Yurttas/PL/DBL/oracle/F/02/Bank/u07.sp

From ZCubes Wiki
Jump to navigation Jump to search
 1CREATE OR REPLACE
 2PROCEDURE u07 IS
 3
 4  cursor_handle INTEGER;
 5
 6  depositor_inserted INTEGER;
 7
 8BEGIN
 9
10  DBMS_OUTPUT.PUT_LINE('Insert account 9732 for customer ''Smith'' with a balance');
11  DBMS_OUTPUT.PUT('of $1200 at the ''Perryridge'' branch...');
12  
13  cursor_handle := DBMS_SQL.OPEN_CURSOR;
14
15  DBMS_SQL.PARSE(cursor_handle, 
16                'INSERT INTO Depositor '||
17                '  VALUES(''Perryridge'', 9732, ''Smith'', 1200)',
18                 DBMS_SQL.V7);
19
20  depositor_inserted := DBMS_SQL.EXECUTE(cursor_handle);
21
22  DBMS_SQL.CLOSE_CURSOR(cursor_handle);
23
24  DBMS_OUTPUT.PUT_LINE('Done.');
25
26EXCEPTION
27  WHEN OTHERS
28  THEN
29    DBMS_SQL.CLOSE_CURSOR(cursor_handle);
30    DBMS_OUTPUT.PUT_LINE('Error inserting new account for customer ''Smith''.');
31
32END;
33/