0% found this document useful (0 votes)
2 views

My handwittern-pl-sql command

The document provides an overview of PL-SQL commands, including structure, examples of basic commands like 'Hello World' and summation, and the use of conditional statements and loops. It demonstrates how to declare variables, execute commands, handle exceptions, and implement grading systems and loops. Each section includes code snippets to illustrate the concepts effectively.

Uploaded by

rovag49792
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

My handwittern-pl-sql command

The document provides an overview of PL-SQL commands, including structure, examples of basic commands like 'Hello World' and summation, and the use of conditional statements and loops. It demonstrates how to declare variables, execute commands, handle exceptions, and implement grading systems and loops. Each section includes code snippets to illustrate the concepts effectively.

Uploaded by

rovag49792
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

PL-SQL COMMAND

1.STRUCTURE

DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling>
END;

//--------------------------------------------------------------

2.The 'Hello World' Example

DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN
dbms_output.put_line(message);
END;

//--------------------------------------------------------------

3. SUMMATION

DECLARE
a integer := 10;
b integer := 20;
c integer;
f real;
BEGIN
c := a + b;
dbms_output.put_line('Value of c: ' || c);
f := 70.0/3.0;
dbms_output.put_line('Value of f: ' || f);
END;

//--------------------------------------------------------------

3. THERE IS MANY CONDITIONAL STATEMENT

SUCH AS: IF, ELSIF AND ELSE statement

EG: GRADING SYSTEM:

SET SERVEROUTPUT ON;

DECLARE
score NUMBER;
grade VARCHAR2(2);
BEGIN
-- Input the score
score := &score;

-- Determine the grade based on the score


IF score >= 90 THEN
grade := 'A';
ELSIF score >= 80 THEN
grade := 'B';
ELSIF score >= 70 THEN
grade := 'C';
ELSIF score >= 60 THEN
grade := 'D';
ELSE
grade := 'F';
END IF;

-- Output the grade


DBMS_OUTPUT.PUT_LINE('The grade for the score ' || score || ' is ' || grade);
END;

//--------------------------------------------------------------

4. LOOPS

EG: LOOPS TO DISPLAY NUMBERS FROM 1 TO 10 ALONG WITH THEIR SQUARES:

SET SERVEROUTPUT ON;

DECLARE
i INTEGER := 1;
square INTEGER;
BEGIN
-- Loop to display numbers and their squares from 1 to 10
WHILE i <= 10 LOOP
square := i * i;
DBMS_OUTPUT.PUT_LINE('Number: ' || i || ', Square: ' || square);
i := i + 1;
END LOOP;
END;

//--------------------------------------------------------------

You might also like