still not get the procedure to compile and run

Sorry again for the problems.
Here is the entire SQL, but I suspect seriously the problem is originally somewhere, with one of the statements.
Any help would be appreciated. Given that I get do this work without a stored procedure (all except the statement execute immediate), then I guess my logic is ok, but as I said, something is not upward.

Thank you
Floyd


The sql is:
coil proc.err
CREATE OR REPLACE PROCEDURE floydw.loadtable_config AS

I have pls_integer;
sql_stmt VARCHAR2 (4000);
all_names VARCHAR2 (4000);
all_names2 VARCHAR2 (4000);
TYPE typ_coltab IS TABLE OF dba_tab_columns % ROWTYPE INDEX BY pls_integer;
coltab_table typ_coltab;
coltab_table2 typ_coltab;
coltab_rec dba_tab_columns % ROWTYPE;
CURSOR cur is SELECT *.
FROM dba_tab_columns where owner = 'GWSTAGING_SENTRYPROD' and table_name = 'CONFIG ';

BEGIN
I: = 0;
Heart OPEN;
LOOP
EXTRACT the heart in coltab_rec;
When the output cur % notfound;
i: = i + 1;
coltab_table (i): = coltab_rec;
coltab_table2 (i) .column_name: = "" ' | " coltab_table (i) .column_name | '"' ;
END LOOP;

all_names: = NULL;
all_names2: = NULL;

FOR j IN 1... I have
LOOP
all_names: = all_names | ',' || coltab_table (j) .column_name;
all_names2: = all_names2 | ',' || coltab_table2 (j) .column_name;
END LOOP;

all_names: = SUBSTR (all_names, 2); -Delete ',' start of list
all_names2: = SUBSTR (all_names2, 2); -Delete ',' start of list

sql_stmt: = 'insert ' | coltab_rec.table_name | ' (' | all_names |) ') SELECT ' | all_names2 | 'OF' config"@sentry_l;';

-dbms_output.put_line ('run' | sql_stmt);
run immediately sql_stmt;
END;
/


If I try to create such what, I get:
SQL > show errors
Errors of PROCEDURE FLOYDW. LOADTABLE_CONFIG:

LINE/COL ERROR
-------- -----------------------------------------------------------------
7/3 PL/SQL: ignored element
7/31 PLS-00201: identifier 'DBA_TAB_COLUMNS' must be declared
10/14 PL/SQL: ignored element
10/14 PLS-00201: identifier 'DBA_TAB_COLUMNS' must be declared
11/18 PL/SQL: statement ignored
12/8 PL/SQL: ORA-00942: table or view does not exist
18/5 PL/SQL: statement ignored
18/20 PLS-00320: the declaration of the type of this expression is
incomplete or incorrect

21/5 PL/SQL: statement ignored

LINE/COL ERROR
-------- -----------------------------------------------------------------
21/24 PLS-00320: the declaration of the type of this expression is
incomplete or incorrect

22/5 PL/SQL: statement ignored
22/22 PLS-00487: Invalid reference to variable
"DBA_TAB_COLUMNS % ROWTYPE.

30/7 PL/SQL: statement ignored
PLS-00487 30/56: Invalid reference to variable
"DBA_TAB_COLUMNS % ROWTYPE.


LINE/COL ERROR
-------- -----------------------------------------------------------------
31/7 PL/SQL: statement ignored
31/61 PLS-00487: Invalid reference to variable
"DBA_TAB_COLUMNS % ROWTYPE.

37/3 PL/SQL: statement ignored
37/33 PLS-00320: the declaration of the type of this expression is
incomplete or incorrect

Hello

Apparently, there is something wrong with the dynamic SQL statement sql_stmt.

sql_stmt := 'insert into ' || coltab_rec.table_name ||' (' || all_names || ') SELECT ' || all_names2 || ' FROM "config"@sentry_l ;' ;

I see an error: sql_stmt must not end with a semicolon. Try:

sql_stmt := 'insert into '
         || coltab_rec.table_name
         || ' ('
         || all_names
         || ') SELECT '
         || all_names2
         || ' FROM "config"@sentry_l' ;

Looks like you have a commented line scheduled for debugging sql_stmt:

--dbms_output.put_line ('executing ' || sql_stmt) ;

This could be a good time to use it.

Remember that the names inside quotation marks are not automatcially converted to uppercase.
So, if you say

...      || ' FROM "config"@sentry_l' ;

then the table name config (all lowercase letters) should work on sentry_l.

Tags: Database

Similar Questions

Maybe you are looking for