PL/SQL stands for “Procedural Language extension to SQL” . It is the mixture of SQL and Procedural features provided by programming language. It was developed by Oracle Corporation in the late 1980s as procedural extension language for SQL and the Oracle relational database.
PL/SQL programs consists of blocks that can be nested and a block structure look likes this −
DECLARE -- it contains declaration statements BEGIN -- It contains executable statements EXCEPTIONS -- It contains exception handling statements END;
In PL/SQL single-line comments begin with double hyphen(--) and Multi-line comments begin with a slash-asterisk ( /* ) and end with an asterisk-slash ( */ )
--Declaration Block DECLARE -- Declaration of string for tutorialspoint St VARCHAR2(100) := 'tutorialspoint'; -- length(len) of string and number(numb) for rows len VARCHAR2(100); numb NUMBER(15); -- Execution part starts from here BEGIN --calculating length of string numb:=LENGTH(St); -- strting of while from num to till num>1 WHILE numb>=1 LOOP len:=SUBSTR(St,1,numb); numb:=numb-1; DBMS_OUTPUT.PUT_LINE(len); END LOOP; -- end of begining block END; -- End program
If we run above program then it will generate following output
tutorialspoint tutorialspoin tutorialspoi tutorialspo tutorialsp tutorials tutorial tutoria tutori tutor tuto tut tu t