Error in Trigger ( PL/SQL: ORA-01744: inappropriate INTO)

Hi ,
I've written the trigger in the following format.. As the original trigger is around 700 lines, so just format is written here.. please co-operate..
CREATE OR REPLACE TRIGGER --
AFTER UPDATE OF COL1
ON TAB1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
WHEN (NOT(OLD.COL1 IS NULL AND NEW.COL1=0))
DECLARE
rowToins PAK1.fdList;
i number;
BEGIN
IF :NEW.COL2='V' THEN
INSERT INTO DEST(
  D_AT)
SELECT * FROM ( SELECT --
   PAK2.FUN1('AD',TAB10.ID) AS D_AT
FROM ---
WHERE --- )
   WHERE D_AT IS NOT NULL;
ELSEIF :NEW.COL2 ='H' THEN
SELECT * FROM ( SELECT --
   PAK2.FUN1('AD',TAB9.ID) AS D_AT
BULK COLLECT INTO rowToins
FROM ---
WHERE --- )
   WHERE D_AT IS NOT NULL;
i:=rowToins.FIRST;
WHILE i IS NOT NULL LOOP
--insert row 1
  PAK1.fun2(rowToins(i).<col>,
i:=rowToins.NEXT(i);
END LOOP;
END IF;
END;
/The above code is giving the error..
PL/SQL: ORA-01744: inappropriate INTOSo how can i correct the code...
thanks

The line no..are
159/3 PL/SQL: SQL Statement ignored
213/16 PL/SQL: ORA-01744: inappropriate INTO
159 --> the first where condition in the example code
213 --> the select list column in the second if condition in example code
If i remove the
select * from (
PAK2.FUN1('AD',TAB9.ID) AS D_AT
WHERE D_AT IS NOT NULL;Then the trigger is created with no issues....
please let me know if i'm not clear
Edited by: josh1612 on Apr 27, 2009 3:42 AM

Similar Messages

  • PL/SQL: ORA-01744: inappropriate INTO

    Hi,
    Iam pasted this code this error coming ...
    any one can help me plz....
    select PI.PEN_NUMBER||''(''||(PEN_CAPACITY-(SELECT nvl(SUM(NO_OF_HEAD_IN_PEN),0) from LOT_PEN WHERE PEN_ID=PI.PEN_ID))||'',''||PEN_CAPACITY||'')'' D, PEN_ID R FROM PEN_ID PI'
    report error:
    ORA-06550: line 1, column 100:
    PL/SQL: ORA-01744: inappropriate INTO
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored

    Yes you can:
    CREATE TABLE PEN_ID ( PEN_NUMBER NUMBER, PEN_CAPACITY NUMBER, PEN_ID NUMBER PRIMARY KEY );
    CREATE TABLE LOT_PEN ( NO_OF_HEAD_IN_PEN NUMBER, PEN_ID NUMBER PRIMARY KEY );
    SELECT pi.pen_number || '(' || (pen_capacity - (SELECT nvl(SUM(no_of_head_in_pen)
                                                              ,0)
                                                      FROM lot_pen
                                                     WHERE pen_id = pi.pen_id))
                      || ',' || pen_capacity || ') ' d
          ,pen_id r
      FROM pen_id pi;
    0 rows selected.However, are you trying to use this in PL/SQL? and getting PLS-00427: an INTO clause is expected in this SELECT statement ?
    I'm confused why you have two single quotes rather than one throughout and a trailing quote at the end, is this dynamic SQL? is there some other context of which you are not making us aware?

  • Error -ora-01744 ( Inappropriate INTO )

    Hi
    Is it possible to select a record and than insert into another table in stored procedure (9i).
    The same query works. But it shows error in procedure ora-01744
    create or replace procedure SELECT_INSERT
    is
    dept_deptid number;
    dept_deptname varchar2(20);
    begin
    INSERT INTO DEPT (SELECT DEPTID,NAME INTO dept_deptid,dept_deptname from department);
    end SELECT_INSERT;
    Thanks

    Remove paranthesis
    INSERT INTO DEPT
    SELECT DEPTID,NAME
    from department;                                                                                                                                                                               

  • ERROR in PROCEDURE  PL/SQL: ORA-00947: not enough values

    Hi all i am creating a Procedure in which i am getting very strange ERROR
    h4. i am using Oralce 11g, SQL Developer 3
    my scenario is :
    CREATE SEQUENCE tt_TMPMEASURESOURCE_ID
    START WITH 1
    INCREMENT BY 1;
    CREATE TABLE tt_TMPMEASURESOURCE
    ID NUMBER(10,0) ,
    OBJNAME VARCHAR2(200) ,
    PRSP NUMBER(10,0) ,
    SOURCEID NUMBER(10,0) ,
    SOURCENAME VARCHAR2(100) ,
    FIX NUMBER(3,0) ,
    MNAME VARCHAR2(1000) ,
    MDESC VARCHAR2(1000)
    CREATE OR REPLACE TRIGGER tt_TMPMEASURESOURCE_ID_TRG
    BEFORE INSERT
    ON tt_TMPMEASURESOURCE
    FOR EACH ROW
    BEGIN
    SELECT tt_TMPMEASURESOURCE_ID.NEXTVAL INTO :NEW.ID
    FROM DUAL;
    END;
    INSERT INTO TT_TMPMEASURESOURCE
    *(OBJNAME,PRSP,SOURCEID,SOURCENAME,FIX,MNAME,MDESC)*
    values ('rajnish',43,54,'anish',4,'apple','kumar');
    output :
    +1 row inserted+
    h4. select * from TT_TMPMEASURESOURCE;
    h3. 1     rajnish     43     54     anish     4     apple     kumar
    creating and compiling Procedure
    create or replace procedure tem_test
    as
    begin
    INSERT INTO tt_TmpMeasureSource
    *(OBJNAME,PRSP,SOURCEID,SOURCENAME,FIX,MNAME,MDESC)*
    VALUES ( v_ObjName, v_PrespectiveID, v_SourceID, v_SourceName, v_FIX, v_MName, v_MDesc );
    when compiling
    Error(63,16): PL/SQL: SQL Statement ignored
    Error(63,28): PL/SQL: ORA-00947: not enough values
    i am do not understand that when Trigger A trigger is allready there for 1st column
    then why its giving me this error?
    please help me out
    thanks

    i got my solutions
    creating and compiling Procedure
    create or replace procedure tem_test
    as
    begin
    INSERT INTO tt_TmpMeasureSource
    *(OBJNAME,PRSP,SOURCEID,SOURCENAME,FIX,MNAME,MDESC)*
    VALUES ( v_ObjName, v_PrespectiveID, v_SourceID, v_SourceName, v_FIX, v_MName, v_MDesc );
    it was a typography mistake
    this line was missing in Original procedure
    *(OBJNAME,PRSP,SOURCEID,SOURCENAME,FIX,MNAME,MDESC)*thanks

  • Error in Trigger (PL/SQL: SQL Statement Ignored)

    Here is the trigger:
    CREATE OR REPLACE TRIGGER DRUGREPLACEMENT
    AFTER INSERT ON PHARMACEUTICALS
    REFERENCING NEW AS newDrugs
    FOR EACH ROW
    WHEN (newDrugs.drugname = newDrugs.genericname)
    BEGIN
    UPDATE prescription
    SET pharmaceuticalid = newDrugs.drugID
    WHERE pharmaceuticalid IN(SELECT pharmaceuticalid FROM prescription, pharmaceuticals WHERE drugid = pharmaceuticalid AND newDrugs.genericname = pharmaceutical.genericname);
    END;
    Error is:
    Error(2,1): PL/SQL: SQL Statement ignored
    Error(3,24): PL/SQL: ORA-00904: "NEWDRUGS"."DRUGID": invalid identifier
    pharmaceuticalid is a number in my prescription table.
    drugid is a number; genericname and drugname are both varchars in my pharmaceuticals table. Any idea why I am getting these errors? (I tried putting quotes around newdrugs.drugid but then it just said "newdrugs.drugid" is invalid. Thanks for your help
    -Brian

    One more thing. Your trigger is selecting from triggering table. So single row inserts will work, but multiple row inserts into PHARMACEUTICALS will fail with famous "table is mutating" error. There is no need to select from PHARMACEUTICALS. Change:
    UPDATE ************
    SET pharmaceuticalid = newDrugs.drugID
    WHERE pharmaceuticalid IN(SELECT pharmaceuticalid FROM ************, pharmaceuticals WHERE drugid = pharmaceuticalid AND newDrugs.genericname = pharmaceutical.genericname);to
    UPDATE ************
      SET pharmaceuticalid = newDrugs.drugID
      WHERE pharmaceuticalid IN (
                                 SELECT pharmaceuticalid
                                   FROM ************
                                   WHERE drugid = :newDrugs.pharmaceuticalid
                                     AND :newDrugs.genericname = pharmaceutical.genericname
                                );SY.

  • Error(20,22): PL/SQL: ORA-00942: table or view does not exist

    I am getting currently getting an error when I try and insert into a table from a different schema from my Stored Procedure:
    Error(20,22): PL/SQL: ORA-00942: table or view does not exist
    I am explicitly calling the table with the schema name infront i.e.
    INSERT INTO SAPSR3.ZTREC_NAME_TYPE
    MASTER_ID,
    NAME_TYPE,
    FAMILY_NAME,
    FIRST_NAME,
    MIDDLE_NAME,
    TITLE
    VALUES
    In_MasterID,
    In_NameType,
    In_FamilyName,
    In_FirstName,
    In_MiddleName,
    In_Title
    I only get this error when I try and compile my stored procedure. If I try this insert not within a stored procedure (i.e. a blank script) it works perfectly.
    Can anyone tell me what Im doing wrong?
    Thanks.

    Hi,
    It sounds like you (the procedure owner) have privileges on that table only through a role.
    Roles don't count in stored procedures created with AUTHID OWNER (which is the default).
    Either
    (1) Have user SAPSR3 grant the necessary privileges directly to you (or to PUBLIC), or
    (2) change the procedure so that it runs with the caller's privileges, by adding AUTHID CURRENT_USER after the argument list but before the keyword IS (os AS) like this:
    CREATE OR REPLACE PROCEDURE     foo
    (     x     IN     NUMBER
    AUTHID CURRENT_USER
    IS ...

  • Database trigger - PL/SQL: ORA-00984: column not allowed here

    I am trying to create a trigger that will update an employee audit table when a row is changed. Using a sequence number to assign a unique identifier to each row as it is created. Need to capture the user ID, date of the change, and the action (update), plus the before image of the row.
    CREATE SEQUENCE emp_audit_seq START WITH 10;               
    Create table emp (
       empno       NUMBER(4)      Primary Key,
       ename       VARCHAR2(10),
       job            VARCHAR2(9),
       mgr           NUMBER(4),
       hiredate     DATE,
       sal             NUMBER(7,2),
       comm        NUMBER(7,2),
       deptno       NUMBER(2));
    CREATE TABLE emp_audit   (
         audit_uid          NUMBER(15)      Primary Key,
         change_date          DATE,
         change_user          VARCHAR2(30),
         action                  CHAR(1),
         empno                  NUMBER(4),
         ename                  VARCHAR2(10),          
         job               VARCHAR2(9),
         mgr               NUMBER(4),
         hiredate          DATE,
         sal               NUMBER(7,2),
         comm                  NUMBER(7,2),
         deptno                  NUMBER(2));
    CREATE OR REPLACE TRIGGER trig_emp_audit
      BEFORE UPDATE ON emp
      FOR EACH ROW
    BEGIN
      INSERT INTO emp_audit
        VALUES(emp_audit_seq.nextval, change_date, change_user, action, :old.empno, :old.ename, :old.job, :old.mgr, :old.hiredate, :old.sal, :old.comm, deptno);
    END;
    Warning: Trigger created with compilation errors.
    SQL> show errors
    Errors for TRIGGER TRIG_EMP_AUDIT:
    LINE/COL ERROR
    2/3      PL/SQL: SQL Statement ignored
    3/149    PL/SQL: ORA-00984: column not allowed hereCan anyone assist in helping me find what I am doing wrong with the trigger?
    Edited by: LostNoob on Aug 25, 2012 2:24 PM

    First, when you write an INSERT statement, it's always good to list the columns that you're inserting into. That makes the code easier to follow-- you don't have to separately pull up the table definition to know what order columns are inserted. And it makes the code more maintainable since the statement won't become invalid if you add a new column to the table in the future.
    Second, CHANGE_DATE, CHANGE_USER, and ACTION are not (presumably) functions and they are not local variables so it doesn't make sense to use them in an INSERT statement. You would need to write code or leverage existing functions to populate those columns. I'm guessing, for example, that you want to use SYSDATE to populate the CHANGE_DATE and USER to populate the CHANGE_USER column. My guess is that ACTION should always be a 'U' for UPDATE.
    Third, it appears that you left off the :old on the DEPTNO column.
    Putting it all together, you'd have something like
    CREATE OR REPLACE TRIGGER trig_emp_audit
      BEFORE UPDATE ON emp
      FOR EACH ROW
    BEGIN
      INSERT INTO emp_audit(
          audit_uid,
          change_date,
          change_user,
          action,
          enpno,
          ename,
          job,
          mgr,
          hiredate,
          sal,
          comm,
          deptno )
        VALUES(
          emp_audit_seq.nextval,
          sysdate,
          user,
          'U',
         :old.empno,
         :old.ename,
         :old.job,
         :old.mgr,
         :old.hiredate,
         :old.sal,
         :old.comm,
         :old.deptno);
    END;
    / Justin

  • PL/SQL: ORA-22806: not an object or REF  when Using Record in Package

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    I have declared a record type in my package
    create or replace
    PACKAGE MYPKG AS
      TYPE MYREC IS RECORD (VAL1 varchar2(20), val2 date);
      PROCEDURE display_error (pSQLERRM number);
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date);
      FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC;
    END MYPKG;
    --In My Package Body
    FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC is
            F_param MYREC;
            BEGIN
            select myvarchar2, mydate into MYREC from MYTable
              where myrefno1 = refno1
              and myrefno2 = refno2
            Exception
              when others then
              display_error(SQLERRM);
              RETURN F_param;
            END F_EPI ;
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date) IS
    insert into atable(myvarchar, mydate)
    select F_EPI(refno1,refno2).val1,F_EPI(refno1,refno2).val2 from tab2;
    END P_LOAD_DATA;
    I get errors
    Error(187,7): PL/SQL: SQL Statement ignored
    Error(225,7): PLS-00382: expression is of wrong type
    Error(225,7): PL/SQL: ORA-22806: not an object or REF
    When I compile the package.
    When I try to call the function from SQL I get an Invalid datatype error.

    Hi,
    Before posting any query/plsql blocks, please ensure that you have written it clean and complete with less syntax errors. ( at least general syntax errors, you can avoid). Then somebody can have an interest to check your logical error.
    About your posting, refer below solution step-by-step. It may help you, about what you are looking for? By the way, you must be knowing, what you are going to to do with. I haven't concentrated about your requirement; as it was not missing in your posting.
    drop table test;
    create table test(myvarchar varchar2(20), mydate date);
    create or replace
        package mypkg as
          type myrec is record (val1 varchar2(20), val2 date);
          --procedure display_error (psqlerrm in number); -- if you are passing sqlerrm, then parameter needs to be string type
       procedure display_error (psqlerrm in varchar2);
          procedure p_load_data (pstartdate in date, penddate in date);
          function  f_epi(refno1 in number,  refno2 in number) return myrec;
       end mypkg;
    Package created.
    --in my package body
    create or replace 
    package body mypkg as -- added
    procedure display_error (psqlerrm in varchar2) -- if you are declared a proc/func in spec, it needs to define in pkg body
    is
    begin
         null; -- you should know, what to do here
      dbms_output.put_line('Err -'||sqlerrm);
    end display_error;
    function  f_epi(refno1 in number,refno2 in number)
    return myrec
    is
    f_param myrec;
    begin
       -- select myvarchar2, mydate into MYREC from mytable
      --  where myrefno1 = refno1
      --  and myrefno2 = refno2;
        select ename, hiredate into f_param from emp -- added demo logic by using emp
        where empno = refno1
         and  mgr  = refno2;
        return f_param;  -- added
    exception
       when others then
         raise; -- if you are using OTHERS then, just raise it
       display_error(sqlerrm);  
       --return f_param; -- what is this?
    end f_epi;
    procedure p_load_data (pstartdate in date, penddate in date) -- you must be knowing the use of 2 params ???
    is
        v_rec myrec; -- added
    begin -- Added
       --insert into atable(myvarchar, mydate)
      -- select f_epi(refno1,refno2).val1,f_epi(refno1,refno2).val1 from tab2;
       -- demo logic added with static params to call f_epi
       v_rec:= f_epi(7499,7698);
       insert into test values v_rec;
        --null; 
    end p_load_data;
    end mypkg;
    Package body created.
    SQL> exec mypkg.p_load_data(null,null);
    PL/SQL procedure successfully completed.
    SQL> select * from test;
    MYVARCHAR            MYDATE
    ALLEN                20-FEB-81
    Thanks!

  • ORA-00933: SQL command not properly ended: error in TRIGGER

    Hi ,
    I tried the following example trigger but unable to trace the error..
    Could you please find it...
    CREATE OR REPLACE TRIGGER trig1
    AFTER INSERT OR UPDATE OR DELETE
    OF RLID,RL
    ON X_RLM_T
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    rlmId X_RLM_T.RLID%TYPE:=CASE WHEN INSERTING OR UPDATING THEN :NEW.RLID WHEN DELETING THEN :OLD.RLID ELSE NULL END;
    rlm RX_RLM_T.RL%TYPE:=CASE WHEN INSERTING OR UPDATING THEN :NEW.RL WHEN DELETING THEN :OLD.RL ELSE NULL END;
    var number:=0;
    var1 number:=0;
    BEGIN
    var:=1;
    var1:=1;
    INSERT ALL
    WHEN var=1 then
    INTO LM_D(CL_ID,D_RLM,RM_NM,RDK_ORG)
    VALUES(dclid,D_RLM,RM_NM,RDK_ORG)
    WHEN var1=1 then
    INTO LM_D(CL_ID,D_RLM,RM_NM,RDK_ORG)
    VALUES(pclid,D_RLM,RM_NM,RDK_ORG)
    SELECT X_RLM_DK_MAP_T.CL_ID AS dclid,
        PM_OR_T_VP.ORG_TECH_ID AS pclid,
        rlmId as D_RLM,
        rlm as RM_NM,
        RX_RLM_DK_MAP_T.ORG_TECH_ID as RDK_ORG
    FROM  RX_RLM_DK_MAP_T , PM_OR_T PMN_ORG_T_VP, PM_OR_T PMN_ORG_T_HP
           PM_RA_MST
    WHERE rlmId = RX_RLM_DK_MAP_T.RL_ID and
    RX_RLM_DK_MAP_T.ORG_TECH_ID=PM_OR_T_HP.ORG_TECH_ID and
    PM_OR_T_HP.ORG_ID=PM_RA_MST.HPMN_ID and     
    PM_RA_MST.VPMN_ID=PM_OR_T_VP.ORG_ID;
    end;error:
    11/2 PL/SQL: SQL Statement ignored
    24/8 PL/SQL: ORA-00933: SQL command not properly ended
    please help me in this...

    i GOT THE ERROR...

  • ORA-00604:error occurred at recursive SQL level string

    Hi all,
    Oracle Version :- 11.2.0.2
                   I found a error in a trigger(Statement Level)
    ORA-00604:error occurred at recursive SQL level string.
    Before Finding this issue,Once the DB Response was slow . Will this be the issue Of DB Slow response. The Above trigger fires for each entry in an transaction table.
    The code is Patched and was executed . The above issue was found during another issue and not the DB Slow response.
    My Doubt is Whether DB response slow issuewould be because of this. Now after fixing this Slow response was not reported.
    Your inputs are highly appreciated.

    it helps if you can post the complete stack of error messages (I'm suspecting you have several more messages than just ORA-00604).
    A cut-n-paste of the SQL*Plus session with the SQL statement and the error message(s) below would give the info as to what the actual problem is.
    Do you have INSERT priv. on that table? Are you doing this from within a stored procedure or at SQL prompt?

  • Issue in Database trigger for HZ_CUSTOMER_PROFILES PL/SQL: ORA-00936: miss

    Hi
    We are trying to create database trigger on update of table HZ_CUSTOMER_PROFILES when CREDIT_HOLD='Y'
    If this update is done from certain operating unit we are inserting into another custom table when compiling trigger we are getting error as given below
    LINE/COL ERROR
    5/2 PL/SQL: SQL Statement ignored
    17/2 PL/SQL: ORA-00936: missing expression
    SQL> l 5
    5*
    SQL> l 17
    17* COUNTRY,
    Copying code used for creating trigger
    CREATE OR REPLACE TRIGGER "APPS"."SDS_CREDIT_HOLD_ROW"
    BEFORE UPDATE ON HZ_CUSTOMER_PROFILES
    FOR EACH ROW
    WHEN ( new.CREDIT_HOLD='Y')
    BEGIN
    IF FND_PROFILE.VALUE('ORG_ID')=3217 THEN
    INSERT INTO SDS.SDS_CREDIT_HOLD
    (CUSTOMER_NAME,
    CUSTOMER_NUMBER,
    ADDRESS,
    CITY,
    COUNTRY,
    HOLD_BY,
    MAIL_LIST1,
    RESP_VALUE,
    ORG_ID,
    MAIL_LIST2)
    VALUES
    (select rc.customer_name,
    rc.customer_number,
    ra.address1,
    ra.city,
    ra.country,
    fu.user_name,
    fu.email_address,
    TO_NUMBER(FND_GLOBAL.RESP_ID),
    TO_NUMBER(fnd_profile.value('ORG_ID')),
    SDS_EMAIL_ADD_FNC('KAMALAKAR.GUDAPAREDDI,BRIAN.MILLER')
    from HZ_CUSTOMER_PROFILES hcp, ra_site_uses rsa,
    ra_addresses ra, ra_customers rc, fnd_user fu,
    (select distinct site_use_id from HZ_CUST_SITE_USES where site_use_code='BILL_TO'
    and status='A') site_acct
    where hcp.status='A'
    and cust_account_id in (select distinct cust_account_id from HZ_CUSTOMER_PROFILES
    where credit_hold='Y'
    and status='A')
    and hcp.site_use_id=rsa.site_use_id (+)
    and rsa.address_id=ra.address_id (+)
    and rsa.site_use_id= site_acct.site_use_id (+)
    and hcp.cust_Account_id=rc.customer_id
    and hcp.credit_hold='Y'
    and hcp.last_updated_by=fu.user_id
    and hcp.CUST_ACCOUNT_PROFILE_ID=:new.CUST_ACCOUNT_PROFILE_ID
    and hcp.ROWID=:new.ROWID);
    END IF;
    -- commit;
    END SDS_CREDIT_HOLD_ROW;
    tried to search for fix in forums checked all columns in select clause and insert they appear to be fine attaching table structure also for reference
    CREATE TABLE SDS_CREDIT_HOLD
    (CUSTOMER_NAME VARCHAR(50),
    CUSTOMER_NUMBER VARCHAR2(30),
    ADDRESS VARCHAR2(240),
    CITY VARCHAR2(60),
    COUNTRY VARCHAR2(60),
    HOLD_BY VARCHAR2(100),
    MAIL_LIST1 VARCHAR2(240),
    RESP_VALUE NUMBER,
    ORG_ID NUMBER,
    MAIL_LIST2 VARCHAR2(240))
    if any hint for fixing this issue it will be highly appreciated
    Thanks
    Kamalakar.G

    Problem is here:
    WHEN ( new.CREDIT_HOLD='Y')
    Should be using a colon in front of any new or old columns in your PL/SQL and SQL, thus try this:
    WHEN ( :new.CREDIT_HOLD='Y')
    FYI: when using triggers (unless you specify otherwise in the trigger definition itself):
    old values are referenced via :old.column and new values via :new.column

  • Error showing in Login as : ORA-00604:error occured at recursive SQL level

    Hi,
    I am facing problem in Login in to user Test:
    I have created a trigger and built in sys environment:
    CREATE OR REPLACE TRIGGER TEST_LOGON
    AFTER LOGON ON TEST.SCHEMA
    DECLARE
    num INTEGER;
    v_grant VARCHAR2(32767);
    l_username VARCHAR2(30) := 'TEST';
    BEGIN
    IF USER=l_username THEN
    num:=0;
    FOR obj IN (SELECT TABLE_NAME FROM DBA_TABLES
    WHERE TABLE_NAME LIKE 'BS_%') LOOP
    v_grant:='GRANT ALL ON '||obj.TABLE_NAME || ' TO ' || USER;
    EXECUTE IMMEDIATE 'GRANT ALL ON' || obj.TABLE_NAME || ' TO ' || USER;
    num := num + 1;
    END LOOP;
    END IF;
    END;
    The trigger got executed in sys environment.
    But when I am Logging to User as Test its showing Error as:
    ORA-00604:error occured at recursive SQL level 1
    ORA-00990:missing or invalid privilege
    ORA-06512:at line 15
    Kindly any help will be needful for me.
    Thanks and Regards

    user598986 wrote:
    Now its giving Error as :
    ORA-00942:Table or view does not existWell, first of all dynamic grants it is not a good idea. Secondly, it is not a good idea to create objects in sys schema. Now about your trigger. Trigger is always created with definer rights, so in your case trigger was created by SYS and will be executed on behalf of SYS. Now, since trigger is created on TEST.SCHEMA it will be called only when user TEST is logging it. So there is no need for:
    l_username VARCHAR2(30) := 'TEST';
    BEGIN
    IF USER=l_username THENNow you think FOR loop selects tables that start with BS_. Keep in mind, _ is a wildcard for LIKE - it indicates any single character, so FOR loop will also select tables that start with BSA, for example. But this is not all. FOR loop selects matchingl tables in whole databse, so tables can belong to any user. At the same time EXECUTE IMMEDIATE does not specify table owner. Therefore, since trigger is owned by SYS and, as I already mentioned, executes on behalf of SYS, table owner in GRANT statement will default to SYS, not to actual table owner. That is why you get ORA-00942.
    Now the "bad" part. Even if you fix it and provide both owner and table name it still will fail with ORA-30511: invalid DDL operation in system triggers. Why? Check ORA-30511 details:
    ORA-30511: invalid DDL operation in system triggers
    Cause: An attempt was made to perform an invalid DDL operation in a system trigger. Most DDL operations currently are not supported in system triggers. The only currently supported DDL operations are table operations and ALTER?COMPILE operations.
    Action: Remove invalid DDL operations in system triggers.SY.

  • ORA-00604/ORA-01422/ORA-06512 Error on trigger

    Hi,
    I have an database which is of version 10.2.0.3.0 on Enterprise Edition.
    I want to restrict a user from usage of an schema . Therefore i have written a trigger but i have encountered with another errors:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 5
    Trigger Being::
    SQL> create or replace trigger session_access
    2 after logon on database
    3 declare
    4 v_username varchar2(30);
    5 v_osuser varchar2(30);
    6 begin
    7 select username,osuser into v_username,v_osuser from v$session;
    8 if v_username = 'SUSANJO' and v_osuser= 'ORACLE' then
    9 raise_application_error (-20001,'Access restricted for this USER');
    10 end if;
    11 end;
    12 /
    Trigger created.
    SQL> show errors;
    No errors.
    SQL> connect susanjo
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 5
    Warning: You are no longer connected to ORACLE.
    i have run out of ideas of whats to be done onto the trigger now.
    Regards.
    Susan John

    Um , i have implemented the following pl/sql. It seem to kick the person out BUT (now this is a big BUT) within the grid control it mentions :
    Details          Failed to connect to database instance: ORA-00604: error occurred at recursive SQL level 1.
    create or replace trigger session_access
    DECLARE
    v_username sys.v_$session.username%type;
    v_osuser sys.v_$session.osuser%type;
    BEGIN
    select s.username ,s.osuser into v_username,v_osuser
    from v$session s where s.username='SUSANJO' and s.osuser='oracle';
    IF (v_username ='SUSANJO' AND V_OSUSER='oracle' )
    THEN
    RAISE_APPLICATION_ERROR(-20001, 'You are not allowed to login using the program');
    END IF;
    END session_access;
    Output :
    SQL*Plus: Release 10.2.0.3.0 - Production on Mon Mar 23 12:36:43 2009
    Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning and Data Mining options
    SQL> connect susanjo
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: You are not allowed to login using the program
    ORA-06512: at line 10
    Warning: You are no longer connected to ORACLE.
    SQL>
    I did conduct a research which was not all that helpful too. So i am back to square one again.
    regards
    Susan John

  • Why an "ORA-01006: bind variable does not exist" error when no dynamic SQL?

    Hi all,
    While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
    Error report:
    ORA-01006: bind variable does not exist
    01006. 00000 - "bind variable does not exist"
    *Cause:   
    *Action:
    After commenting out the new chunk of code that caused the error, the error persisted.
    After deleting the new code, the error went away.
    What the heck!?!? If you have any ideas, please lay 'em on me.
    Thanks so much,
    Kim
    P.S. It's a few hundred lines of code, so I didn't append it to this post and I don't see how to attach a file.

    Let's review a few facts:
    1. You post a question in the sql developer forum that has no apparent relation to sql developer. You could confirm this by doing the test using sql*plus or some other tool.
    2. You provide NO information about what database you are even using. The only clue is an ORA -xxx message that means SOME version of Oracle is involved.
    3. You provide NO information about what the four digit version of Oracle DB is being used.
    4. You provide NO information about what the code in general or what that specific section of the code is even doing. The code could be doing literally anything that Oracle is capable of doing.
    That's a bit like calling a mechanic you don't know, telling them your car is making a funny noise and asking them what the problem with your car is.
    >
    While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
    Error report:
    ORA-01006: bind variable does not exist
    01006. 00000 - "bind variable does not exist"
    *Cause:
    *Action:
    The error gives no indication of where the error occurred in the code.
    >
    Your first clue that your troubleshooting method is seriously flawed is when you make statements that aren't supported by any evidence at all but appear to be nothing but your opinion.
    Your second clue is when those statements appear to directly contradict what Oracle is telling you.
    I'm talking about these two statements you make; which you state as if they were universal truths
    >
    nothing I'm doing has anything to do with dynamic SQL
    (which is what 01006 is supposedly about).
    >
    If thoe were true then your 'unstated' conclusion appears to be that Oracle is wrong in saying 'bind variable does not exist'
    Sorry - but I would place my money on Oracle.
    I'm sure the above may sound harsh - it is intended to be. My four major rules (there are more) when troubleshooting Oracle problems.
    1. Assume that Oracle is CORRECT when it tells you there is a problem.
    2. Assume that you are WRONG if your opinion conflicts with what Oracle is telling you - see rule #1.
    3. Don't make ANY other assumptions. You can form hypotheses but don't state them as facts until they are proven.
    4. Your 'opinion' is only useful to the extent that it can help you form meaningful hypotheses - see rule #3.
    >
    To reiterate, there is no dynamic SQL in the code.
    >
    To reiterate - if, as you state, that error relates to dynamic SQL and bind variables then it can not be disputed that:
    ORACLE DOESN'T AGREE WITH YOU!
    So let's try it my way and hypothesize that Oracle is correct (see rule #1 above).
    Then by definition this statement by Oracle is correct
    >
    ORA-01006: bind variable does not exist
    >
    And that should immediately raise this question:
    1. where might there be a bind variable that does not exist?
    which leads to a prerequisite question:
    2. where are ALL of the bind variables that might be being used?
    Question #2 is where you need to start your search. Here are at least five possibilities (there are more)
    1. your code - this should be easiest to check and you state that your 'anonymous' block does not have any.
    2. a table trigger - triggers that use the :NEW, :OLD or :PARENT pseudocolumns. Those psuedocolumns are BIND variables and the trigger code that uses them is, by definition, dynamic sql.
    3. a pl/sql package/function/procedure - any of these might be being called from trigger code or a view that is involved in the transaction. Any of these could take a parameter and/or use bind variables and cause your problem if that bind variable does 'not exist'.
    4. a functional index - can also trigger code from #3 above
    5. an audit trigger that logs the audit activity that your user or your code is performing. This code could be trying to use a SYS_CONTEXT environment variable that has not been created and cause a 'bind variable does not exist' error.
    See rule #1 - Oracle is CORRECT. Until you have identified and examined ALL of the code (not just your anonymous block) being executed and ruled it out you should continue with the hypotheses that Oracle is CORRECT.
    In the (extremely) unlikely event that you can show that Oracle is NOT correct you should file a SOR with Oracle.

  • PL/SQL: ORA-04052: error occurred when looking up remote object.

    Hi All,
    I'm getting the following error message while executing a PL/SQL Block.
    PL/SQL: ORA-04052: error occurred when looking up remote object UPLDUSER.filestatushistory@FTS
    ORA-00604: error occurred at recursive SQL level 1
    ORA-03106: fatal two-task communication protocol error
    ORA-02063: preceding line from FTSStatement
    declare
    v_coun number;
    begin
    select count(*) into v_coun
    from updluser.filestatushistory@fts;
    end;Back ground of the situation as follows,
    My DataBase version 10.2.0.3 DB Name :DB1
    Table Owner : UPLDUSER
    Table Name : FILESTATUSHISTORY
    I have a report user on the same database and I have grant all on the above table to report user
    Report User : RPT_FTS
    SQL> GRANT ALL ON FILESTATUSHISTORY_V TO RPT_FTS;Now Please find the below database details where I'm getting subjected error.
    Database version : 9.2.0.8
    DB Name : DB2
    User Name : RPT_REPORTS
    I Have create a dblink from RPT_REPORTS to RPT_FTS on DB1 and the dblink works fine. But getting the above error while running it.
    but When I do the same other 10.2.0.3 db , the above PL/SQL block works fine without any problem.
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Now the strange about this is that I have Created a new table on DB1 db like below;
    SQL> CREATE TABLE UPLDUSER.ABC AS SELECT * FROM FILESTATUSHISTORY;and retry my code on DB2 (9.2.0.8) after changing the table to ABC and it worked. Now I don't know whats wrong with a original table(FILESTATUSHISTORY).
    To over come the problem and a work-a-round method I create a view on the DB1 (RPT_FTS) like the below
    SQL> CREATE VIEW FILESTATUSHISTORY AS SELECT * FROM UPLDUSER.FILESTATUSHISTORY;and was able to run the PL/SQL block Remotely.
    Just wants To know what whould have been the cause for this .
    Cheers
    Kanchana

    Hi Kanchana,
    Perhaps following link of google search has answer to your query
    ORA-04052. The search result contains some useful articles whose URLs I shan't post in the forums.
    HTH!
    *009*

Maybe you are looking for

  • Display HTML data on RTF Template - EBS R12

    Hi, I have a requirement where I would like to display the data from a Rich text format to a XML Publisher report Output. The XML Tag is currently showing all the HTML tags in its data. Please can anyone help as too how can I display the HTML data on

  • Locking a pdf Form

    I created an application form with Adobe Acrobat Pro XI.  It has reguired fields that must be completed before submitting to ensure that basic information is completed.  However, I didn't lock it (protect it) to keep someone from changing the content

  • Is CS6 Production Premium dual license?

    Hi everyone, I was wondering if when I bought CS6 would I be able to install it on 2 computers? I have CS5.5 Production Premium Student/Teacher Edition and it allows me to use it on 2x machines but I have been told by someone at CVP in the UK that it

  • Metanet -  own MetaStar doesn't accept Attributs of Dimension

    Hi, I'm creating a form displaying Personal Infotype Datas instead of Payroll Datas. For displaying Datas of Infotype 13 Social Insurance Germany (01) I created a new MetaStar ZSOCIAL_INS_DE Containing the Dimension SI_KEY_DE. As I am reading Infotyp

  • Mac Air 13 running Windows 7 not properly recognizing external monitor

    My Macbook Air 13 running Windows 7 Pro through Bootcamp is no longer properly recognizing an external Apple 27 inch monitor since the latest package of windows updates. When plugged in, the external display duplicates that of the laptop (both being