ERROR creating table with dynamic SQL :-(

Advertisement

ERROR creating table with dynamic SQL :-(
Hi friends,
I have a problem when I try to create a table using dynamic SQL.
(Env.: Forms 6i, WinXP, Oracle 9i)
I only want to create a table, insert data and drop the table.
I have a user with the correct privileges (At least ....I think so), because I can to make the three actions in SQL*PLUS (CREATE TABLE, INSERT .. and DROP TABLE).
I want to do the same in Forms using dynamic SQL...
I've made a package with 3 procedures:
1st to create the table, 2nd to insert data , 3rd to drop the table.
Only the 1st fails with the error ORA-01031 (insufficient privileges).
Here it is:
PROCEDURE PRO_DM_CreaTabla(pe_nombre_tabla VARCHAR2) IS
id_cursor INTEGER;
ls_sentencia VARCHAR2(500);
v_dummy integer;
BEGIN
id_cursor := DBMS_SQL.OPEN_CURSOR;
ls_sentencia := 'CREATE TABLE '||pe_nombre_tabla||' ( campo1 VARCHAR2(100), campo2 VARCHAR2(100), campo3 VARCHAR2(100),campo4 VARCHAR2(100))';
DBMS_SQL.PARSE(id_cursor, ls_sentencia, dbms_sql.NATIVE);
v_dummy := dbms_sql.execute(id_cursor);
DBMS_SQL.CLOSE_CURSOR(id_cursor);
END;
The DROP_table procedure is exactly the same as this (with the difference of the 'CREATE' sentence, where I have a DROP sentence)... then.. why the DROP procedure works?... and.. why this CREATE procedure doesn't work?
Any ideas?
Thanks a lot.
Jose.
Repaly
From a different thread, Jose wrote:
V_INSERT:='INSERT INTO TMP_TABLE(field1,field3,field3,field4) VALUES (1,2,3,4)';
Forms_DDL(V_INSERT);
commit;First, try your statement in SQL Plus:
INSERT INTO TMP_TABLE(field1,field3,field3,field4) VALUES (1,2,3,4);
Then if that works, try doing this right after the Forms_DDL(V_INSERT);
If not form_success then
  Message('   Insert has failed');
  Raise form_trigger_failure;
Else
  Forms_DDL('COMMIT');
End if;
Read More: The other 8 answers