Sequence  name vs. sequence in EXECUTE IMMEDIATE

Hello !
I don't know how to use a string in another string in PLSQL:
I have to reset all the sequences starting with the last value of a similar sequence in another database with link between tables
Look at first EXECUTE IMMEDIATE
This works fine:
cval INTEGER;
BEGIN
FOR r IN (select sequence_name from user_sequences)
LOOP
EXECUTE IMMEDIATE 'SELECT ' || r.sequence_name ||'.NEXTVAL@decobrv FROM dual' INTO cval;
EXECUTE IMMEDIATE 'DROP SEQUENCE ' || r.sequence_name ;
EXECUTE IMMEDIATE 'CREATE SEQUENCE '|| r.sequence_name ||' START WITH ' || cval ||' INCREMENT BY 1 NOCACHE NOCYCLE';
END LOOP;
END;
but I don't want to use .NEXTVAL but SELECT LAST_NUMBER FROM USER_SEQUENCES
so I'm using:
FOR r IN (select sequence_name from user_sequences)
LOOP
EXECUTE IMMEDIATE 'SELECT LAST_NUMBER FROM USER_SEQUENCES@decobrv WHERE SEQUENCE_NAME=' || r.sequence_name || '' INTO cval;
EXECUTE IMMEDIATE 'DROP SEQUENCE ' || r.sequence_name ;
EXECUTE IMMEDIATE 'CREATE SEQUENCE '|| r.sequence_name ||' START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE';
END LOOP;
An error is rising:
Input parameters
Execution finished with error
ORA-00904: "S_RANDURI_CONTRACTE": invalid identifier
because it use the sequence name as parameter. I have to convert the sequence name to string but I dont know how
The same error as I'm using:
" Select Product from Products where Category = A "
will rise an error
but
" Select Product from Products where Category = 'A' "
works fine.
But how to put this ' in EXECUTE IMMEDIATE ??
I'm very beginner on PLSQL
Thank you !

Are these remote sequences not being used concurrently with this select then?
If they are, then you might be better taking last_number or nextval + a bit more.
The problem you were having was with the quoting of the sequence name in your first execute immediate.
So, either add more quotes to escape the other other quotes or just get rid, e.g.
BEGIN
FOR r IN (select local.sequence_name
          ,      remote.last_number
          from   user_sequences local
          ,      user_sequences@decobrv remote
          WHERE  remote.sequence_name = local.sequence_name)
LOOP
EXECUTE IMMEDIATE 'DROP SEQUENCE ' || r.sequence_name ;
EXECUTE IMMEDIATE 'CREATE SEQUENCE '|| r.sequence_name ||' START WITH ' || r.last_number ||' INCREMENT BY 1 NOCACHE NOCYCLE';
END LOOP;
END;
/

Similar Messages

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • EXECUTE IMMEDIATE usage with SEQUENCE problem

    execute immediate 'INSERT INTO ZLYT_IZRACUN_RANGA_METRIK (IID_IZRACUNA_RANGA_METRIKE, POVPRECJE, DATUM_SPREMEMBE, UPORABNIK, IID_TIPA, IID_IZRACUNA, IID_METRIKE) VALUES (:1, :2, :3, :4, :5, :6, :7)'
    using 'zkes_ZLYZIZRAME.nextval', average_rank, sysdate, user, r_types.iid_tipa, r_types.iid_izracuna, r_types.iid_metrike;
    and i get 01722. 00000 - "invalid number".
    How must i use sequence in execute immediate?

    user13256715 wrote:
    execute immediate 'INSERT INTO ZLYT_IZRACUN_RANGA_METRIK (IID_IZRACUNA_RANGA_METRIKE, POVPRECJE, DATUM_SPREMEMBE, UPORABNIK, IID_TIPA, IID_IZRACUNA, IID_METRIKE) VALUES (:1, :2, :3, :4, :5, :6, :7)'
    using 'zkes_ZLYZIZRAME.nextval', average_rank, sysdate, user, r_types.iid_tipa, r_types.iid_izracuna, r_types.iid_metrike;
    and i get 01722. 00000 - "invalid number".
    How must i use sequence in execute immediate?Lose the quotes.
    create table for_immediate_execution
          col1 number primary key
       ,  col2 number
    create sequence s start with 1 increment by 1;
    begin
       execute immediate 'insert into for_immediate_execution (col1, col2) values (:0, :1)' using s.nextval, 2;
    end;
      4  /
    PL/SQL procedure successfully completed.
    TUBBY_TUBBZ?select * from for_immediate_execution;
          COL1      COL2
          4         2
    1 row selected.
    TUBBY_TUBBZ?

  • EXECUTE IMMEDIATE NO PRIVALIGE

    No privilege to execute this statement ,but the current user is already has right to create sequence.
    EXECUTE IMMEDIATE(' CREATE SEQUENCE '||P_Sequance_Name||
                             ' START WITH '||P_Start_With||
                             ' MAXVALUE '||P_MaxValue||
                             ' MINVALUE '||P_MinValue||
                             ' '||P_CYCLE||
                             ' '||P_CACHE||
                             ' '||P_ORDER);

    If you trying to use EXECUTE IMMEDIATE in forms procedure - this is probably not a privilege problem.
    EXECUTE IMMEDIATE is is not supported in client side.
    Try to replace it with
    forms_ddl(' CREATE SEQUENCE '||P_Sequance_Name||
                                ' START WITH '||P_Start_With||
                                ' MAXVALUE   '||P_MaxValue||
                                ' MINVALUE   '||P_MinValue||
                                ' '||P_CYCLE||
                                ' '||P_CACHE||
                                ' '||P_ORDER);

  • How to pass a sequence by 'using' for execute immediate

    how i can pass a sequence.nxlval as a parameter through using , here is my code looks like
    sql_string is -> insert into some_tab (col1,col2, ....) (select col1,:passed_seq,......) where .... (i want to insert sequence values for col2)
    and i am calling this as
    passed_seq := 'seq_'||some_dynamic_num||'.nextval' ( in my db there will be sequences with the formed string like seq_10.nextval)
    EXECUTE IMMEDIATE sql_string using passes_seq;
    if i am doing like this i am getting
    Error : -1722:ORA-01722: invalid number seq_10.nextval
    Edited by: DIVI on Jan 8, 2013 7:40 AM

    Hi,
    I hope you have created sequence as below
    SQL>
    SQL> CREATE SEQUENCE seq
      2  MINVALUE 1
      3  START WITH     1
      4  INCREMENT BY   1
      5  NOCACHE
      6  NOCYCLE;
    Sequence created.
    SQL>
    SQL> SELECT * FROM TEST1;
         EMPNO EMPTYPE              EMP_ADDRESS              SALARY     DEPTNO
             1 HR                   MUMBAI                    10000         10
             2 ADMIN                THANE                      6000         20
    SQL>
    SQL> INSERT INTO TEST1 (EMPNO)
      2  VALUES(SEQ.NEXTVAL);
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> SELECT * fROM TEST1;
         EMPNO EMPTYPE              EMP_ADDRESS              SALARY     DEPTNO
             1 HR                   MUMBAI                    10000         10
             2 ADMIN                THANE                      6000         20
             1
    SQL>Now if you need to add different numbe in differenct condition then create multiple sequence and use them accounding.

  • Execute immediate with using clause to pass column name dynamically

    Hai,
    Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
    1. Column value as dynamic, which is working correctly.
    create or replace function testexeimm (acctnum char)
    return number as
    acctbal number;
    begin
    execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
    return acctbal;
    end;
    2. Column name as dynamic which is not working
    create or replace function testexeimm (colnam char)
    return char as
    acctbal char;
    begin
    execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
    return acctbal;
    end;
    Any help in this regard will be highly appericated.
    Regards
    Sridhar

    So the variable has to be numeric too:
    create or replace function testexeimm (colnam char)
    return number as
    acctbal number;
    begin
    execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
    return acctbal;
    end;Max
    http://oracleitalia.wordpress.com

  • Why does a sequence structure execute if a while loop is to the left of it?

      I have a while loop in a case structure whose boolean is wired to a sub vi.  To the right of this structure I have a sequence that executes regardless of the while loops condition.  I assumed that the program would not continue to the case structure until the while loop stopped.  Then it would proceed to the case structure.
    Thank You

    jemengineering wrote:
      I have a while loop in a case structure whose boolean is wired to a sub vi.  To the right of this structure I have a sequence that executes regardless of the while loops condition.  I assumed that the program would not continue to the case structure until the while loop stopped.  Then it would proceed to the case structure.
    As others have mentioned, you have to familiarize yourself with the core idea of dataflow programming. One of the great powers of LabVIEW is the fact that things can occur in paralell unless there is data dependency.
    A good start would be the LabVIEW beginners online tutorial:
    http://www.ni.com/swf/presentation/us/labview/aap/default.htm
    The quiz #1 on slide 11 deals with the above issues. Try to answer it. 
    In your particular case, you need to force execution order. This can be done by creating a data dependency (preferred) or by the use of a sequence structure. You could e.g. create a 2-frame flat sequence and place the loop in the first frame and the case structure in the second frame.
    The picture shows a few scenarios for comparison. Can you spot the differences?  Understanding dataflow is crucial for writing any LabVIEW program.
    Message Edited by altenbach on 07-31-2006 06:49 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ExecutionOrder.png ‏19 KB

  • Invalid Table Name error in EXECUTE IMMEDIATE

    Hi there.
    I am trying to truncate few debug tables I created a used ago. Refer the code
    declare
    lv_sql varchar2(100) := 'truncate table :b1';
    begin
    for i in (select object_name
                 from all_objects
                where object_type = 'TABLE'
                  and object_name like 'DEBUG_%'
                  and owner = user)
    loop             
       dbms_output.put_line('Table Name: '||i.object_name);
       execute immediate lv_sql using i.object_name;
    end loop;
    end;Seems to be correct (unless I messed something big). And, I get an error message:
    ORA-00903: invalid table name
    ORA-06512: at line 13Any idea? Thanks in advance.

    you can't bind table or column names... try this instead:
    declare lv_sql varchar2(100);
    begin for i in (select object_name
                  from all_objects
                where object_type = 'TABLE'
                  and object_name like 'DEBUG_%'
                  and owner = user) loop
                     dbms_output.put_line('Table Name: '||i.object_name);
       lv_sql := 'truncate table '||i.object_name;
       execute immediate lv_sql;
    end loop;
    end;Message was edited by:
    RACER
    forgot ending  tag

  • In TestStand, how can a main sequence be executed while sending RS-232 messages at a fixed periodic rate (e.g. every 500 msec, independent of the steps executing in the main sequence)?

    I am trying to send periodic RS-232 messages (through a DLL function) while a sequence is executing. Does TestStand have periodic timers that can be used to perform periodic tasks independent of other sequences executing?
    Thanks,
    John Merritt

    John -
    In TestStand 2.x, you could have a root sequence launch a subsequence in a new thread. The root sequence call could auto wait for the thread.
    1) The new thread could have a loop structure that contains a label, action, wait and goto step. The action step could send the message.
    or
    2) You could also have a single step loop internally to periodically send the messages, but the step should monitor the execution status for termination, and the step should process messages while waiting inside the step.
    Hope this helps...
    Scott Richardson NI
    Scott Richardson
    National Instruments

  • Need suggestion on PLSQL Create and EXECUTE IMMEDIATE

    Most of you already know plsql doesn't like create table, so we have to use EXECUTE IMMEDIATE for creating table. What if I want to see if the table exist, if not then create the table, later I will insert data into that table.
    My problem is it returned me the error saying I am try to insert into a non existing table when trying to compile my code. I think plsql doesn't pick up the execute statement.
    what I did is, both create and insert are executed by using EXECUTE IMMEDIATE. Anyone have such experience before and willing to share your knowledge?
    PS: I am having same problem for creating sequence as well.

    I think plsql doesn't pick up the execute statement.Since it is a runtime instruction, it will pick it up at runtime. but to be able to run, it needs to compile the code and in order to compile (so it can run) the code it needs that table/sequence you are referencing to exist already. So, you need to run the code to get the table and run needs to compile the code and compile needs the table to compile. can't go from here to there when you try to mix dynamic sql with static sql on the same object within the same program unit (or dependent units).

  • Problem using EXECUTE IMMEDIATE

    Hi,
    I am running the following procedure..
    table emp ( empno number,ename varchar2 , dept varchar2 )
    CREATE OR REPLACE PROCEDURE Sp_Test11 ( p_dept IN VARCHAR2 )
    IS
    m_count               NUMBER               :=     NULL;
    m_sql_query               VARCHAR2(32767) := 'SELECT COUNT(*) INTO m_count FROM emp WHERE dept = ';
    BEGIN
    m_sql_query := m_sql_query||''''||p_dept||''''||';';
         EXECUTE IMMEDIATE m_sql_query ;
    END Sp_Test11;
    I am getting the "Invalid character" error on execute immediate statement when i debug ..
    Please guide.

    venkata wrote:
    Use RETURN or RETURNING INTO Keywords in execute immediate statement.RETURNING INTO is used with INSERT/UPDATE/DELETE statements when there will be triggers that will populate something on the table after an insert or update etc. e.g. when you insert a new record and you want to return the primary key that is automatically generated from a sequence so you can use it in your code for something else.
    If you are SELECTing data then you would use the INTO keyword as Gj demonstrated.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_cnt number;
      3  begin
      4    execute immediate 'select count(*) from x' returning into v_cnt;
      5* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-06547: RETURNING clause must be used with INSERT, UPDATE, or DELETE statements
    ORA-06512: at line 4
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_cnt number;
      3  begin
      4    execute immediate 'select count(*) from x' into v_cnt;
      5* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL>It's amazing how many people are just jumping in here with wrong answers.

  • Execute immediate return

    Hi,
    I want to know if it's possible to use the return clause with the insert statement with EXECUTE IMMEDIATE.
    My code looks like:
    execute immediate('INSERT INTO '||p_nameDB||'.TableName (col1) VALUES (:1)
         ') using p_col1;
    The id is generated automatically with a trigger (and a sequence). And I want to recuperate it in a variable after the insert statement. I don't want to do a seq.currval after because i'm afraid that there will be a mix match with the sequence and the id if 2 persons accede at the same time.
    thanks

    execute immediate 'insert into trial (a) values (:1) returning a into :2' using a1 returning into x ;

  • Error while insert data using execute immediate in dynamic table in oracle

    Error while insert data using execute immediate in dynamic table created in oracle 11g .
    first the dynamic nested table (op_sample) was created using the executed immediate...
    object is
    CREATE OR REPLACE TYPE ASI.sub_mark AS OBJECT (
    mark1 number,
    mark2 number
    t_sub_mark is a class of type sub_mark
    CREATE OR REPLACE TYPE ASI.t_sub_mark is table of sub_mark;
    create table sam1(id number,name varchar2(30));
    nested table is created below:
    begin
    EXECUTE IMMEDIATE ' create table '||op_sample||'
    (id number,name varchar2(30),subject_obj t_sub_mark) nested table subject_obj store as nest_tab return as value';
    end;
    now data from sam1 table and object (subject_obj) are inserted into the dynamic table
    declare
    subject_obj t_sub_mark;
    begin
    subject_obj:= t_sub_mark();
    EXECUTE IMMEDIATE 'insert into op_sample (select id,name,subject_obj from sam1) ';
    end;
    and got the below error:
    ORA-00904: "SUBJECT_OBJ": invalid identifier
    ORA-06512: at line 7
    then when we tried to insert the data into the dynam_table with the subject_marks object as null,we received the following error..
    execute immediate 'insert into '||dynam_table ||'
    (SELECT

    887684 wrote:
    ORA-00904: "SUBJECT_OBJ": invalid identifier
    ORA-06512: at line 7The problem is that your variable subject_obj is not in scope inside the dynamic SQL you are building. The SQL engine does not know your PL/SQL variable, so it tries to find a column named SUBJECT_OBJ in your SAM1 table.
    If you need to use dynamic SQL for this, then you must bind the variable. Something like this:
    EXECUTE IMMEDIATE 'insert into op_sample (select id,name,:bind_subject_obj from sam1) ' USING subject_obj;Alternatively you might figure out to use static SQL rather than dynamic SQL (if possible for your project.) In static SQL the PL/SQL engine binds the variables for you automatically.

  • Java Stored Procedure in EXECUTE IMMEDIATE

    Hi,
    I need advice for the following.
    I'm on Oracle 11g R2. I'm testing application in Oracle 11gR1 and R2 and Oracle Express.
    Purpose is to generate XML reports.
    I have PLSQL Stored Procedure which does that, but since there is bug in Oracle11gR2 related to XMLTRANSFORM I have and Java Stored Procedure which is workaround. They are both compiled, valid etc.
    Java class is :
    import java.io.PrintWriter;
    import java.io.Writer;
    import oracle.xml.parser.v2.DOMParser;
    import oracle.xml.parser.v2.XMLDocument;
    import oracle.xml.parser.v2.XSLProcessor;
    import oracle.xml.parser.v2.XSLStylesheet;
    * This class is used as Java stored procedure
    * There is a bug on Oracle11gR2, related to the limitation on the number of style sheet instructions
    * This stored procedure is workaround when PLSQL code can not be used.
    * File must not have package, otherwise is wrongly compiled in DB
    public class JavaXslt {
         public static void XMLTtransform(oracle.sql.CLOB xmlInput,oracle.sql.CLOB xslInput,oracle.sql.CLOB output) throws Exception{
              DOMParser parser;
              XMLDocument xml;
              XMLDocument xsldoc;
              try{
                   parser = new DOMParser();
                   parser.parse(xmlInput.getCharacterStream());
                   xml = parser.getDocument();
                   parser.parse(xslInput.getCharacterStream());
                   xsldoc = parser.getDocument();
                   XSLProcessor processor = new XSLProcessor();
                   XSLStylesheet xsl = processor.newXSLStylesheet(xsldoc);
                   Writer w = output.setCharacterStream(1L);
                   PrintWriter pw = new PrintWriter(w);
                   processor.processXSL(xsl, xml, pw);
              }catch (Exception ex){
                   throw ex;
    PROCEDURE Java_XmlTransform (xml CLOB, xslt CLOB, output CLOB) AS LANGUAGE JAVA
    NAME 'JavaXslt.XMLTtransform(oracle.sql.CLOB, oracle.sql.CLOB, oracle.sql.CLOB)';
    I'm calling Java stored procedure from PLSQL Stored procedure (if it is Oracle11gR2) like that :
    Java_Proc.Java_XmlTransform(inputXML, xslt, res);
    So till here everything works ok. XSLT as applied and output XML (res) is OK.
    But when Oracle Express is used Java is out of the question, so there is no Java stored procedure. Howewer PLSQL Stored procedure is still needed.
    So I had to put call to Java Stored procedure in EXECUTE IMMEDIATE statement in order to compile to PLSQL package.
    But when I do that :
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING inputXML, xslt, res;
    result value CLOB (res) has zero length...
    What am I missing? Should i set return value to Java class?
    Hope my explanations are clear though.
    Thanks

    Hi odie_63,
    Thanks for quick response.
    I didn't clearly explained.
    When using Oracle 11gR1 and Oracle Express I'm using only PLSQL Procedure.
    When using Oracle 11gR2 i have to use Java Stored procedure because there is documented bug in R2.
    That's why i have to use EXECUTE IMMEDIATE. I don't know which version is the client DB and whether there is or no Java procedures.
    I did tried
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING IN inputXML, IN xslt, OUT res; and the result was ORA-06537: OUT bind variable bound to an IN position
    When using IN OUT for last parameter i.e.
    EXECUTE IMMEDIATE 'BEGIN Java_Proc.Java_XmlTransform (:1, :2, :3); END;' USING IN inputXML, IN xslt, IN OUT res;
    there is no exception, but still DBMS_LOB.getlength(res) = 0
    Thanks

  • Execute immediate -- udpate statement

    Hello,
    I am fairly new to scripting sql..pl/sql.. any help will be really appreciated!!
    I have a table where i am trying to update one of the column with table name i am passing dynamically.
    However i get the invalid identifier error. ORA-00904. The column AD.MIR_PARENT i am updating is of compatible data type.
    Any help please.. where i am doing a mistake..
    fyi -- the reason i am updating the column with table name is because i need to know which table i make a hit.
    DECLARE
    p_table varchar2(200);
    P_SCHEMA varchar2(200);
    p_acct NUMBER;
    v_acct NUMBER;
    P_column varchar2(200);
    cursoR c is
    select schema_name, table_name, column_name from addnl_sources where TABLE_NAME = 'ACCT';
        BEGIN
            FOR R IN C LOOP
                                    p_TABLE := R.TABLE_NAME;
                                    P_SCHEMA := R.SCHEMA_NAME;
                                    P_column := R.column_name;
                       execute immediate 'UPDATE ACCT_DELETE AD
                SET AD.MIR_PARENT = '||p_table || '
                WHERE EXISTS (select "'||p_table || '" from "' || P_SCHEMA||'"."'||p_table || '" where "' || P_column ||'" = ad.acct_id )
                AND AD.EXCLUDE IS NULL
                AND AD.ACCT_ID = 472039
                AND AD.MIR_PARENT IS NULL' ;
                            END LOOP;
        end;Edited by: 982806 on Jan 18, 2013 10:47 AM
    Edited by: 982806 on Jan 18, 2013 11:04 AM

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION)
    >
    I am fairly new to scripting sql..pl/sql.. any help will be really appreciated!!
    I have a table where i am trying to update one of the column with table name i am passing dynamically.
    However i get the invalid identifier error. ORA-00904. The column AD.MIR_PARENT i am updating is of compatible data type.
    Any help please.. where i am doing a mistake..
    >
    Just about everything you are doing is a mistake.
    1. You using PL/SQL instead of SQL to do this job? That is usually a red flag that something is wrong about what you are trying to do or how you are trying to do it.
    2. You are 'fairly new to scripting' and have chosen to use dynamic sql? That is one of the harder techniques to learn and to use properly and is another red flag. Experienced professionals often don't use dynamic sql properly and often use it when they shouldn't.
    3. You are using a loop to execute against multiple tables? It is extremely difficult to perform proper error handling and recovery when you do this. What if some of the tables get updated and others don't? How will you know which ones still need to be updated? How will you roll back the data if you need to.
    4. You have opened a GIGANTIC opportunity for sql injection where the wrong tables could accidentally be updated. That could corrupt the data and reek havoc on the system. Anyone could, accidentally or intentionally, put the wrong schema, table or column in your lookup table and cause enormous damage.
    5. You are using double quotes in PL/SQL? Where did you learn that?
                WHERE EXISTS (select "'||p_table || '" from "' || P_SCHEMA||'"."'||p_table || '" where "' || P_column ||'" = ad.acct_id ) Finally, it is standard practice when you do have a use case for dynamic sql to construct the query in a variable and then print the query or write it to a log file so it can be tested independently.
    If you do that you will likely see your error.
    query VARCHAR2(4000);
    query := 'UPDATE . . .';
    execute immediate query;SUMMARY: don't try to automate something until you can first do it manually. Write a query that works properly first. Then, and only then, convert it to dynamic sql.

Maybe you are looking for

  • Type of a field in select query

    i have a query like this: SELECT SINGLE (lwa_mat_attr-zattribute)             FROM mara             INTO lv_value            WHERE matnr = <fs>-matnr. can anyone tell me what would be the type of lv_value. because i have got a dump in the type declar

  • Some websites open multiple pages from just one click.while just one of them is the main page,others are spam and contains virus..how do i stop it?

    these multiple pagres being spam sites slow down my pc and net connection probably through some infection.how do i control the opening of specified pages?

  • Text/Email notifications won't clear

    I was having issues with my text/email notifications not clearing on the dock and was told I had to do a factory reset. So i did that and I was still having the problem after i set my phone up again. I found that once I went into the Developer Option

  • How to share a library with two apple id's?

    We have one library on the iMac. And only 1 computer - so home sharing is not the solution. My husband and I each have our own Apple id and iphones. How does he get access to our library as we have only one as he is a new Apple user. Where am I meant

  • Remote mx:Model source not refreshing

    Hi, I'm working on a little project, which involves an <mx:List> object being populated by an <mx:Model>. This Model takes a remote XML file as a source. However, when I update the XML file, the only way to get the List object to take the new data is