I am not quite sure what error you are geting since
you did not specify it.
But you will definately need to have explicit direct
'CREATE TABLE' privilege, then you may want to try
this:
CREATE OR REPLACE PROCEDURE CR_TABLE AS
QUERY1 VARCHAR2(200);
QUERY2 VARCHAR2(200);
CUR1 INTEGER;
RET1 INTEGER;
A NUMBER;
BEGIN
CUR1:=DBMS_SQL.OPEN_CURSOR;
QUERY1:='CREATE TABLE CR AS SELECT * FROM INS';
DBMS_SQL.PARSE(CUR1,QUERY1,DBMS_SQL.V7);
RET1:=DBMS_SQL.EXECUTE(CUR1);
DBMS_SQL.CLOSE_CURSOR(CUR1);
DBMS_OUTPUT.PUT_LINE('TABLE CREATED');
CUR1:=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(CUR1,'SELECT COUNT(*) FROM
CR',DBMS_SQL.V7);
DBMS_SQL.DEFINE_COLUMN (cur1, 1, a);
RET1:=DBMS_SQL.EXECUTE_AND_FETCH(CUR1);
DBMS_SQL.COLUMN_VALUE (cur1, 1, a);
DBMS_SQL.CLOSE_CURSOR(CUR1);
DBMS_OUTPUT.PUT_LINE(a||' - '||'ROWS COUNTED');
END;
/
- anurag dewan <anu_dewan_at_yahoo.co.uk> wrote:
> Hi,
> I have to dynamically create a table and then
> dynamically get the count
> of the rows in a variable. i'm using Oracle 7.3.4.
> i have written the following code...but its not
> working.
> please help me out.
> thanx in advance.
>
> CREATE OR REPLACE PROCEDURE CR_TABLE AS
> A NUMBER;
> QUERY1 VARCHAR2(200);
> QUERY2 VARCHAR2(200);
> CUR1 INTEGER;
> CUR2 INTEGER;
> RET1 INTEGER;
> RET2 INTEGER;
> BEGIN
> CURSOR1:=DBMS_SQL.OPEN_CURSOR;
> QUERY1:='CREATE TABLE CR AS SELECT * FROM INS';
> DBMS_SQL.PARSE(CUR1,QUERY1,DBMS_SQL.V7);
> RET1:=DBMS_SQL.EXECUTE(CUR1);
> DBMS_SQL.CLOSE_CURSOR(CUR1);
> DBMS_OUTPUT.PUT_LINE('TABLE CREATED');
> CUR2:=DBMS_SQL.OPEN_CURSOR;
> QUERY2:='SELECT COUNT(*) FROM CR';
> DBMS_SQL.PARSE(CUR2,QUERY2,DBMS_SQL.V7);
> RET2:=DBMS_SQL.EXECUTE_AND_FETCH(CUR2);
> A:=DBMS_SQL.LAST_ROW_COUNT;
> DBMS_SQL.CLOSE_CURSOR(CUR2);
> DBMS_OUTPUT.PUT_LINE('ROWS COUNTED');
> END;
>
> -anurag
>
>
>
> Do You Yahoo!?
> Get your free @yahoo.co.uk address at
> http://mail.yahoo.co.uk
> or your free @yahoo.ie address at
> http://mail.yahoo.ie
> --
> Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> --
> Author: =?iso-8859-1?q?anurag=20dewan?=
> INET: anu_dewan_at_yahoo.co.uk
>
> Fat City Network Services -- (858) 538-5051 FAX:
> (858) 538-5051
> San Diego, California -- Public Internet
> access / Mailing Lists
>
> To REMOVE yourself from this mailing list, send an
> E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of
> 'ListGuru') and in
> the message BODY, include a line containing: UNSUB
> ORACLE-L
> (or the name of mailing list you want to be removed
> from). You may
> also send the HELP command for other information
> (like subscribing).
Get personalized email addresses from Yahoo! Mail - only $35
Received on Wed Jan 31 2001 - 13:17:13 CST