Saturday, November 7, 2009

High level language extensions – PL/SQL

High level language extensions – PL/SQL


The plain SQL Program

CREATE TABLE Table1(

e INTEGER,

f INTEGER

);


DELETE FROM Table1;

INSERT INTO Table1 VALUES(1, 3);

INSERT INTO Table1 VALUES(2, 4);



The PL/SQL program



DECLARE

a NUMBER;

b NUMBER;

BEGIN

SELECT e,f INTO a,b FROM Table1 WHERE e>1;

INSERT INTO Table1 VALUES(b,a);


END;

.

run;


Fortuitously, there is only one tuple of Table1 that has first component greater than 1, namely (2,4). The INSERT statement thus inserts (4,2) into Table1.

No comments:

Post a Comment