Unable To Run Dynamic Query In Stored Procedure While Selecting Count Of Records
Hi I am trying to simply get the count of data in source table. CREATE OR REPLACE PROCEDURE MOVE_CHECK (SCHEMA_SOURCE IN VARCHAR2, SCHEMA
Solution 1:
Your dynamic statement should not have a semicolon at the end; that is a statement separator and not relevant or valid for a single statement. You can only run a single SQL statement dynamically anyway (unless you put several into an anonymous PL/SQL block).
Your into
is in the wrong place too:
TEMP_1 := 'select count ( '|| E ||' ) from ' || C;
DBMS_OUTPUT.PUT_LINE ('STARTED');
DBMS_OUTPUT.PUT_LINE (TEMP_1);
EXECUTE IMMEDIATE TEMP_1 INTO Count_source;
Not sure why you're bothering to have and assign local variables when you can use the procedure arguments directly, which I think makes the statement more readable:
TEMP_1 := 'select count ( '|| COLUMN_SOURCE ||' ) from ' || TABLE_SOURCE;
Post a Comment for "Unable To Run Dynamic Query In Stored Procedure While Selecting Count Of Records"