PL/SQL

 SQL> SET SERVEROUTPUT ON

SQL> Declare

  2  name varchar(12);

  3  sub1 number(4,2);

  4   sub2 number(4,2);

  5   res number(4,2);

  6    Begin

  7  name:= '&name';

  8  sub1:= &sub1;

  9   sub2:= &sub2;

 10  res:= (SUB1+SUB2)/2;

 11  DBMS_OUTPUT.PUT_LINE('Result'||res);

 12  end;

 13  /

Enter value for name: VARDHAN

old   7: name:= '&name';

new   7: name:= 'VARDHAN';

Enter value for sub1: 89

old   8: sub1:= &sub1;

new   8: sub1:= 89;

Enter value for sub2: 85

old   9:  sub2:= &sub2;

new   9:  sub2:= 85;

Result87


PL/SQL procedure successfully completed.


SQL> select substr('Transaction',3,4) from dual;


SUBS

----

ansa


SQL> select replace('welcome to hcl','o','3') from dual;


REPLACE('WELCO

--------------

welc3me t3 hcl


SQL> select concat('welcome to', hcl tech') from dual;

ERROR:

ORA-01756: quoted string not properly terminated



SQL> select concat('welcome to','hcl tech') from dual;


CONCAT('WELCOMETO'

------------------

welcome tohcl tech


SQL> select instr('welcome','i') from dual;


INSTR('WELCOME','I')

--------------------

                   0


SQL> select instr('welcome','I') from dual;


INSTR('WELCOME','I')

--------------------

                   0


SQL> select mod(4,2) from dual;


  MOD(4,2)

----------

         0


SQL> declare

  2   rad number(4,2) ;

  3   PI Constant number(5,2) :=3.14;

  4  area number(5,2);

  5  begin

  6  rad  :=  &rad;

  7  area  := PI*rad*rad;

  8   DBMS_OUTPUT.PUT_LINE('Area of Circle'||area);

  9  end;

 10  /

Enter value for rad: 7

old   6: rad  :=  &rad;

new   6: rad  :=  7;

Area of Circle153.86


PL/SQL procedure successfully completed.


SQL> declare

  2   rad number(4,2) ;

  3   PI Constant number(5,2) :=3.14;

  4  area number(5,2);

  5  begin

  6  rad  :=  &rad;

  7  area  := PI*rad*rad;

  8   DBMS_OUTPUT.PUT_LINE('Area of Circle  :'||area);

  9   end;

 10  /

Enter value for rad: 7

old   6: rad  :=  &rad;

new   6: rad  :=  7;

Area of Circle  :153.86


PL/SQL procedure successfully completed.


Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.