Skip to main content

PL/SQL :

1.Hellow world program

Begin

Dbms_output.put_line(‘Hellow world!!!!!!’);

End;

/

Output:

Hellow world!!!!!

*note :-this may not show you direct output so typeà
set serveroutput on;


2.Display 2 variables

Declare

X number;

Y number;

Begin

X:=10;

Y:=20;

Dbms_output.put_line(x);

Dbms_output.put_line(y);

End;

/

Output:

10

20

OR

Declare

X number;

Y number;

Begin

X:=10;

Y:=20;

Dbms_output.put_line(‘x=’);

Dbms_output.put_line(x);

Dbms_output.put_line(‘y=’);

Dbms_output.put_line(y);

End;

/

Output:

X=

10

Y=

20



3. Addition of two number

Declare

X int;

Y int;

Z int;

Begin

X:=10;

Y:=20;

Z:=X+Y

Dbms_output.put_line(z);

End;

/

Output:

30

4.Arithm 

declare

  x int;

    y int;

    z int;

    begin

    x:=100;

    y:=200;

    dbms_output.put_line('addition');

    dbms_output.put_line(x+y);

   dbms_output.put_line('subtraction');

  dbms_output.put_line(x-y);

  dbms_output.put_line('multiplication');

  dbms_output.put_line(x*y);

  dbms_output.put_line('division');

  dbms_output.put_line(x/y);

  end;

  /



Ouput:

addition

300

subtraction

-100

multiplication

20000

division

.5


PL/SQL procedure successfully completed.



PL/SQL

Prerequicisio:

Conn

System

Root

Se serveroutput on;

1.Hellow world program



--single line commet using double hyphen

Begin

Dbms_output.put_line(‘Hellow world!!!!!!’);

End;

/

Output:

Hellow world!!!!!

*note :-this may not show you direct output so typeà set serveroutput on;

2.Display 2 variables

Declare

X number;

Y number;

Begin

X:=10;

Y:=20;

Dbms_output.put_line(x);

Dbms_output.put_line(y);

End;

/

Output:

10

20

OR

Declare

X number;

Y number;

Begin

X:=10;

Y:=20;

Dbms_output.put_line(‘x=’);

Dbms_output.put_line(x);

Dbms_output.put_line(‘y=’);

Dbms_output.put_line(y);

End;

/

Output:

X=

10

Y=

20



3. Addition of two number

Declare

X int;

Y int;

Z int;

Begin

X:=10;

Y:=20;

Z:=X+Y

Dbms_output.put_line(z);

End;

/

Output:

30

4.Arithmetic operation

 declare

  x int;

    y int;

    z int;

    begin

    x:=100;

    y:=200;

    dbms_output.put_line('addition');

    dbms_output.put_line(x+y);

   dbms_output.put_line('subtraction');

  dbms_output.put_line(x-y);

  dbms_output.put_line('multiplication');

  dbms_output.put_line(x*y);

  dbms_output.put_line('division');

  dbms_output.put_line(x/y);

  end;

  /



Ouput:

addition

300

subtraction

-100

multiplication

20000

division

.5



PL/SQL procedure successfully completed.
 

5. Program for initializing variables in declaration section

Declare

A int:=10;

Begin

Dbms_output.put_line(‘value of a is=’||A);

End;

/

Output:

 

6.Table based recors:

declare

  2  cust customers%rowtype;

  3  begin

  4  select * into cust

  5  from customers where cust_id=1;

  6  dbms_output.put_line('cust id='||cust.cust_id);

  7  dbms_output.put_line('cust name='||cust.cust_nm);

  8  dbms_output.put_line('cust address='||cust.cust_add);

  9  dbms_output.put_line('cust slary='||cust.salary);

 10  end;

 11  /

Output:

cust id=1

cust name=vishakha umale

cust address=akola

cust slary=50000






7.Cursor based record:

SQL> declare

  2  cursor cur1 is

  3  select cust_id,cust_nm,cust_add

  4  from customers;

  5  cust cur1%rowtype;

  6  begin

  7  open cur1;  --cursor is opened here

  8  loop

  9  fetch cur1 into cust;

 10  exit when cur1%notfound;

 11  dbms_output.put_line(cust.cust_id||' '||cust.cust_nm||' '||cust.cust_add);

 12  end loop;

 13  end;

 14  /











Comments

Popular posts from this blog

Naming Convention

  Naming Convention : A naming convention is  a convention for naming things: Please find below the table for naming conventions: Naming Convention Format Example Camel Case camelCase 🐪aBcD Kebab Case kebab-case 🍢a-b-c-d Snake Case snake_case 🐍a_b_c_d Pascal Case PascalCase 🧑‍🦳AbCd Flat Case flatcase 📏abcd Upper Flat Case UPPERFLATCASE ABCD Screaming Snake Case SCREAMING_SNAKE_CASE 🐍A_B_C_D Camel Snake Case camel_Snake_Case 🐪🐍ab_Cd Pascal Snake Case Pascal_Snake_Case Ab_Cd Train Case Train-Case 🚃Ab-Cd Cobol Case COBOL-CASE 🍢AB-CD
How to run lex yacc programs on win 10 In short: For Lex steps to run: lex lex7.l gcc lex.yy.c a     For YACC steps to run: lex simple_compound.l yacc -d simple_compound.y gcc lex.yy.c y.tab.c a                          A.Lex 1. download flex for windows http://flex-windows-lex-and-yacc.software.informer.com/2.5/ 2. install it locatin:  C:\Flex Windows\ 3.open cmd 4.You need to change location as follows:  cd C:\Flex Windows\EditPlusPortable 5. Steps to run : lex lex7.l gcc lex.yy.c a Output : Word Count : 13 Char Count : 80 Line Count : 7 codes : lex7.l %{ /* *Program to count no of characters, words and lines */ #include<stdio.h> #include<string.h> int c=0,w=0,l=0; %} %% [\t ]+              /* ignore whitespace */ [a-zA-z]+  ...

Simple java code

  Simple java code class Main{ /*Every application in Java must contain the main method. The Java compiler starts executing the code from the main method*/      public static void main(String anyVar[]){      System.out.println("Simple java code");       } } Output: Simple java code Screenshot: Online compiler:https://www.onlinegdb.com/online_java_compiler #happyCoding💁👍