Yurttas/PL/DBL/oracle/F/02/PC/Product-def.sp
Jump to navigation
Jump to search
1/*
2REM
3REM
4REM Product-def.sp
5REM
6REM
7*/
8
9DECLARE
10
11 cursor_handle INTEGER;
12
13 product_created INTEGER;
14
15BEGIN
16
17 cursor_handle :=DBMS_SQL.OPEN_CURSOR;
18
19 DBMS_SQL.PARSE(cursor_handle,
20 'CREATE TABLE Product(maker VARCHAR2(6) NOT NULL, '||
21 'model VARCHAR2 (6) NOT NULL, '||
22 'type VARCHAR2(8) NOT NULL, '||
23 'PRIMARY KEY(model))',
24 DBMS_SQL.V7);
25
26 product_created := DBMS_SQL.EXECUTE(cursor_handle);
27
28 DBMS_SQL.CLOSE_CURSOR(cursor_handle);
29
30 DBMS_OUTPUT.PUT_LINE('Table ''Product'' created successfully');
31
32EXCEPTION
33 WHEN OTHERS
34 THEN
35 DBMS_SQL.CLOSE_CURSOR(cursor_handle);
36 DBMS_OUTPUT.PUT_LINE('Table ''Product'' cannot be created');
37 DBMS_OUTPUT.PUT_LINE('Table ''Product'' may already exist');
38
39END;
40/