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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Sequence inside a Trigger ??

    Is it possible to use a sequence inside trigger's definition ?
    I don't understand why when i give a static value to my RowId in a trigger's definition it works, but when get a value from a sequence, the trigger become invalid.
    Please Help.

    Somewhat off the spatial topic but what the heck! This is easy :
    SQL> create table t
    2 (person_id number,
    3 person_name varchar2(32));
    Table created.
    SQL> create sequence person_id_seq start with 1 increment by 1;
    Sequence created.
    SQL> create trigger person_id_trig
    2 before insert
    3 on t
    4 for each row
    5 begin
    6 select person_id_seq.nextval
    7 into :new.person_id
    8 from dual;
    9 end;
    10 /
    Trigger created.
    SQL> insert into t (person_name) values ('Steve');
    1 row created.
    halls@GENDEV> select * from t;
    PERSON_ID PERSON_NAME
    1 Steve
    SQL> insert into t (person_name) values ('Rod');
    1 row created.
    halls@GENDEV> select * from t;
    PERSON_ID PERSON_NAME
    1 Steve
    2 Rod
    SQL>
    Steve

  • Problem using a sequence in a trigger

    I am creating a table, sequence and trigger as below. When I insert into the table I get the error message
    'ORA-04098: trigger 'SIMS2.BEF_INS_MATERIAL_COST' is invalid and failed re-validation'
    I am using TOAD rather than SQL Plus to do all this. Any idea what is causing the problem?
    create table material_costs
    material_id NUMBER(8) not null,
    material_desc VARCHAR2(50),
    material_rate NUMBER(8,2)
    tablespace sims2data;
    create index material_costs_1
    ON material_costs (material_id)
    tablespace sims2index;
    create sequence material_costs_seq
    increment by 1
    start with 1
    nomaxvalue
    nocycle
    noorder
    cache 100;
    create or replace trigger bef_ins_material_cost
    before insert
    on material_costs
    for each row
    begin
    if inserting then
    select material_costs_seq.nextval into new.material_id
    from dual;
    end if;
    end;

    Some older versions of Oracle do not allow the direct assignment of a sequence to the column, so you could try
    CREATE OR REPLACE TRIGGER bef_ins_material_cost
    BEFORE INSERT ON material_costs
    FOR EACH ROW
    DECLARE
    l_seqval NUMBER;
    BEGIN
       SELECT material_costs_seq.nextval INTO l_seqval
       FROM dual;
       :NEW.material_id := l_seqval;
    END; The TOAD editor does not require the :new syntax because new.material_id is, at least potentially, a valid construct, and can only be resolved at compile time by Oracle. Oracle will certainly complain about new.material_id not being declared.
    HTH
    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

  • Before Trigger in Discoverer 10.1.2

    Hi,
    Can any one help me how to build before trigger report in Discoverer. there is a function which internally calling a procedure which has parameters like process_id,organization_name,Gre,start_date,end_date. This process_id will be generated based on a sequence. So, how to pass value for the process_id parameter from Desktop Edition.
    example:-
    function a(process_id ,start_date,end_date..etc)
    procedure(process_id ,start_date,end_date..etc)
    insert into temp_table values(process_id,start_date,end_date,etc);
    end function a;
    In Desktop we created a workbook worksheet we called this function in calculation tab.It has to insert some rows into temp_table and we will create second sheet on this temp_table.
    The problem we are facing is we are not able to pass sequence.nextvalue as default value for a parameter. Please suggest.
    Thanks inadvance,
    Ch.Hanuman Prasad

    Hi,
    There is no before report trigger. You may be able to use a logon trigger.
    It sounds as though you may want to investigate using database contexts as session parameters which can be set by a workbook or at logon and remain for the duration of the DIscoverer session. Look at these posts for more details:
    Re: Passing multiple parameters into Custom Folder...
    Re: Parameters in SubQuery
    Re: Passing Parameters to a discoverer folder using Note 282249.1
    Rod West

  • Is there a way to enforce the use of sequences

    is there a way to stop someone from inserting an id without using the sequence?
    CREATE SEQUENCE id_seq
       START WITH 1;
    CREATE TABLE test_table (id_seq NUMBER (4) PRIMARY KEY);
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);
    INSERT INTO test_table
         VALUES (2);
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);gives us
    ORA-00001: unique constraint (DSAMSTRC.SYS_C0091648) violated
    as it should
    however is there a check constraint of some ilk that ensures that the user is using the sequence when doing inserts?
    so that the second insert
    INSERT INTO test_table
         VALUES (2);gives me some sort of check constraint violation that I'm not using the id_seq.NEXTVAL ?

    Justin:
    One minor problem with your trigger. If the "bad" insert is the first thing done in the session you get:
    SQL> insert into test_table values(25);
    insert into test_table values(25)
    ERROR at line 1:
    ORA-08002: sequence ID_SEQ.CURRVAL is not yet defined in this session
    ORA-06512: at "OPS$ORACLE.TRG_TEST_TABLE", line 4
    ORA-04088: error during execution of trigger 'OPS$ORACLE.TRG_TEST_TABLE'If you want to raise an exception instead of just silently using the sequence as Frank suggests you need something more like:
    create trigger trg_test_table
       before insert on test_table
       for each row
    declare
       l_currval integer;
       no_currval exception;
       PRAGMA EXCEPTION_INIT (no_currval, -8002);
    begin
       select id_seq.currval
       into l_currval
       from dual;
       if( l_currval != :new.id_seq ) then
          raise_application_error( -20001, 'Hey!  Use the sequence' );
       end if;
    exception
       when no_currval then
          raise_application_error( -20001, 'Hey!  Use the sequence' );
    end;John

  • Using oracle sequence in SQL Loader

    I'm using oracle sequence in control file of sql loader to load data from .csv file.
    Controlfile:
    LOAD DATA APPEND
    INTO TABLE PHONE_LIST
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    PHONE_LIST_ID "seqId.NEXTVAL",
    COUNTRY_CODE CHAR,
    CITY_CODE CHAR,
    BEGIN_RANGE CHAR,
    END_RANGE CHAR ,
    BLOCKED_FREE_FLAG CHAR
    Datafile:
    1516,8,9,9,B
    1517,1,1,2,B
    1518,8,9,9,B
    1519,8,9,9,B
    1520,8,9,9,B
    1521,8,9,9,B
    1) As first column uses oracle sequence, we have not defined that in datafile.
    This gives me error "Can not insert NULL value for last column"
    Is it mandatory to specify first column in datafile, even though we are using sequence?
    2) Another table is referencing PHONE_LIST_ID column (the one for which we using sequence) of this table as a foreign key.
    So is it possible to insert this column values in other table simultaneously? Sequence no. should be same as it is in first table...
    Kindly reply this on urgent basis....

    use BEFORE INSERT trigger
    with
    select your_seq.nextval into :new.id from dual;

  • Auditing inside a Trigger

    Inside my trigger I want to write for auditing purposes certain values that get updated. However I am unable to commit within my trigger. Is there some way to write certain values to another table when my trigger is fired?

    Yes you can do insert, update and delete operation on other tables inside a trigger. But COMMIT is not allowed inside a trigger.
    Because a trigger is considered as a part of a transaction. So the action of a trigger should not get commit unless the invoking statement is committed.
    But even then you can define a trigger as a [AUTONOMOUS_TRANSACTION.|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm#LNPLS01302] Which lets you to commit. But you must be very careful before using it. Know the effects of using it before doing so.

  • I need to pass null as a default value for a parameter in Before Trigger

    Hi All,
    I am using Before trigger function in calculation tab which has some set of parameters.So, I accept some parameters which are passed to this Before Trigger function and need these parameters default value as null.
    To be clear I want to set the Default value for a parameter in workbook to be NULL and pass the same to the calling Function.
    please help me.
    Thanks in advance

    Hi All,
    I am using Before trigger function in calculation tab which has some set of parameters.So, I accept some parameters which are passed to this Before Trigger function and need these parameters default value as null.
    To be clear I want to set the Default value for a parameter in workbook to be NULL and pass the same to the calling Function.
    please help me.
    Thanks in advance

  • FIREFOX IS FREEZING MY BACKGROUND GIF IMAGES WHEN THEY USED TO RUN SMOOTHLY BEFORE.

    WE CREATE WEBSITES USING THE WEEBLY CREATOR, AND ALL OF OUR BACKGROUND IMAGING WORKS FLAWLESSLY IN CHROME.
    BUT WE DESIGN ALL OF OUR WEBSITES USING THE FIREFOX BROWSER, AND CERTAIN BACKGROUNDS ARE FREEZING WHEN THEY NEVER USED TO DO SO BEFORE.
    1. WE DELETED FOXFIRE AND UPDATED IT AGAIN
    2. WE DISABLED ALL OF OUR PLUGINS AND THAT DIDN'T WORK.
    3 WE WENT TO THE CONFIF: SETTINGS AND MADE SURE BOTH VIDEO AND GRAPH SETTINGS WHERE SET TO TRUE AND WE ARE STILL HAVING A HUGE PROBLEM WITH FREEZING BAD.
    4. WE DISABLED HARDWARE ACCELERATOR WITH STILL NO LUCK
    "application": {
    "name": "Firefox",
    "version": "37.0.1",
    "buildID": "20150402191859",
    "userAgent": "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0",
    "updateChannel": "release",
    "supportURL": "https://support.mozilla.org/1/firefox/37.0.1/WINNT/en-US/",
    "numTotalWindows": 2,
    "numRemoteWindows": 0
    "crashes": {
    "submitted": [],
    "pending": 1
    "modifiedPreferences": {
    "browser.cache.disk.smart_size.first_run": false,
    "browser.cache.disk.capacity": 358400,
    "browser.cache.frecency_experiment": 2,
    "browser.places.smartBookmarksVersion": 7,
    "browser.sessionstore.upgradeBackup.latestBuildID": "20150402191859",
    "browser.startup.homepage_override.mstone": "37.0.1",
    "browser.startup.homepage_override.buildID": "20150402191859",
    "dom.mozApps.used": true,
    "extensions.lastAppVersion": "37.0.1",
    "gfx.direct3d.last_used_feature_level_idx": 0,
    "media.gmp-gmpopenh264.lastUpdate": 1428406839,
    "media.gmp-gmpopenh264.version": "1.3",
    "media.gmp-gmpopenh264.enabled": true,
    "media.gmp-manager.lastCheck": 1428406839,
    "network.cookie.prefsMigrated": true,
    "places.history.expiration.transient_current_max_pages": 104472,
    "plugin.state.np_wtapp": 1,
    "plugin.state.npadobeaamdetect": 2,
    "plugin.importedState": true,
    "plugin.state.np32dsw": 2,
    "plugin.disable_full_page_plugin_for_types": "application/pdf",
    "plugin.state.nppdf": 2,
    "plugin.state.npwlpg": 2,
    "plugin.state.npintelwebapiipt": 2,
    "plugin.state.npspwrap": 2,
    "plugin.state.npappdetector": 2,
    "plugin.state.npintelwebapiupdater": 2,
    "plugin.state.npgoogleupdate": 2,
    "plugin.state.nphpdetect": 2,
    "plugins.load_appdir_plugins": true,
    "privacy.sanitize.migrateFx3Prefs": true
    "lockedPreferences": {},
    "graphics": {
    "numTotalWindows": 2,
    "numAcceleratedWindows": 2,
    "windowLayerManagerType": "Direct3D 11",
    "windowLayerManagerRemote": true,
    "adapterDescription": "Intel(R) HD Graphics 4000",
    "adapterVendorID": "0x8086",
    "adapterDeviceID": "0x0166",
    "adapterSubsysID": "1854103c",
    "adapterRAM": "Unknown",
    "adapterDrivers": "igdumdim64 igd10iumd64 igd10iumd64 igdumdim32 igd10iumd32 igd10iumd32",
    "driverVersion": "10.18.10.3304",
    "driverDate": "9-9-2013",
    "adapterDescription2": "",
    "adapterVendorID2": "",
    "adapterDeviceID2": "",
    "adapterSubsysID2": "",
    "adapterRAM2": "",
    "adapterDrivers2": "",
    "driverVersion2": "",
    "driverDate2": "",
    "isGPU2Active": false,
    "direct2DEnabled": true,
    "directWriteEnabled": true,
    "directWriteVersion": "6.3.9600.17415",
    "webglRenderer": "Google Inc. -- ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)",
    "info": {
    "AzureCanvasBackend": "direct2d 1.1",
    "AzureSkiaAccelerated": 0,
    "AzureFallbackCanvasBackend": "cairo",
    "AzureContentBackend": "direct2d 1.1"
    "javaScript": {
    "incrementalGCEnabled": true
    "accessibility": {
    "isActive": false,
    "forceDisabled": 0
    "libraryVersions": {
    "NSPR": {
    "minVersion": "4.10.8",
    "version": "4.10.8"
    "NSS": {
    "minVersion": "3.17.4 Basic ECC",
    "version": "3.17.4 Basic ECC"
    "NSSUTIL": {
    "minVersion": "3.17.4",
    "version": "3.17.4"
    "NSSSSL": {
    "minVersion": "3.17.4 Basic ECC",
    "version": "3.17.4 Basic ECC"
    "NSSSMIME": {
    "minVersion": "3.17.4 Basic ECC",
    "version": "3.17.4 Basic ECC"
    "userJS": {
    "exists": false
    "extensions": [
    "name": "Adobe Acrobat - Create PDF",
    "version": "2.0",
    "isActive": false,
    "id": "[email protected]"
    "name": "Norton Toolbar",
    "version": "2015.2.1.3",
    "isActive": false,
    "id": "{2D3F3651-74B9-4795-BDEC-6DA2F431CB62}"
    "experiments": []
    WE WOULD LIKE OT CONTINUE TO USE FIREFOX FOR OUR WEBSITE CREATION BUT IF THESE FREEZES DON'T STOP WE WILL BE FORCED TO CHANGE OVER TO CHROME FOR ALL OUR CLIENTS. HERE IS THE WEBSITE AND THE BACKGROUND IMAGES WHICH ARE FREEZING.
    http://www.allianceoftheholytrinity.com/
    1. http://www.allianceoftheholytrinity.com/10014-audio--video-messages-of-faith-10014.html
    2. http://www.allianceoftheholytrinity.com/10014-virtual-3d-tours-10014.html
    3. http://www.allianceoftheholytrinity.com/10014-inside-the-vatican-10014.html
    PLEASE HELP.....

    ''mrbunnylamakins [[#answer-714804|said]]''
    <blockquote>
    Try this...... your gif animation may be off
    Toggle animated GIFs :: Add-ons for Firefox
    [https://addons.mozilla.org/en-us/firefox/addon/toggle-animated-gifs/]
    or
    1) in a new tab type in the URL '''about:config'''
    2) click the button saying '''I'll Be Careful'''
    3) type into the search bar at top '''image.animation_mode'''
    4) It should read '''Normal''' under mode
    The Firefox preference image.animation_mode determines how the browser handles animated gifs. It has three values that it accepts:
    * none - will prevent all animation and display a static image instead.
    * once - will run through the animation once and then stop.
    * normal (default) - will allow it to play repeatedly.
    The new value takes effect right away, which you can test on any page that is displaying animated gifs. If a page is already open, you need to reload it before the change becomes available.
    </blockquote>
    ''mrbunnylamakins [[#answer-714804|said]]''
    <blockquote>
    Try this...... your gif animation may be off
    Toggle animated GIFs :: Add-ons for Firefox
    [https://addons.mozilla.org/en-us/firefox/addon/toggle-animated-gifs/]
    or
    1) in a new tab type in the URL '''about:config'''
    2) click the button saying '''I'll Be Careful'''
    3) type into the search bar at top '''image.animation_mode'''
    4) It should read '''Normal''' under mode
    The Firefox preference image.animation_mode determines how the browser handles animated gifs. It has three values that it accepts:
    * none - will prevent all animation and display a static image instead.
    * once - will run through the animation once and then stop.
    * normal (default) - will allow it to play repeatedly.
    The new value takes effect right away, which you can test on any page that is displaying animated gifs. If a page is already open, you need to reload it before the change becomes available.
    </blockquote>

  • How to use HTML tags inside JSF pages

    I am creating a Menu using dataTable and outputLink in a JSF page.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
    <h:column>
    <li>
    <h:outputLink id="crumbID" value="#{bread.menuLink}">
    <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
    </h:outputLink>
    <li>
    </h:column>
    </h:dataTable>
    </ol>
    </div>
    </div>
    I want to use <li> HTML tag as shown in code above before and after every <tr> tag formed, but when i run it and see view source, this is how it shows:
    NOTE: you can see it has thrown out of <table> tag itself.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <li>
    </li>
    <table>
    <tbody>
    <tr>
    <td><a id="_id0:0:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=-1"><span id="_id0:0:crumpName" style="width: 165px;">Home</span></a></td>
    </tr>
    <tr>
    <td><a id="_id0:1:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=3~-1"><span id="_id0:1:crumpName" style="width: 165px;">HIM Admin</span></a></td>
    </tr>
    </tbody>
    </table>
    </ol>
    </div>
    </div>
    Can some one help me, how do i use HTML tags inside <h:dataTable>.
    Or is their any other way i should form my Menus, to fully utilize to HTML tags.
    Thanks
    Ravi

    Hello,
    You can embed the verbatim elements in your datatable, ie,
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
      <h:column>
        <f:verbatim><li></f:verbatim>
        <h:outputLink id="crumbID" value="#{bread.menuLink}">
          <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
        </h:outputLink>
        <f:verbatim></li></f:verbatim>
      </h:column>
    </h:dataTable>

  • How to insert into a table using a procedure in a trigger

    I have following trigger and based on the some condition, it should inser a row in to a table using the procedure:
    CREATE OR REPLACE TRIGGER RSSC.RR_SERV_ADD_ON_REQ_bu before update on RSSC.RR_SERV_ADD_ON_REQ
    for each row
    DECLARE
    lr_appr_trans_hdr APPR_TRANS_HDR%ROWTYPE;
    -- Inserting a row into APPR_TRANS_HDR table
              lr_appr_trans_hdr.apth_ref_system := 'RSAO';
              lr_appr_trans_hdr.apth_xref_col_name := 'RSAO_ADD_ON_REQ_NUM';
              lr_appr_trans_hdr.apth_xref_id := :NEW.RSAO_ADD_ON_REQ_NUM;
              lr_appr_trans_hdr.apth_trans_srce := 'I';
              lr_appr_trans_hdr.apth_balance_amt := :NEW.RSAO_TOT_AMT;
              lr_appr_trans_hdr.apth_is_finance_adj := 'N';
              SPI_APPR_TRANS_HDR (
              lr_appr_trans_hdr.apth_id
              ,lr_appr_trans_hdr.apth_create_dt
                   ,lr_appr_trans_hdr.apth_create_user_id
                   ,lr_appr_trans_hdr.apth_update_dt
                   ,lr_appr_trans_hdr.apth_update_user_id
              ,lr_appr_trans_hdr.apth_ref_system
                   ,lr_appr_trans_hdr.apth_xref_col_name
                   ,lr_appr_trans_hdr.apth_xref_id
                   ,lr_appr_trans_hdr.apth_trans_srce
                   ,lr_appr_trans_hdr.apth_udc_name_cd
                   ,lr_appr_trans_hdr.apth_udc_acct_num
                   ,lr_appr_trans_hdr.apth_level1_apprvl_stat
                   ,lr_appr_trans_hdr.apth_level1_apprvl_dt
                   ,lr_appr_trans_hdr.apth_level1_apprvr_id
                   ,lr_appr_trans_hdr.apth_level2_apprvl_stat
                   ,lr_appr_trans_hdr.apth_level2_apprvl_dt
                   ,lr_appr_trans_hdr.apth_level2_apprvr_id
                   ,lr_appr_trans_hdr.apth_received_dt
                   ,lr_appr_trans_hdr.apth_balance_amt
                   ,lr_appr_trans_hdr.apth_cust_name
                   ,lr_appr_trans_hdr.apth_sent_dt
                   ,lr_appr_trans_hdr.apth_wbs_element
                   ,lr_appr_trans_hdr.apth_gl_acct_num
                   ,lr_appr_trans_hdr.apth_is_finance_adj );
    When I use the above, it is saying wrong number of argument or type.
    When I use the following instead, I am getting :NEW.APTH_ID must be declared.
    SPI_APPR_TRANS_HDR('APPR_TRANS_HDR',to_char(:NEW.APTH_ID),'APTH_ID',:OLD.APTH_ID,:NEW.APTH_ID);
    How can use the procedure in a trigger.
    Following is the table structure:
    Column Name     Data Type     Column Comments
    APTH_ID     NUMBER(16) Computed unique identified per large table standards (yyyymmddnnnnnnnn)
    APTH_CREATE_DT     DATE     sysdate
    APTH_CREATE_USER_ID VARCHAR2(65)     ‘conv’
    APTH_UPDATE_DT     DATE     sysdate
    APTH_UPDATE_USER_ID     VARCHAR2(65)     ‘conv’
    APTH_REF_SYSTEM     VARCHAR2(4)     ‘RSAO’
    CPA_PREM_NUM     NUMBER(13,0)     NULL
    RSR_REQ_NUM     NUMBER(16)     NULL
    RSAO_ADD_ON_REQ_NUM     NUMBER(16)     rsao_add_on_req_num
    APTH_TRANS_SRCE     VARCHAR2(2)     ‘I’
    APTH_LDC_NAME_CD     VARCHAR2(4)     NULL
    APTH_LDC_ACCT_NUM     VARCHAR2(25)     NULL
    APTH_LEVEL1_APPROVAL_STAT     VARCHAR2(1)     NULL
    APTH_LEVEL1_APPROVAL_DT     DATE     NULL.
    APTH_LEVEL1_APPROVAL_ID     VARCHAR2(30)     NULL
    APTH_LEVEL2_APPROVAL_STAT     VARCHAR2(1)     NULL
    APTH_LEVEL2_APPROVAL_DT     DATE     NULL.
    APTH_LEVEL2_APPROVAL_ID     VARCHAR2(30)     NULL
    APTH_RECEIVED_DT     DATE     NULL
    APTH_BALANCE_AMT     NUMBER(11,2) RR_SERV_ADD_ON_REQ.rsao_tot_amt – amount previously extracted to sap
    APTH_CUST_NAME     VARCHAR2(65)     NULL
    APTH_SENT_DT     DATE     NULL
    APTH_WBS_ELEMENT     VARCHAR2(25)     NULL
    APTH_GL_ACCT_NUM     VARCHAR2(15) NULL
    APTH_IS_FINANC_ADJ     VARCHAR2(1)     ‘N’
    Edited by: user652807 on Sep 3, 2008 4:51 PM

    It appears you're missing the format mask in the TO_CHAR, ...
    TO_CHAR(:new.apth,'YYYYMMHR24MISS')
    The full code would help a bit more.

  • What is the exact use of Sequence container

    Hi all,
       I am intermediate in SSIS package,i am not understanding what is the exact use of Sequence container ?
      I am preparing for interview(3 years exp), if experts dont mind can you pls share some tips and questions to clear the interview ?
     pls
    thanks

    Hi SelvakumarSubramaniam,
    This blog delivers a good summary of the benefits we can get by using Sequence Container:
    Easier debugging by allowing you to disable groups of tasks to focus package debugging on one subset of the package control flow.
    Managing multiple tasks in one location by setting properties on a Sequence Container instead of setting properties on the individual tasks.
    Provides scope for variables that a group of related tasks and containers use.
    Create a transaction around all the components inside the container.
    Here are some other good resources:
    http://www.phpring.com/sequence-container-in-ssis/ 
    http://sql-developers.blogspot.com/2010/06/sequence-container-in-ssis.html 
    Regards,
    Mike Yin
    TechNet Community Support

  • Common use of Sequence in Package

    Hi,
    I need to get the NEXTVAL from a sequence and i have to pass that to many packages inside of a package.
    If i write SELECT seq.nexval into v_varil from dual; means the value wont change sequentially.
    How can i get the NEXTVAL sequentialy and declare the SELECT stmt commonly.
    Can anyone help me in this.
    Thanks
    Radha K

    Could not understand your question, please be more specific,
    Anyway I have tried to answer it with 2 different assumptions with a common understanding that you don't want to code "SELECT seq.nexval into v_varil from dual;" every time you want to use the sequence instead want to have one common declaration for it so that you can reuse.
    Assumption1.
    You want same value of the sequence to be available in the package for a single oracle session.
    Create a function say get_seq_value return number in the package spec and define it in the body as follows
    then call this package in the initialization section of the package as follows
    CREATE OR REPLACE PACKAGE BODY abc_pkg
    g_seq IS NUMBER;
    FUNCTION get_seq_value return number
    IS
    v_varil IS NUMBER;
    BEGIN
    SELECT seq.nexval into v_varil from dual;
    RETURN v_varil;
    END;
    --here you will have all you internal package and procedures and functons.....
    BEGIN
    g_seq := get_seq_value;
    END abc_pkg;
    You can use global variable g_seq throughout this main package elements.
    Assumption2.
    You want different value of the sequence based on need purpose in the package but don't want to code the select statement, in this case just call the function get_seq_value whereever you need it in the package.
    Thanks
    SP

Maybe you are looking for