Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create table dynamically and insert in procedure

Ricky007Apr 12 2017 — edited Apr 13 2017

Dear experts,

                      unable to create table , insert on same table in procedure and drop the same table after processing,it is giving below error

CREATE TABLE TEMP_HIST

(

T_SNO NUMBER,

T_ACT_TERM NUMBER

);

INSERT INTO TEMP_HIST VALUES(1,234);

INSERT INTO TEMP_HIST VALUES(2,567);

commit;

DECLARE

P_VAL VARCHAR2(20);

begin

execute immediate 'Create Table Temp(SLNo number(10) ,ACT_TERM_ID varchar2(15))';

IF P_VAL='DESC' THEN

INSERT INTO TEMP (SLNo,ACT_TERM_ID)

SELECT T_SNO,T_ACT_TERM FROM TEMP_HIST

ORDER BY T_SNO;

END IF;

EXECUTE IMMEDIATE 'DROP TABLE Temp';

end;

/

unable to create table , insert on same table in procedure and drop the same table after processing,it is giving below error

error occured

ORA-06550: line 6, column 13:

PL/SQL: ORA-00942: table or view does not exist

ORA-06550: line 6, column 1:

PL/SQL: SQL Statement ignored

06550. 00000 -  "line %s, column %s:\n%s"

*Cause:    Usually a PL/SQL compilation error.

*Action:

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2017
Added on Apr 12 2017
8 comments
7,378 views