# Database Discussions > Oracle >  please check my PL/SQL answers

## dai_lo

Practice 1
1.	Evaluate each of the following declarations. Determine which of them are not legal and explain why
a.	DECLARE
v_id                  NUMBER(4);                    

correct

b.	DECLARE
v_x, v_y, v_z                VARCHAR(2);

incorrect, because cant declare multiple variables at once

c.	DECLARE
       v_birthdate 		DATE  NOT NULL;

      incorrect, because must assign a value 

 d.   DECLARE
	    v_in_stock        	BOOLEAN :=1;
	incorrect, it should be BOOBLEAN:=true;

2.	In each of the following assignments, indicate whether the statement is valid and what the valid data type of the result will be.
a.	v_days_to_go:= v_due_date  -  SYSDATE;
correct, it will return a numeric value

b.	v_sender := USER || : ||  TO_CHAR(v_dept_no);
incorrect, because USER could be an non-string value

c.	v_sum : $100,000 + $250,000;
incorrect, because $ is not allowed 

d.	v_flag := True;
correct

e.	v_n1 := vn2 > (2 * v_n3);
Correct, it will return True/False

f.	v_value := NULL;
incorrect, Null cant assign to variable.

----------


## vikaul

********************************************
b. v_sender := USER || : || TO_CHAR(v_dept_no);
incorrect, because USER could be an non-string value
********************************************

Oracle does implicit conversion wherever possible.

SQL> ed
Wrote file afiedt.buf

  1  declare
  2     USER      number := 33;
  3     v_sender  varchar2(100);
  4     v_dept_no number(2) := 5;
  5  begin
  6     v_sender := USER || ':' || TO_CHAR(v_dept_no);
  7     dbms_output.put_line(v_sender);
  8* end;
SQL> 
SQL> /
33:5

PL/SQL procedure successfully completed.

SQL> 

********************************************
f. v_value := NULL;
incorrect, Null cant assign to variable. 
********************************************

You can assign NULL to a variable

SQL> declare
  2   v_null varchar2(1);
  3  begin
  4   v_null := NULL;
  5  end ;
  6  /

PL/SQL procedure successfully completed.

SQL>

----------

