Friday, September 5, 2025
HomeData Modelling & AIPrint pyramid of GeeksforGeeks in PL/SQL

Print pyramid of GeeksforGeeks in PL/SQL

PL/SQL is a block-structured language that enables developers to combine the power of SQL with procedural statements. All the statements of a block are passed to the oracle engine all at once which increases processing speed and decreases the traffic.
PL/SQL extends SQL by adding constructs found in procedural languages, resulting in a structural language that is more powerful than SQL. The basic unit in PL/SQL is a block. All PL/SQL programs are made up of blocks, which can be nested within each other.

Typically, each block performs a logical action in the program. A block has the following structure:

DECLARE
    declaration statements;

BEGIN
    executable statements

EXCEPTIONS
    exception handling statements

END;

Now write a program in pl/sql which print a pyramid of string “neveropen” shown below

Examples – 

neveropen
GeeksforGeek
GeeksforGee
GeeksforGe
GeeksforG
Geeksfor
Geeksfo
Geeksf
Geeks
Geek
Gee
Ge
G

Code –

C++




--Declaration Block
DECLARE
  
-- declaration of string as Geeksforneveropen
str VARCHAR2(100) := 'neveropen';
  
-- len of string and num for no of rows
len VARCHAR2(100);
num NUMBER(15);
  
-- execution part begin 
BEGIN
  
--calculating length of string
num:=LENGTH(str);
  
  
-- starting of while from 
-- from num to till num>1
WHILE num>=1
    LOOP
        len:=SUBSTR(str,1,num);
        num:=num-1;
        DBMS_OUTPUT.PUT_LINE(len);
          
--ending of loop here        
END LOOP; 
  
-- end of beginning block
END; 
  
-- End program


Output: 

neveropen
GeeksforGeek
GeeksforGee
GeeksforGe
GeeksforG
Geeksfor
Geeksfo
Geeksf
Geeks
Geek
Gee
Ge
G

Disadvantages of SQL – 

  • SQL doesn’t provide the programmers with a technique of condition checking, looping, and branching.
  • SQL statements are passed to the Oracle engine one at a time which increases traffic and decreases speed.
  • SQL has no facility of error checking during manipulation of data.
Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32269 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6637 POSTS0 COMMENTS
Nicole Veronica
11802 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11865 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7027 POSTS0 COMMENTS
Thapelo Manthata
6704 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS