PLS-00357

Hai
I created sequence
create sequence emp_seq startwith 800 increment by 1 maxvalues 1000;
and emp table is empty.I want to set module information into v$session by dbms_application_info package.According to that i created procedure sucessufully ,i got the below error when executing the procedure
SQL> CREATE OR REPLACE PROCEDURE ADD_EMPLOYEE(NAME VARCHAR2,SALARY NUMBER,MANAGER NUMBER,TITLE VARCH
AR2,COMMISSION NUMBER,DEPARTMENT NUMBER) AS
2 BEGIN
3 DBMS_APPLICATION_INFO.SET_MODULE(MODULE_NAME=> 'ADD_EMPLOYEE', ACTION_NAME=>'INSERT INTO EMP');
4 INSERT INTO EMP(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) VALUES(EMP_SEQ.NEXTVAL,NAME,TITLE
,MANAGER,SYSDATE,SALARY,COMMISSION,DEPARTMENT);
5 DBMS_APPLICATION_INFO.SET_MODULE('' , '');
6 END
7
8 ;
9 /
Procedure created.
EXEC ADD_EMPLOYEE (EMP_SEQ.NEXTVAL,'MOHAN1', 'SYSTEM',7902,TO_DATE('17-DEC-1980','DD-MON-YYYY')
, 800,NULL, 20);
BEGIN ADD_EMPLOYEE (EMP_SEQ.NEXTVAL,'MOHAN1', 'SYSTEM',7902,TO_DATE('17-DEC-1980','DD-MON-YYYY'), 80
ERROR at line 1:
ORA-06550: line 1, column 29:
PLS-00357: Table,View Or Sequence reference 'EMP_SEQ.NEXTVAL' not allowed in
this context
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

The input parameters that are listed in the procedure and the input parameters that you pass to the procedure when you execute it have to be in the same order. Also, you should not try to pass emp_seq.NEXTVAL or SYSDATE to the procedure. In the following, I changed the order of the input parameters to match the order of the parameters you were passing to it. I also removed the emp_seq.NEXTVAL and the date from the list of parameters passed to the procedure upon execution.
CREATE SEQUENCE emp_seq
START WITH      800
INCREMENT BY    1
MAXVALUE        1000
Sequence created.
CREATE OR REPLACE PROCEDURE add_employee
  (name       VARCHAR2,
   title      VARCHAR2,
   manager    NUMBER,
   salary     NUMBER,
   commission NUMBER,
   department NUMBER)
AS
BEGIN
  DBMS_APPLICATION_INFO.SET_MODULE
    (MODULE_NAME => 'ADD_EMPLOYEE',
     ACTION_NAME => 'INSERT INTO EMP');
  INSERT INTO EMP
     (empno,
      ename,
      job,
      mgr,
      hiredate,
      sal,
      comm,
      deptno)    
  VALUES
    (emp_seq.NEXTVAL,
     name,
     title,
     manager,
     SYSDATE,
     salary,
     commission,
     department);
  DBMS_APPLICATION_INFO.SET_MODULE ('' , '');
END add_employee;
Procedure created.
SHOW ERRORS
No errors.
EXECUTE add_employee ('MOHAN1', 'SYSTEM', 7902, 800, NULL, 20)
PL/SQL procedure successfully completed.

Similar Messages

  • Pass table name as parameter PLS-00357

    create or replace
    PROCEDURE universal_p (
    tab IN VARCHAR2,
    col IN VARCHAR2,
    whr IN VARCHAR2 := NULL)
    IS
    TYPE cv_type IS REF CURSOR;
    cv cv_type;
    val VARCHAR2(32767);
    BEGIN
    OPEN cv FOR
    'SELECT ' || col ||
    ' FROM ' || tab ||
    ' WHERE ' || NVL (whr, '1 = 1');
    LOOP
    FETCH cv INTO val;
    EXIT WHEN cv%NOTFOUND;
    IF cv%ROWCOUNT = 1
    THEN
    DBMS_OUTPUT.PUT_LINE (RPAD ('-', 60, '-'));
    DBMS_OUTPUT.PUT_LINE (
    'Contents of ' ||
    UPPER (tab) || '.' || UPPER (col));
    DBMS_OUTPUT.PUT_LINE (RPAD ('-', 60, '-'));
    END IF;
    DBMS_OUTPUT.PUT_LINE (val);
    END LOOP;
    CLOSE cv;
    END;
    WHEN I CALL THIS PROCEDURE I got error messasge
    ORA-06550: Table,View Or Sequence reference not allowed in this context.
    PLS-00357:
    Can anyone can help me, please ?
    WHEN
    Edited by: user6446424 on 11.3.2010 13:59

    Works for me:
    SQL> create or replace
      2  PROCEDURE universal_p (
      3  tab IN VARCHAR2,
      4  col IN VARCHAR2,
      5  whr IN VARCHAR2 := NULL)
      6  IS
      7  TYPE cv_type IS REF CURSOR;
      8  cv cv_type;
      9  val VARCHAR2(32767);
    10  BEGIN
    11  OPEN cv FOR
    12  'SELECT ' || col ||
    13  ' FROM ' || tab ||
    14  ' WHERE ' || NVL (whr, '1 = 1');
    15
    16  LOOP
    17  FETCH cv INTO val;
    18  EXIT WHEN cv%NOTFOUND;
    19  IF cv%ROWCOUNT = 1
    20  THEN
    21  DBMS_OUTPUT.PUT_LINE (RPAD ('-', 60, '-'));
    22  DBMS_OUTPUT.PUT_LINE (
    23  'Contents of ' ||
    24  UPPER (tab) || '.' || UPPER (col));
    25  DBMS_OUTPUT.PUT_LINE (RPAD ('-', 60, '-'));
    26  END IF;
    27  DBMS_OUTPUT.PUT_LINE (val);
    28  END LOOP;
    29
    30
    31  CLOSE cv;
    32  END;
    33
    34  /
    Procedure created.
    SQL> exec universal_p('EMP','ENAME')
    Contents of EMP.ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    SQL> select * from v$version
      2  ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - ProductionMax
    http://oracleitalia.wordpress.com

  • PLS-00357: Table,View Or Sequence reference 'A' not allowed in this context

    Hello
    I am accepting input values from users through java web page. To accept the values I am using the following code:
    import java.sql.*;
    import javax.sql.DataSource;
    import javax.naming.*;
    public class spsrch
         public void spsrch()
         public String espsrch(String p, String d, String a)
              String s1= "";
              String strColor="#C0C0C0";
              try
                   InitialContext ctx = new InitialContext();
                   DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Oracle9i");
                   Connection Con = ds.getConnection();
                   Statement stmt = Con.createStatement();
                   CallableStatement proc1stmt1=Con.prepareCall ("{call Allsch("+p+","+d+")}");
    //               ResultSet rs = proc1stmt1.execute();
                   proc1stmt1.executeUpdate();
                   Con.close();
              catch(Exception e)
                   System.out.println("Flag Raised"+e);
              return s1;
    I am calling the procedure 'Allsch' to apply some logic before inserting data into a SQL table.
    The 'Allsch' procedure is :
    create or replace procedure tmpsch(pno varchar2,pdes varchar2) as
    mpartnum varchar2(30);
    mpn varchar2(30);
    mdes varchar2(150);
    cursor c1 is select partnum,description,aircraft_type from master_catalog where description like ltrim(rtrim(mdes))||'%' AND partnum like mpn||'%';
    cursor c2 is select partnum from ipc_master where partnum=mpartnum;
    cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
    cursor c4 is select partnum from superparts where partnum=mpartnum;
    cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
    mpno1 varchar2(30);
    mpno2 varchar2(30);
    mpno3 varchar2(30);
    mpno4 varchar2(30);
    mpno5 varchar2(30);
    mdescription varchar2(150);
    maircraft_type varchar2(15);
    mstat varchar2(1);
    mstat1 varchar2(30);
    mstat2 varchar2(30);
    mstat3 varchar2(30);
    mstat4 varchar2(30);
    begin
    mstat:='N';
    mpn:=pno;
    mdes:=pdes;
    for i in c1 loop
    mstat:='N';
    mstat1:='N';
    mstat2:='N';
    mstat3:='N';
    mstat4:='N';
    mpno1:=i.partnum;
    mpartnum:=i.partnum;
    mdescription:=i.description;
    maircraft_type:=i.aircraft_type;
    for j in c2 loop
    mpno2:=j.partnum;
    end loop;
    for k in c3 loop
    mpno3:=k.partnum;
    end loop;
    for l in c4 loop
    mpno4:=l.partnum;
    end loop;
    for m in c5 loop
    mpno5:=m.part_no;
    end loop;
    if mpno2=mpartnum then
    mstat1:=mpno2;
    end if;
    if mpno3=mpartnum then
    mstat2:=mpno3;
    end if;
    if mpno4=mpartnum then
    mstat3:=mpno4;
    end if;
    if mpno5=mpartnum then
    mstat4:=mpno5;
    end if;
    if mpno1=mpartnum then
    mstat:='Y';
    insert into tmpcat values(mpno1,mdescription,maircraft_type,mstat1,mstat2,mstat3,mstat4);
    end if;
    end loop;
    end;
    Java program compiling time, it not showing any error. But after executing, it is not inserting any data into 'tmpcat' table and throwing the following error :
    Flag Raisedjava.sql.SQLException: ORA-06550: line 1, column 14:
    PLS-00357: Table,View Or Sequence reference 'A' not allowed in this context
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    [07/22/03 11:47:38][executor-0][W]: Handling error; throwable is "null", status
    code is "404" and message is "Not Found: /User/Ecatalog/Validations.js".
    [07/22/03 11:47:38][executor-0][W]: Handling error; throwable is "null", status
    code is "404" and message is "Not Found: /User/Ecatalog/Validations.js".
    Any one please help me to solve the issue.
    With thanks
    Pramod kumar.
    My Email-id is : [email protected]

    What are p and d in
    "{call Allsch("+p+","+d+")}"
    Something tells me you might need some quotes in this statement since they are varchar2. Maybe
    "{call Allsch('"+p+"','"+d+"')}"
    If this doesn't work try to cut off parts of the procedure until it works.
    Mike

  • PLS-00357 error

    I have created MView under report_owner schema and like to refresh the MView via scheduler job and the MView won't get refreshed.i am getting this errors.
    ORA-12012: error on auto execute of job 135426
    ORA-06550: line 1, column 402:
    PLS-00357: Table,View Or Sequence reference 'REPORT_OWNER.M_REP_01'
    SQL> l
    1 BEGIN
    2 sys.dbms_scheduler.create_job(
    3 job_name => '"SYSTEM"."REFRESH_MVIEWS"',
    4 job_type => 'PLSQL_BLOCK',
    5 job_action => 'BEGIN
    dbms_mview.refresh(list=>"REPORT_OWNER"."M_REP_01");END;',
    6 job_class => 'AUTO_TASKS_JOB_CLASS',
    7 start_date => SYSTIMESTAMP,
    8 repeat_interval => 'FREQ=MINUTELY',
    9 end_date => NULL,
    10 enabled => TRUE,
    11 comments => 'To refresh REPORT_OWNER schema MViews');
    12* END;
    SQL> /
    PL/SQL procedure successfully completed.
    So what is the problem ??

    Hi,
    may be that
    dbms_mview.refresh(list=>"REPORT_OWNER"."M_REP_01");END;',should be
    dbms_mview.refresh(list=>''REPORT_OWNER.M_REP_01'');END;',so the problem is just for the wrong usage of quotes?
    Max

  • Re: PLS-00357 Table,View Or Sequence reference 'string' not allowed in this con

    i have the same problem , can somebod help
    i pasting my code here , please help me resolving
    SQL> declare
      2  continue char(1):='y';
      3   begin
      4  while(continue='y')
      5  loop
      6  dbms_output.put_line('somen');
      7  dbms_output.put_line('do u wan continue');
      8  continue:=to_char(&continue);
      9  end loop;
    10  end;
    11  /
    Enter value for continue: y
    old   8: continue:=to_char(&continue);
    new   8: continue:=to_char(y);
    continue:=to_char(y);
    ERROR at line 8:
    ORA-06550: line 8, column 19:
    PLS-00357: Table,View Or Sequence reference 'Y' not allowed in this context
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignored

    Just to emphasise Sven's point that the substitution variable (&continue) is resolved once and "compiled" into the code, try making a stored procedure instead of an anonymous block.
    SQL> create procedure p as
      2     continue char(1):='y';
      3  begin
      4     while(continue='y') loop
      5        dbms_output.put_line('somen');
      6        dbms_output.put_line('do u wan continue');
      7        continue:=('&continue');
      8     end loop;
      9  end;
    10  /
    Enter value for continue: q
    old   7:       continue:=('&continue');
    new   7:       continue:=('q');
    Procedure created.
    SQL> select text from user_source
      2  where name = 'P'
      3  order by line;
    TEXT
    procedure p as
       continue char(1):='y';
    begin
       while(continue='y') loop
          dbms_output.put_line('somen');
          dbms_output.put_line('do u wan continue');
          continue:=('q');
       end loop;
    end;
    Note that where you had the substitution variable, there is now a literal value, q in my case.  Note that because I did not respond with y for the value of continue I can safely run this procedure.
    SQL> exec p;
    somen
    do u wan continue
    PL/SQL procedure successfully completed.
    John

  • PLS-00049: bad bind variable 'NEW.ID' on trigger

    Hi guys, I am using Oracle SQL Developer version 2.1.1.64 and having the sql statement like below
    CREATE TABLE Zipcodes
         zipcode_id NUMBER(10),
         zipcode VARCHAR2(10),
         district_id NUMBER(10),
         PRIMARY KEY(zipcode_id)
    CREATE SEQUENCE ZIPCODE_ID_SEQ START WITH 1 INCREMENT BY 1;
    CREATE OR REPLACE TRIGGER ZIPCODE_TRIGGER
    BEFORE INSERT
    ON ZIPCODES
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
         SELECT ZIPCODE_ID_SEQ.NEXTVAL INTO :NEW.ZIPCODE_ID FROM DUAL;
    END;
    And I got errors:
    Error(2,40): PLS-00049: bad bind variable 'NEW.ID'
    Error(4,5): PL/SQL: Statement ignored
    Error(4,39): PLS-00357: Table,View Or Sequence reference 'ZIPCODE_ID_SEQ.NEXTVAL' not allowed in this context
    Error(2,36): PLS-00049: bad bind variable 'NEW.ID'
    Error(2,2): PL/SQL: SQL Statement ignored
    Error(2,9): PL/SQL: ORA-02289: sequence does not exist
    Error(5,1): PLS-00103: Encountered the symbol "SHOW"
    Firstly, I dont even have the "SHOW" key world in my syntax.
    What is it happening ?
    Thank you in advance.

    Hi,
    954390 wrote:
    Hi guys, I am using Oracle SQL Developer version 2.1.1.64 Thanks; that could be useful information. Even more important is your database version (e.g. 11.2.0.2.0)
    and having the sql statement like below
    CREATE TABLE Zipcodes
         zipcode_id NUMBER(10),
         zipcode VARCHAR2(10),
         district_id NUMBER(10),
         PRIMARY KEY(zipcode_id)
    )Don't you need a semicolin or a slash after the CREATE TABLE statement?
    CREATE SEQUENCE ZIPCODE_ID_SEQ START WITH 1 INCREMENT BY 1;Did you get a message like "Sequence created" at this point?
    CREATE OR REPLACE TRIGGER ZIPCODE_TRIGGER
    BEFORE INSERT
    ON ZIPCODES
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
         SELECT ZIPCODE_ID_SEQ.NEXTVAL INTO :NEW.ZIPCODE_ID FROM DUAL;
    END;
    And I got errors:
    Error(2,40): PLS-00049: bad bind variable 'NEW.ID'
    Error(4,5): PL/SQL: Statement ignored
    Error(4,39): PLS-00357: Table,View Or Sequence reference 'ZIPCODE_ID_SEQ.NEXTVAL' not allowed in this context
    Error(2,36): PLS-00049: bad bind variable 'NEW.ID'
    Error(2,2): PL/SQL: SQL Statement ignored
    Error(2,9): PL/SQL: ORA-02289: sequence does not exist
    Error(5,1): PLS-00103: Encountered the symbol "SHOW"
    Firstly, I dont even have the "SHOW" key world in my syntax.
    What is it happening ?You don't have anything like NEW.ID, either.
    Also, the line numbers in error messages for triggers start with the first DECLARE or BEGIN statement, so this trigger only has 3 lines, yet you're getting line numbers up to 5 in the error messages.
    That trigger works fine for me in SQL*Plus (database 10.2.0.1.0).
    Are you sure you're showing the complete script, exactly what you're running? If you had some syntax error before the CREATE OR REPLACE TRIGGER statement, that might possibly account for the parser getting confused.
    Does your code work in SQL*Plus?

  • Use multiple day event in Calendar region

    I am using a Calendar region in my application. One issue i have run into is, some of my events are multiple-day events, such as a conference. The calendar application does not seem to be able to deal with multiple-day events. It takes one date as the date. There doesn't seem to be any way of dealing with multiple day events. In my case, I have 2 date fields in my table associated with my calendar - a starting date, and an ending date.
    Has anyone found a way to deal with this situation? I don't want to have a separate entry for each date of the event. I'd like to be able to use my start date, and ending date fields.
    Thanks,
    John

    Scott,
    I took the SQL you used in your trigger and substituted my table names and fields. I am getting 3 errors. Here is what my code looks like after the substitutions (my table names are 'meetings_tbl' and 'meetings_tbl_cal'):
    CREATE OR REPLACE TRIGGER ai_meetings
    AFTER UPDATE OR INSERT ON meetings_tbl
    FOR EACH ROW
    DECLARE
    l_date_diff NUMBER;
    BEGIN
    IF UPDATING THEN
    DELETE FROM meetings_tbl_cal WHERE m_id = meetings_tbl.m_id;
    END IF;
    l_date_diff := meetings_tbl.meeting_end - meetings_tbl.meeting_start;
    FOR x IN 0..l_date_diff
    LOOP
    INSERT INTO meetings_tbl_cal
    (m_id, meeting_date)
    VALUES
    (meetings_tbl.m_id, TO_DATE(meetings_tbl.meeting_start + x));
    END LOOP;
    END;
    I am getting 3 errors:
    1) PL/SQL: ORA-00904: "MEETINGS_TBL"."M_ID": invalid identifier
    2) PLS-00357: Table,View Or Sequence reference 'MEETINGS_TBL.MEETING_END' not allowed in this context
    3) PL/SQL: ORA-00984: column not allowed here
    Maybe I'm not supposed to substitute ':NEW' with 'MEETINGS_TBL' ??
    Thanks for your help!
    John

  • Populating nextval into a variable

    Hi,
    I'm bulding a custom form with a dynamic page portlet.
    i would like to generate an hidden id field from a sequance i created in the database.
    How do i do that, when i try :
    theId NUMBER := iloug.iloug_tmp_seq.nextval;
    i get an error that says:
    ORA-06550: line 1, column 46:
    PLS-00357: Table,View Or Sequence reference 'ILOUG.ILOUG_TMP_SEQ.NEXTVAL' not allowed in this context
    Thx
    Esther
    null

    thx Egor, works great.
    Esther
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Egor Bologov ([email protected]):
    Try
    select iloug.iloug_tmp_seq.nextval into theId from dual;<HR></BLOCKQUOTE>
    null

  • Using a sequence inside BEFORE TRIGGER

    Hi all,
    I just created a testtable and a sequence to use as a primary key column value for that table.
    I tried to create a BEFORE INSERT trigger on that table and in the trigger i tried to set up the primary key column value using the sequence
    but while compiling i am getting the error "Error(9,30): PLS-00357: Table,View Or Sequence reference 'SEQ_OF_TESTTABLE.NEXTVAL' not allowed in this context"
    My Version:Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    All the objects created with the same user. I would appraciate any help, thanks all
    EDIT
    I solved the problem using the below
    create or replace
    TRIGGER Bef_Ins_On_Testtable
    BEFORE INSERT ON TestTable
    FOR EACH ROW
    declare
    ntemp_id INT;
    BEGIN
    SELECT SEQ_OF_TESTTABLE.NEXTVAL INTO ntemp_id FROM DUAL ;
    DBMS_OUTPUT.PUT_LINE('İNSERTED');
    :NEW.VSURNAME := 'HAKKİ' ;
    :NEW.NID := ntemp_id;
    END;But i wonder why i can use the sequence(just as seqeunce_name.NEXTVAL) in INSERT statement and why cant in trigger?
    Edited by: user9371286 on 31.Tem.2010 04:15
    Edited by: user9371286 on 31.Tem.2010 04:21
    Edited by: user9371286 on 31.Tem.2010 04:27

    Please post your trigger code and your database version ( the result of: select * from v$version; ).
    Put it between tags, so your example will stay formatted.
    (see: http://forums.oracle.com/forums/help.jspa for more examples regarding tags)
    "PLS-00357: Table,View Or Sequence reference "string" not allowed in this context
        Cause: A reference to database table, view, or sequence was found in an inappropriate context. Such references can appear only in SQL statements or (excluding sequences) in %TYPE and %ROWTYPE declarations. Some valid examples follow: SELECT ename, emp.deptno, dname INTO my_ename, my_deptno, my_dept .FROM emp, dept WHERE emp.deptno = dept.deptno; DECLARE last_name emp.ename%TYPE; dept_rec dept%ROWTYPE;
        Action: Remove or relocate the illegal reference."
    +http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/plsus.htm#sthref13592+
    You can find examples of triggers referring to sequences here, by doing a search on this forum or:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#ABC1032282                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Calling a stored procedure with argument as column name

    hi
    i am calling a stored procedure mapping_audit_errors_inserts
    whose definition is as follows
    PROCEDURE mapping_audit_errors_inserts (
    in_ma_seq_id IN ETL_MAPPING_AUDIT_ERRORS.ma_seq_id%TYPE,
    in_etl_stage IN ETL_MAPPING_AUDIT_ERRORS.etl_stage%TYPE,
    in_sqlerrcode IN ETL_MAPPING_AUDIT_ERRORS.sqlerrcode%TYPE
    IS
    BEGIN
    mapping_audit_ora_errors (in_ma_seq_id,
    in_etl_stage,
    in_sqlerrcode,
    get_error_message (in_sqlerrcode)
    END;
    now i need to call this procedure as
    mapping_audit_errors_inserts(MA_SEQ_ID.currval,1,v_error_code)
    [ v_error_code:=SQLCODE;]
    it is giving error as
    PLS-00201: identifier 'MA_SEQ_ID.CURRVAL' must be declared
    can anyone calrify me on this.
    Thanks

    Anwar is likely correct about the reason for your error. The other possibility is that the owner of the procedure calling mapping_audit_errors_inserts does not have SELECT on the sequence granted directly to them.
    However, even after creating the sequence, if the session calling the procedure has not got a value from the sequence prior to trying to use CURRVAL, you will get:
    SQL> CREATE PROCEDURE p(p_id IN NUMBER) AS
      2  BEGIN
      3     DBMS_OUTPUT.Put_Line('ID is '||p_id);
      4  END;
      5  /
    Procedure created.
    SQL> DECLARE
      2     l_no NUMBER;
      3  BEGIN
      4     SELECT ma_seq_id.CURRVAL INTO l_no
      5     FROM dual;
      6     p(l_no);
      7  END;
      8  /
    DECLARE
    ERROR at line 1:
    ORA-08002: sequence MA_SEQ_ID.CURRVAL is not yet defined in this session
    ORA-06512: at line 4And, just to reinforce Anwar's point about selecting it into a variable, if you try to pass CURRVAL to a procedure, you will get:
    SQL> DECLARE
      2     l_no NUMBER;
      3  BEGIN
      4     SELECT ma_seq_id.NEXTVAL INTO l_no
      5     FROM dual;
      6     p(ma_seq_id.CURRVAL);
      7  END;
      8  /
       p(ma_seq_id.CURRVAL);
    ERROR at line 6:
    ORA-06550: line 6, column 16:
    PLS-00357: Table,View Or Sequence reference 'MA_SEQ_ID.CURRVAL' not allowed in
    this context
    ORA-06550: line 6, column 4:
    PL/SQL: Statement ignoredTTFN
    John

  • Using sequence in insert trigger?

    Hi all,
    I'm new to this forum, and for that matter, any forums related to computers.
    I would appreciate it if anyone would give me some hinters.
    I created a table with an ID column of type "Number." And I want to populate that column with a sequence number everytime I insert into that table.
    I have a sequence named "sequence1_account."
    Below is my insert trigger code:
    create TRIGGER system.trigger1_account
    BEFORE INSERT ON system.table_account
    for each row
    BEGIN
    :new.id := sequence1_account.NextVal;
    END;
    Note:
    user is "system"
    table is "table_account"
    The error that I get when I try to compile this is
    PLS-00357: Table,View Or Sequence reference 'SEQUENCE1_ACCOUNT.NEXTVAL' not allowed in this context
    So, does that mean I cannot use a sequence in a trigger?
    Thanks in advance!
    in His love,
    HS

    Hello,
    Hoping for some help with sequence triggers as well.
    CREATE TRIGGER "SCALS"."TRIGGER_CALL_NUM"
    BEFORE INSERT ON "CALLLOG" FOR EACH ROW
    BEGIN
    select num_callers.NextVal into : new.callernumber from dual;
    END;
    Problem is that the trigger status is invalid ??
    The error I get is in German (German installation)
    Zeilen-# = 0 Spalten-# = 0 Fehlertext = PLS-00801: internal error [ph2csql_strdef_to_diana:bind]
    Zeilen-# = 2 Spalten-# = 57 Fehlertext = PL/SQL: ORA-06544: PL/SQL: internal error, arguments: [ph2csql_strdef_to_diana:bind], [], [], [], [], [], [], []
    Zeilen-# = 2 Spalten-# = 1 Fehlertext = PL/SQL: SQL Statement ignored
    But perhaps something looks familiar???

  • Use of sequence in trigger

    I need to ensure that a unique key value is stored in a column. Values must be persistent across DB restores. A Sequence is fine to initially populate the column, but I must also ensure a key is applied to records inserted later (by third-party code unaware of the key column).
    If I try to plant a trigger to set the column value to sequence.nextval, compilation error occurs: "PLS-00357: ... Sequence reference ... not allowed in this context."
    Are special tactics needed to allow use of sequences in triggers? Can you suggest another approach to enforce key maintenance?

    Log in as scott/tiger and do the following:
    CREATE SEQUENCE deptno
    START WITH 50
    INCREMENT BY 10;
    CREATE OR REPLACE FUNCTION next_dept
    RETURN NUMBER AS
    v_new_dept dept.deptno%TYPE;
    BEGIN
    SELECT deptno.NEXTVAL
    INTO v_new_dept
    FROM DUAL;
    RETURN v_new_dept;
    END;
    CREATE OR REPLACE TRIGGER new_dept
    BEFORE INSERT ON dept
    FOR EACH ROW
    BEGIN
    :NEW.deptno := next_dept();
    -- this will fail when next_dept
    -- returns 100 because deptno is
    -- only 2 digits.
    END;
    INSERT INTO dept
    -- you must provide a dummy deptno
    -- to satisfy the PK constraint
    VALUES(0, 'SURFING', 'MAUI');
    null

  • CURRVAL and NEXTVAL in PL/SQL - is it only in 11g

    DECLARE
    seq_value NUMBER;
    BEGIN
    seq_value := employees_seq.NEXTVAL;
    END;
    is it works only on 11g.
    I have xe 10g and it doesn't work. Error:
    PLS-00357: Table,View Or Sequence reference 'EMPLOYEES_SEQ.NEXTVAL' not allowed in this context

    Hello,
    this is a new feature in 11g, not specific for XE.
    In 10 g you can achieve the same result as follows
    DECLARE
      seq_value NUMBER;
    BEGIN
      SELECT employees_seq.NEXTVAL
        INTO seq_value
        FROM dual;
    END;-Udo

  • How to generate unique values while initializing values

    I am initializing values in my pl/sql program and want to use a sequence to set my unique ids but it errors out. Below is what I use.
    ie. table_id := table_seq.nextval;
    How can I use my sequence to initialize values or is this possible?

    The method suggested by user605919 will work. However, you don't need to initialize a variable like this. It is better and more performant to do it like the third example below:
    SQL> create table mytable
      2  ( id number(6)
      3  , description varchar2(30)
      4  )
      5  /
    Tabel is aangemaakt.
    SQL> create sequence table_seq start with 1 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> declare
      2    table_id mytable.id%type := table_seq.nextval;
      3  begin
      4    insert into mytable
      5    ( id
      6    , description
      7    )
      8    values
      9    ( table_id
    10    , 'Some description'
    11    );
    12  end;
    13  /
      table_id mytable.id%type := table_seq.nextval;
    FOUT in regel 2:
    .ORA-06550: line 2, column 41:
    PLS-00357: Table,View Or Sequence reference 'TABLE_SEQ.NEXTVAL' not allowed in this context
    ORA-06550: line 2, column 12:
    PL/SQL: Item ignored
    ORA-06550: line 9, column 5:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 9, column 5:
    PL/SQL: ORA-00904: "TABLE_ID": invalid identifier
    ORA-06550: line 4, column 3:
    PL/SQL: SQL Statement ignored
    SQL> declare
      2    table_id mytable.id%type;
      3  begin
      4    select table_seq.nextval
      5      into table_id
      6      from dual
      7    ;
      8    insert into mytable
      9    ( id
    10    , description
    11    )
    12    values
    13    ( table_id
    14    , 'Some description'
    15    );
    16  end;
    17  /
    PL/SQL-procedure is geslaagd.
    SQL> begin
      2    insert into mytable
      3    ( id
      4    , description
      5    )
      6    values
      7    ( table_seq.nextval
      8    , 'Some description'
      9    );
    10  end;
    11  /
    PL/SQL-procedure is geslaagd.And if you need the id value for some code after the insert, you use the RETURNING clause.
    Regards,
    Rob.

  • Updating a Materialized View.

    Hi,
    I'm using Oracle 9.2.0.6.
    We have a materialized view with this definition.
    SET DEFINE OFF;
    DROP SYNONYM APPSRO.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D;
    DROP SYNONYM APPS.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D;
    DROP MATERIALIZED VIEW FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D;
    CREATE MATERIALIZED VIEW FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D
    TABLESPACE APPS_TS_SUMMARY
    NOCACHE
    NOLOGGING
    NOPARALLEL
    BUILD DEFERRED
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY
    AS
    SELECT
                             a.*
    FROM
                             apps.ftbv_qt_esr_to_1st_esc_dtl_v a;
    COMMENT ON TABLE FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D IS 'snapshot table for snapshot FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D';
    GRANT ALTER, DELETE, INDEX, INSERT, REFERENCES, SELECT, UPDATE, ON COMMIT REFRESH, QUERY REWRITE, DEBUG, FLASHBACK ON  FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D TO APPS WITH GRANT OPTION;
    GRANT SELECT ON  FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D TO APPSRO;
    GRANT SELECT ON  FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D TO FTBV_REPORTING;
    CREATE SYNONYM APPSRO.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D FOR FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D;
    CREATE SYNONYM APPS.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D FOR FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D;We've updated the view that it's reading by adding a column 'CUSTOMER_NAME'. It looks like this.
    CREATE OR REPLACE VIEW FTBV_QT_ESR_TO_1ST_ESC_DTL_V
    (RESPONSE_TEAM, RESPONSE_COMMENTS, SALES_MGR, SALES_REP, DEAL_ID,
    REQUEST_SUBMIT_DATE, RESPONSE_1ST_SUBMIT_DATE, ELAPSED_HRS, RESPONSE_1ST_SUBMIT_YYYY_MM, CUSTOMER_NAME)
    AS
    SELECT
              resp_1.team                                       AS response_team
            , resp_2.response_comments                          AS response_comments
            , user_r.sales_mgr_last                             AS sales_mgr
            , SUBSTR  ( deal.sales_rep_user_id, 2 )             AS sales_rep
            , TO_CHAR ( req.deal_id,'999999'      )             AS deal_id
            , req.submit_date                                   AS request_submit_date
            , resp_1.min_submit_date                            AS response_1st_submit_date
            , ROUND
                ( ftbv_om_ord_util.get_datetime_interval_char ( req.submit_date,resp_1.min_submit_date, 'dd', 'Y') * 24 ) +
                ( ftbv_om_ord_util.get_datetime_interval_char ( req.submit_date,resp_1.min_submit_date, 'hh', 'Y')      ) +
                ( ftbv_om_ord_util.get_datetime_interval_char ( req.submit_date,resp_1.min_submit_date, 'mi', 'Y') / 60 )
              , 2
              )                                                 AS elapsed_hrs
            , TO_CHAR ( resp_1.min_submit_date, 'YYYY-MM' )     AS response_1st_submit_yyyy_mm
            , cust.customer_name                                as customer_name
    FROM      (
              SELECT    /*+ no_merge */
                        deal_id                                           AS deal_id
                      , team                                              AS team
                      , MIN ( submit_date )                               AS min_submit_date
              FROM
                        op_esc_prod
              GROUP BY
                        deal_id
                      , team
                                                                   resp_1
              SELECT    deal_id                                           AS deal_id
                      , version_number                                    AS version_number
                      , team                                              AS team
                      , submit_date                                       AS submit_date
                      , CASE WHEN UPPER ( comments ) LIKE '%HI%TOUCH%'
                             THEN'High Touch'
                             WHEN UPPER ( comments ) LIKE 'HT%'
                             THEN'High Touch'
                             WHEN UPPER ( comments ) LIKE '%LO%TOUCH%'
                             THEN'Low Touch'
                             WHEN UPPER ( comments ) LIKE 'LT%'
                             THEN'Low Touch'
                             ELSE NULL
                        END                                               AS response_comments
              FROM
                        op_esc_prod
              )                                                    resp_2
              op_esr                                               req
              op_deal                                              deal
              op_customers                                         cust
              SELECT     user_id                                          AS user_id
                       , SUBSTR ( relation_id, 2 )                        AS sales_mgr_last
              FROM       op_user_relationship
              WHERE      relation                                          = 'SLSMGR'
                                                                   user_r
    WHERE
              resp_2.deal_id                                     = resp_1.deal_id         AND
              resp_2.team                                        = resp_1.team            AND
              resp_2.submit_date                                 = resp_1.min_submit_date
    AND       req.deal_id                                        = resp_2.deal_id         AND
              req.version_number                                 = resp_2.version_number
    AND       deal.deal_id                                       = req.deal_id
    AND       user_r.user_id                                     = deal.sales_rep_user_id
    AND       cust.op_customer_id                                = deal.op_customer_id
    GROUP BY
              resp_1.team
            , resp_2.response_comments
            , user_r.sales_mgr_last
            , SUBSTR  ( deal.sales_rep_user_id, 2 )
            , TO_CHAR ( req.deal_id,'999999'      )
            , req.submit_date
            , resp_1.min_submit_date
            , TO_CHAR ( resp_1.min_submit_date, 'YYYY-MM' )
            , cust.customer_nameWhen we run the refresh we get the following error messages.
    BEGIN dbms_snapshot.refresh('FTBV.FTBV_QT_ESR_TO_1ST_ESC_DTL_1D','C'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00913: too many values
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 841
    ORA-06512: at line 1I don't believe we're creating table for this MView I think we're just defining an MView and then populating it. For some reason it's not picking up the new column. Is there a reason why? What do I need to do?
    Thanks

    When you create an MV, Oracle automatically does create an underlying table with the same name. That is how it is a "materialized" view -- physical storage of the result set from the query defining the MV.
    When you created this particular MV "FTBV_QT_ESR_TO_1ST_ESC_DTL_1D" ,
    the "SELECT A.* FROM apps.ftbv_qt_esr_to_1st_esc_dtl_v a;"
    was automatically translated to the specific columns in ftbv_qt_esr_to_1st_esc_dtl_v.
    An table called FTBV_QT_ESR_TO_1ST_ESC_DTL_1D was actually created to store the results of the query. Therefore, it has the actual column names as well.
    In fact, even if you created a View, the view gets created with the actual column names.
    See :
    SQL> create table a_1_t (col_1 number not null primary key, col_2 varchar2(5));
    Table created.
    SQL> insert into a_1_t values (1,'a');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create view a_1_v as select * from a_1_t;
    View created.
    SQL> desc a_1_v
    Name                                                                     Null?    Type
    COL_1                                                                    NOT NULL NUMBER
    COL_2                                                                             VARCHAR2(5)
    SQL> create materialized view a_1_mv as select * from a_1_t;
    Materialized view created.
    SQL> desc a_1_mv
    Name                                                                     Null?    Type
    COL_1                                                                    NOT NULL NUMBER
    COL_2                                                                             VARCHAR2(5)
    SQL> select * from a_1_mv;
         COL_1 COL_2
             1 a
    SQL> alter table a_1_t add (col_3 varchar2(10));
    Table altered.
    SQL> select * from a_1_v;
         COL_1 COL_2
             1 a
    SQL> select * from a_1_mv;
         COL_1 COL_2
             1 a
    SQL> exec dbms_mview.refresh(a_1_mv);
    BEGIN dbms_mview.refresh(a_1_mv); END;
    ERROR at line 1:
    ORA-06550: line 1, column 26:
    PLS-00357: Table,View Or Sequence reference 'A_1_MV' not allowed in this context
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    SQL> select col_1, col_2, col_3 from a_1_t;
         COL_1 COL_2 COL_3
             1 a
    SQL> select col_1, col_2, col_3 from a_1_v;
    select col_1, col_2, col_3 from a_1_v
    ERROR at line 1:
    ORA-00904: "COL_3": invalid identifier
    SQL>I can still do a SELECT * from both the view A_1_V and the materialized view a_1_mv.
    But I cannot see the 3rd column in either of them. (Note : This means that the view also wouldn't show the new column !!).
    I cannot refresh the MV because there is physical storage of the columns.
    Hemant K Chitale
    http://hemantoracledba.blogspot.com

Maybe you are looking for

  • Appraisal in Training and event management

    Hallo Experts, In the ESS portal during appraisal of a certain BE, the Appraisal form does not appear. The Name of the Appraisal model appear on the portal but NOT the form itself where the user input data. (the criteria groups and criterions.) I am

  • Suppresing Delivery note prints for certain sales order types/item category

    Hi I need to find a way of suppressing some delivery notes from being printed. Relating to orders for consignment fill up and consignment issue. The delivery notes are needed to be printed for 'Consignment fill up order' type, BUT not for Consignment

  • How to determine the order of plugin menu entries displayed in Automate menu?

    I found in Plug-in Resource Guide.pdf: int16 PIPriorityProperty 0x70727479L ('prty') Plug-in load order. Also used to control the order in which items with the same name show up in menus. Lower numbers (including negative ones) load first. If NULL, t

  • Data base

    Hi all : Issue is data base  Please attach see file , copy this file to desktop ,, then run create table  vi ,,, as you see its will save the data in access . Please see  I took the this example from national instrument example directory C:\Program F

  • Error: custom.pll

    Hi all when we are trying to open some forms we are getting an error :custom.pll cannot find the current instace, whats actual problem?where can we find the this program to edit it to add new instance. thanks Praneeth