Migrating from MSSQL2005: Before-Insert Trigger Generation

The SQL Server 2005 tables with auto=incrementer primary keys result in sequence objects being defined for use in Before-Insert triggers, which is good. I see the following code in the generated triggers:
<br>
IF INSERTING AND :new.ofi_service_provider_id IS NULL THEN
SELECT OFI_SERVICE_PROVIDER_ofi_servi.NEXTVAL INTO v_newVal FROM DUAL;
-- If this is the first time this table have been inserted into (sequence == 1)
IF v_newVal = 1 THEN
--get the max indentity value from the table
SELECT NVL(max(ofi_service_provider_id),0) INTO v_newVal FROM OFI_SERVICE_PROVIDER;
v_newVal := v_newVal + 1;
--set the sequence to that value
LOOP
EXIT WHEN v_incval>=v_newVal;
SELECT OFI_SERVICE_PROVIDER_ofi_servi.nextval INTO v_incval FROM dual;
END LOOP;
END IF;
</br>
I'm guessing this is a boilerplate template. I'd like to replace this with my own template code, so the generated triggers meet our own in-house specifications. And that looping method of bumping up a sequence object's NEXTVAL is hideous!
Is there a way to modify your template with my own, so I can generate the triggers according to our needs?
- Dan Clamage

I'm trying to generate the code to fit our shop. These Before-Insert triggers would need to be rewritten for our environment. The template provided doesn't suit our needs. It'd make more sense if it was picked up from a text file, or at least presented on a Preferences screen, with placeholders for the sequence object name. Then a developer could tweak it to suit their own shop's needs, and have it generated correctly from the migration.
This migration isn't a one-time deal for us. We'd be doing it over and over.

Similar Messages

  • INSERTstatement is not working if there is a before insert trigger

    INSERTstatement is not working if there is a before insert trigger on that table. That trigger contains an insert to another table which having the main table reference.
    Let us say, for example there a table named 'EMP_DEPT' and there is a before insert trigger on this table.
    In this trigger inserting a record in to another table named 'AUDIT_EMP' and in this table using EMP_Dept primary key as foreign key.
    Table EMP_DEPT is having the below columns:
    EMP_DEPT_SYS_ID
    EMP_DEPT_NO
    DEP_NAME etc..
    Table AUDIT_EMP is having the below columns:
    AUDIT_EMP_SYS_ID
    EMP_DEPT_SYS_ID
    AUDIT_NO etc..
    the code in the trigger is
    INSERT INTO audit_emp
    (audit_emp_sys_id, emp_dept_sys_id, audit_no
    VALUES (audit_emp.NEXTVAL, :new EMP_DEPT_SYS_ID, '1101'
    Now when you execute the insert query like:
    INSERT INTO emp_dept
    (emp_dept_sys_id, emp_dept_no, dep_name
    VALUES (EMP_DEPT.nextval, 1001, 'Dep-1'
    It is giving the error saying 'Integrity constraint error, parent key not found' from the trigger.
    But, when you modify the above insert query like the below then it is working.
    INSERT INTO emp_dept
    (emp_dept_sys_id, emp_dept_no, dep_name
    SELECT EMP_DEPT.nextval, 1001, 'Dep-1'
    FROM DUAL;
    I am using Oracle 10g.
    Why the insert into values is not working. Is there any commit transaction sequence change? Any idea please?
    Edited by: user6475632 on Sep 16, 2009 7:08 AM

    Obviously the code you posted can not work.
    You are inserting the detail record (the audit record) before the master record, where it should have been after. IMO, you should fire the trigger AFTER INSERT for each row.
    If that still doesn't work, you need to change the foreign key constraint into a deferred constraint, which is evaluated at commit, instead of immediately. The SQL reference manual has further info on this.
    'Oracle 10g' is considered a marketing label here, not a -4 digit- version.
    Sybrand Bakker
    Senior Oracle DBA

  • Clob field not working in BEFORE INSERT trigger

    Hello, everyone. I am trying to create a before insert trigger for a table (10g). I would like to create a value for a table field based on the xml query from a clob field. The table looks like this:
    SQL> desc lac_costing_upload
    Name Type Nullable Default Comments
    UPLOAD_ID NUMBER Y
    EMP_NUM VARCHAR2(20)
    UPLOAD_DATE DATE Y
    YEAR_MONTH VARCHAR2(10) Y
    UPLOAD_TEXT CLOB Y
    The trigger code looks like this:
    create or replace trigger lac_cst_upl_yr_month
    before insert on lac_costing_upload
    for each row
    declare
    l_month varchar2(20);
    l_year varchar2(20);
    l_error_msg varchar2(255);
    begin
    SELECT XMLTYPE (:old.upload_text).EXTRACT('Oracle_Extract/Year/text()').getstringval() Extr_Year
    , XMLTYPE (:old.upload_text).EXTRACT('Oracle_Extract/Month/text()').getstringval() Extr_Month
    into l_year
    , l_month
    FROM dual;
    :new.year_month := l_year || '.'
    || substr(l_month, 1, 3)
    exception
    when others then
    l_error_msg := substr(sqlerrm, 1, 10);
    :new.year_month := l_error_msg;
    end lac_cst_upl_yr_month;
    Here is a sample insert statement:
    insert into lac_costing_upload lcu values(2006, '008925', sysdate, null
    , '<Oracle_Extract>' || chr(10)
    || ' <Emp_Num>05417</Emp_Num>' || chr(10)
    || ' <Emp_Name>Fitzgerald</Emp_Name>' || chr(10)
    || ' <Year>2007</Year>' || chr(10)
    || ' <Month>May</Month>' || chr(10)
    || ' <Vehicle>1330</Vehicle>' || chr(10)
    || '</Oracle_Extract>'
    My hope was to see '2007.May' in the year_month field. However, I'm getting 'ORA-06502:' instead. It looks like the value of :old.upload_text is null in the trigger.
    Can anyone tell me what I'm doing wrong?
    Thanks for any help.
    --Dave                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    That's probably a really dumb error, but I don't work much with triggers.
    It's working now.
    Thanks for your help.
    --Dave                                                                                                                                                                                                                                                               

  • Problem determining if id is present in BEFORE INSERT trigger

    Hi,
    I have written a BEFORE INSERT trigger in which I am trying to determine whether or not an id (primary key ) has been submitted as part of the insert. The reason for this is that in my application there are two cases in which the trigger will be called, 1) when the id has been previously obtained from a sequence and passed in, and 2) when an id needs to be 'automatically' generated from within the trigger'. (two subsystems which work differently talk to the database in different ways)
    this is the key part of the trigger code:
    CREATE OR REPLACE TRIGGER trg_submissions_seq_id
    BEFORE INSERT on submissions
    FOR EACH ROW
    BEGIN
    if :new.id IS NULL THEN
    select seq_submissions_id.nextval INTO :new.id FROM DUAL;
    end if;
    ....more code here
    END;
    I think this is correct. Can someone confirm this.
    However the behaviour I see is that in case 1 the id is increased twice , once when it is obtained from the sequence , and then again in the trigger... despite the condition I put in.
    If anyone can shed any light on this behaviour I would be grateful.
    Mark

    This trigger (at least what you've posted of it) won't increment the sequence if Rails passes in the ID column. If you're always seeing the sequence incremented twice, I would tend to wager that either Rails is calling the nextval function twice or that it is not passing in an ID. Of course, since Oracle sequence-generated values are not gap-free, presumably this is just a cosmetic issue, not a functionality issue.
    As a general matter, I'd suggest not using ID as a column name for a table. In addition to being a poor naming convention, ID is a reserved word.
    Justin

  • Problem while using Before insert Trigger

    Hello everybody,
    I am using 9.2.0.4.0 XMLDB..
    The problem occurs while using the before insert trigger shown below to convert a CLOB(:new.file_clob) to XMLTYPE(:new.file_xml). The trigger is on a table with file_clob and file_xml as columns. file_xml column is based on a registered schema.
    The trigger is:
    Create or replace trigger po_2_demo_xml_tab_trg
    before insert on po_2_demo_xml_tab
    FOR EACH ROW
    -- Step 1:to convert CLOB to XMLtype and store it
    --in :new.file_xml .
    :new.file_xml := xmltype(:new.file_clob);
    -- Step 2:to verify if :new.file_xml has been created
    dbms_output.put_line(:new.file_xml.extract('/PurchaseOrder/PONum/text()').getStringVal());
    end;
    If u insert a valid xml file, u can see the PONum value on dbms output(Step 2 of the trigger works). u also get the "1 row inserted" message.
    Surpisingly, if u query on the table it shows that the file_xml column is null! For some reason, the value of :new.file_xml in the before insert trigger is not being retained in the table.
    Has anybody encountered this before? Do I have to apply any patch?
    Appreciate any help in this regard.
    Thanks,
    Partha.

    sorry! I just noticed.. the trace file does show an error, but the error is while creating the table itself.
    Please see the segment from trace file below:
    The following statements encountered a error during parse:
    create table po_2_demo_clob_xml_tab
    file_clob CLOB,
    file_xml xmltype
    )xmltype column file_xml
    XMLSCHEMA "http://Friday/PO_2.xsd"
    ELEMENT "PurchaseOrder";
    XCTEND rlbk=0,
    Error encountered: ORA-00911
    But, inspite of this I am able to insert a xml file into file_xml using a sql statement. But the before insert trigger does not retain :new values.
    Appreciate any comments.
    Thanks,
    Partha.

  • Calling function in before insert trigger

    HELLO,
    **TRIGGER IS NOT DISPLAYING THE DATA ACCURATELY**
    **PLZ HELP ITS URGENT...**
    THE CODE IS BELOW.....
    create or replace TRIGGER GENSTUDYID
    BEFORE INSERT
    ON ER_PATPROT
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
         lPatStudyID varchar2(30);
         lSiteCode number(10);
         lStudyCode number(10);
         lpk_patprot     Number(10);     
         lpatprot_enroldt date;
         lFK_PER number(20);
         lIPADD varchar2(15);
         lfk_protocol number(20);
         llast_modified_by number;
         lgencal_status number;
    BEGIN
         lSiteCode := :New.fk_site_enrolling;
         lStudyCode := :new.fk_study;
         lpk_patprot := :new.pk_patprot;
         lpatprot_enroldt := :new.patprot_enroldt;
         lFK_PER := :new.fk_per;      
         lIPADD :=NULL;                
         lPatStudyID:=GenerateStudyID(lSiteCode,lStudyCode,lFK_PER);
         IF lPatStudyID IS NOT NULL then
              :NEW.patprot_patstdid := lpatstudyid;
         END IF;
    END;
    -----------FUNCTION CODE STARTS
    create or replace
    function GenerateStudyID (sitecode number,studycode number,pid number) RETURN VARCHAR IS
         lfield_name varchar2(10);
         lfield_format varchar2(10);
         lfield_length number(2);
         lfield_deftext varchar2(500);
         lparam1 varchar2(30):=sitecode;
         lparam2 varchar2(30):=studycode;
         lresult varchar2(30);
         lstudyid varchar2(30);
         lPATPROT_PATSTDID     varchar2(20);
    CURSOR studyid_def_cur is select field_name, field_format, field_length, field_deftext from bayatree.studyid_definition
    where study_code = studycode and site_code=sitecode order by field_seqno;
         CURSOR patprot_patstdid_cur is select PATPROT_PATSTDID from eres.er_patprot where fk_study=studycode and fk_per=pid;
    BEGIN
         lstudyid := NULL;
    dbms_output.put_line('studycode: '||studycode);
         dbms_output.put_line('pid; '||pid);
         FOR disp_studyid in patprot_patstdid_cur
         LOOP
              lPATPROT_PATSTDID:=disp_studyid.PATPROT_PATSTDID;
              dbms_output.put_line('lPATPROT_PATSTDID: '||lPATPROT_PATSTDID);
         END LOOP;
              IF lPATPROT_PATSTDID IS NULL THEN
              OPEN studyid_def_cur;
              LOOP
              FETCH studyid_def_cur INTO lfield_name, lfield_format, lfield_length, lfield_deftext;
              EXIT WHEN studyid_def_cur%NOTFOUND;
    lfield_deftext:= replace(lfield_deftext,'param1',lparam1);
              lfield_deftext:= replace(lfield_deftext,'param2',lparam2);
         if (instr (lfield_deftext, 'select',1) > 0) then
                   execute immediate lfield_deftext into lresult;
              else
                   execute immediate lfield_deftext;
                   lresult := null;
              end if;
              if lfield_format is not null and lresult is not null and lfield_length is not null then
                   lresult := lpad(lresult, lfield_length, 0);
              end if;
              if lfield_name is not null and lresult is not null then
                   lstudyid := lstudyid || lresult;
              end if;
         END LOOP;
         return (lstudyid);
         ELSE
              lstudyid:=lPATPROT_PATSTDID;
              Dbms_output.put_line('Study Id: '||lstudyid);
              return (lstudyid);
         END IF;
    END;

    Your post is not quiet readable, please include your program in tags, Include sample data and sample output, table and other objects creation and insert scripts.
    What error are you getting anyway post the Oracle error code
    SS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Before insert Trigger and SQL Loader

    Hi,
    I have a table with a BEFOR insert on each row trigger . I am loading the data to that table using sqlloader and I want my trigger to fire for each row. But the trigger is firing only for alternate rows.
    body of trigger as follows.
    select max(pd_id) into VarVal from <table name> where tar_id=:new.tar_id;
    select pd_id+1 into :new.pd_id from dual;
    if I remove the first select statement from my trigger , then it is firing for all the rows. But the removel of first select statement will not satisfy my requirements.
    So please suggest me how can I achieve this.

    [url http://forums.oracle.com/forums/thread.jspa?threadID=587783&tstart=0]duplicate thread

  • Migrating from MSSQL2005 to OracleExpress 10g - stored proc problems

    I'm trying to migrate from MSSQLExpress2005 to OracleExpress 10g.
    I upgraded my SQLDeveloper 1.1.3 to SQLDeveloper 1.2 from Check Updates (Even it still displays 1.1.3 at Help->About, I assume it was upgraded because version of extensions changed to 10.2.0.29.98)
    First I have renaming of my objects problem :
    Why does SQLDeveloper renames my stored procedures? I dont see any reason to change.Some of about 50 occurrences :
    1-"spCPLN_Alloc_ReSortForMultiAttendance" to "spCPLN_lloc_ReSortForMultitten"
    2-"spCPLN_Alloc_CalculateFixedConstraints" to "spCPLN_lloc_CalculateFixedCons"
    3-"spCPLN_Alloc_GetAllocationResult" to "spCPLN_lloc_GetllocationResult"
    Another problem : What is the problem of this T/SQL scode snippet?I cant convert it with Scratch editor too. I got "Unexpected end of subtree : Line 0 Col 0." error
    CREATE PROCEDURE spCPLN_XML_InsertDers
    @CourseID int,
    @Type1 int
    AS
    BEGIN
    IF((NOT EXISTS(
    SELECT * FROM DersKur
    WHERE CourseID = @CourseID))
    AND ( @Type1 = 2 ))
    BEGIN
    SELECT 1
    END
    END     
    I have more than 15 error like this.
    thank you
    tuna

    Hi Tuna ,
    Thanks for the feedback.
    Stored procedure names are collision managed so that they are not longer than 30 characters in length. This is a limitation of Oracles object naming convention.
    http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/fundamentals.htm#sthref309
    WRT the procedure.
    There is a issue in the T-SQL translator which I have logged a bug for.
    bug 6127111 NOT EXITS SUB EXPRESSION NOT RECOGNIZED
    It looks like the translator cannot recognize the
    IF(( NOT EXISTS
    and is expecting IF NOT EXISTS.
    As a workaround the following manually modified T-SQL translates
    T-SQL
    CREATE PROCEDURE spCPLN_XML_InsertDers
    @CourseID int,
    @Type1 int
    AS
    BEGIN
    IF NOT EXISTS(
    SELECT * FROM DersKur
    WHERE CourseID = @CourseID) AND ( @Type1 = 2 )
    BEGIN
    SELECT 1
    END
    END
    GENERATED PL/SQL
    CREATE OR REPLACE PROCEDURE spCPLN_XML_InsertDers
    v_CourseID IN NUMBER DEFAULT NULL ,
    v_Type1 IN NUMBER DEFAULT NULL ,
    cv_1 IN OUT SYS_REFCURSOR
    AS
    v_temp NUMBER(1, 0) := 0;
    BEGIN
    BEGIN
    SELECT 1 INTO v_temp
    FROM DUAL
    WHERE NOT EXISTS ( SELECT *
    FROM DersKur
    WHERE CourseID = v_CourseID )
    AND ( v_Type1 = 2 );
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    END;
    IF v_temp = 1 THEN
    BEGIN
    OPEN cv_1 FOR
    SELECT 1
    FROM DUAL ;
    END;
    END IF;
    END;

  • Halting the update from a BEFORE UPDATE trigger

    Hello,
    I'm writing a trigger which is set to fire before update. One of the possible scenarios requires that the row being updated is not updated but instead deleted. Is it possible to send a DELETE query and then stop the update process so it doesn't spit out an error? I haven't tested this yet, but I'm quite sure it will give an error if it's trying to update a row which has just been deleted.
    Thanks,
    Pavel

    Hi,
    Personally, I don't like implement some business logic into trigger... so, why run an update whenever you need a delete ?
    I would modify the original code to delete in this case instead of update.
    My 2 cents,
    Nicolas.
    SQL> create table pavel (id number, txt varchar2(10));
    Table created.
    SQL> insert into pavel values (1, 'This one');
    1 row created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace trigger pavel_trg
      2  before update on pavel
      3  for each row
      4  begin
      5  delete from pavel where id = :old.id;
      6* end;
    SQL> /
    Trigger created.
    SQL> update pavel set txt = 'Two';
    update pavel set txt = 'Two'
    ERROR at line 1:
    ORA-04091: table SCOTT.PAVEL is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.PAVEL_TRG", line 2
    ORA-04088: error during execution of trigger 'SCOTT.PAVEL_TRG'Message was edited by:
    N. Gasparotto

  • Drill down reports from Before Report Trigger

    Hallo,
    I am using reports 6.08 and I want to run several subreports from the parameter form of a master report. However when I call srw.run_report() from the Before Report Trigger with batch=no I get the error message ... When I use batch=yes I cannot use destype=srcreen. When I use the same call from a button trigger it works fine.
    How can I call a drill down report from the Before Report Trigger?
    The master report should not create a report itself; only the drill down report should be visible. How can I exit the master report without raising an exception after running the drill down report?
    Thanks a lot - Ulrich

    Ulrich,
    The only place where it is valid to call a report using srw.run_report() with a destype=Screen (or Preview) is from a button of an already run report (to provide drill down capabilities).
    In your situation where you're really only using Reports as a parameter form (in the master case) I would suggest that you look to use a real Oracle Form as the master driver, and run_product calls to generate the required reports.
    Hope this helps,
    Danny

  • Call Java from AS/400 DB2 Trigger

    I need to call a Java Program from an SQL Triger (is there anyway to do this?).
    I can call PGM files but my java program is a class file which I can call from:
    1- Command Line with JAVA or RUNJVA
    2- QSHELL with java
    3- SQLScript with CALL QSYS.QCMDEXC('java class(holamundo.PrintParametros) PARM(1 3)',0000000047.00000)
    I thought I could use the sentence CALL QSYS.QCMDEXC in an sql trigger but I couldn't.
    My trigger must be able to send parameters to my JAVA Program.
    I've set my environment variable CLASSPATH I need at *sys level in my AS/400 iSeries 270 with ADDENVVAR.
    Thank you for your time. I appreciate any information.
    Best regards.

    I thought... well if triggers are able to call PGM programs easily,
    then I can add a CL which calls my java program with 'java class
    (package1.ProgramX)' but it falied with the following message (NOTE
    that PGM program is RUNJVAPGM in library ADAM):
    ======================
    Message ID . . . . . . : CPF502B
    Date sent . . . . . . : 06/20/03 Time sent . . . . . . : 10:00:06
    Message . . . . : Error occurred in trigger program.
    Cause . . . . . : The trigger program which was called as the result of a
    database insert, update, delete, or read operation failed. See the previous
    messages in the job log to determine the error. The error code is 2 for
    trigger RUNJVAPGM in library ADAM type *SYS. This error code can be used to
    determine the trigger which caused the error, as follows:
    1 -- BEFORE INSERT trigger
    2 -- AFTER INSERT trigger
    3 -- BEFORE UPDATE trigger
    4 -- AFTER UPDATE trigger
    5 -- BEFORE DELETE trigger
    6 -- AFTER DELETE trigger
    More...
    ===============================
    Code is as follows
    *************** Beginning of data *************************************
    0001.00 PGM
    0002.00 MONMSG CPF502B
    0003.00 RUNJVA CLASS(holamundo.HolaMundo)
    0004.00 ENDPGM
    ****************** End of data ****************************************
    Any comments?

  • Truncate field before insert

    Suppose I have the following:
    table: mytable
    field: username (VARCHAR2(35))
    field: zip (VARCHAR2(5))
    I am importing data from an excel file with columns username and zip. A couple of the usernames contain more than 35 characters, and some of the zipcodes are in the xxxxx-xxxx format, thus containing more than 5 characters.
    I attempted to write a before insert trigger to truncate the data before they are inserted. For any username that is above 35 characters from the excel file, just truncate the username to the first 35 characters. Similarly, for any zip code that is above 5 characters, just truncate the zip to the first 5 characters.
    The trigger for the zip codes:
    CREATE OR REPLACE
    TRIGGER trigger_zipc
      BEFORE INSERT
      ON mytable
      FOR EACH ROW
    BEGIN
      SELECT substr(:new.zip, 1, 5)
      INTO :new.zip
      from dual;
    END;
    However, I get the error: ORA-12899: value too large for column
    I've read on other forums that this is what happens, and that a possible work around is to use INSERT INSTEAD??
    Can anyone give me a solution or point me in the right direction?

    Can anyone give me a solution or point me in the right direction?
    Sure - the 'right direction' is to mark this thread ANSWERED and repost your question in the Sql and Pl/Sql forum:
    PL/SQL
    This forum is ONLY for Sql Developer questions and your question doesn't appear to have anything to do with that tool.
    As the exception says the value is too large for the column. Your code that tries to trim the value will NEVER be executed because the exception occurs BEFORE it ever gets that far.
    The buffer that Oracle creates to hold that :NEW value is too small to hold the value you try to insert - that is why you get the exception.
    You can NOT use a trigger to perform validations such as those since the data will NEVER make it into the buffer the trigger uses.before it ever executes your code.

  • How to create an INSERT trigger which creates a "sequence number"

    Imagine a table T_Q with columns C_1, C_2, C_3 and UN_123.
    C_1, C_2 and C_3 are all numeric and given by the user.
    UN_123 has to be a calculated sequence number starting by 1 and incremented by 1 for each combination of C_1, C_2 and C_3, i.e., the sequence number depends on the key values C_1, C_2 and C_3.
    Could anybody provide a code sample on how to create a BEFORE INSERT trigger , which calculates the value of the column UN_123 based on the values of C_1, C_2 and C_3 ??
    Premise: Rather than using any sequence, the trigger code should only be based on the table T_Q
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Rainer Wagner ([email protected]):
    Imagine a table T_Q with columns C_1, C_2, C_3 and UN_123.
    C_1, C_2 and C_3 are all numeric and given by the user.
    UN_123 has to be a calculated sequence number starting by 1 and incremented by 1 for each combination of C_1, C_2 and C_3, i.e., the sequence number depends on the key values C_1, C_2 and C_3.
    Could anybody provide a code sample on how to create a BEFORE INSERT trigger , which calculates the value of the column UN_123 based on the values of C_1, C_2 and C_3 ??
    Premise: Rather than using any sequence, the trigger code should only be based on the table T_Q<HR></BLOCKQUOTE>
    null

  • Delete all data of a table in Oracle before insert operation in BizTalk.

    Hi,
    I need to delete all the data of a table from Oracle before insert data into it from BizTalk. I can't create stored procedure on the oracle table or how to create a xml of the delete schema of the oracle table in the BizTalk with filter node has a blank
    value because i need to delete all the data of the table so that i will send this xml as delete operation.
    Thanks in advance.
    Regards,
    Gyan

    You need to create two schemas: One for deleting all rows and one for inserting.
    Then combine these Schemas into one and use the "CompositeOperation" SOAP Action Header.
    Something like the below (a SQL Example, so the Schemas needs to be replaced by WCF-Oracle syntax)
    <Request xmlns="http://CompositeTest.CompositeSchema">
    <Delete xmlns="http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/Employee">
    <Rows>
    <Employee xmlns="http://schemas.microsoft.com/Sql/2008/05/Types/Tables/dbo">
    </Employee>
    </Rows>
    </Delete>
    <Insert xmlns="http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/Employee">
    <Rows>
    <Employee xmlns="http://schemas.microsoft.com/Sql/2008/05/Types/Tables/dbo">
    <Name>John</Name>
    <Designation>Manager</Designation>
    <Salary>100000</Salary>
    </Employee>
    </Rows>
    </Insert>
    </Request>
    Morten la Cour

  • Best Practice PK Generation: 'before insert on trig' vs. rolling yer own

    Experts,
    I have a form with the standard Create/Delete/Apply Changes buttons.
    When someone hits "Create", I have a trigger that fires on the table as "before insert on". It hits a sequence to get a new primary key for the record which is about to be created.
    Another way of doing it is to run a page-level PL/SQL computation, and get SEQUENCE_NAME.Nextval, and stuff it into the appropriate page-level item. "Create" will then fire the insert after this computation and it amounts to the same thing as the trigger.
    Loaded question: Which way is better?
    My DBA recommends to "roll my own" using the page-level computation. His reasoning is if my applications scale up to a lot of users running inserts at the same time, the trigger will be a bit of a drag.
    On the other hand, I like having the trigger "on the database" and not having to worry much about it. It is one less thing that I have on my page.
    Dan

    I'm not the end-all be-all of Oracle expertise, so I
    refer to those who are:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:4343369880986#34562653805149
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:4343369880986#76218085672062
    A couple links I could quickly find on the subject.
    I'm sure there's plenty more out there.Taking Tom's answers out of context don't invalidate the problems of a trigger"less" approach.
    As to the other concerns, personally I would argue
    that a separation between application logic and GUI
    shouldn't go so far as to remove all data management
    concerns, such as using primary keys (and otherwise
    indexed fields) to access data.Still, what happens if you want to user other methods of access, for example sqlldr/external tables, ODBC/.NET, etc.?
    Also, I prefer to keep rogue applications/scripts
    away from my data if possible :). Translated: Everyone has to incorporate sequences in any INSERT statement. For BULK inserts, this maybe the way to go, but you can always check if the PK column is NULL, which should give the trigger a bit of performance improvement.
    But on the chance
    that they do go selecting from incorrect sequences it
    will be their own problem. Or your's if other applications start generating error messages.
    It'll be refused insert
    until it can (randomly, I don't care) provide a
    unique value for that column. Yay for constraints!Finding the source of the problem might be where unnecessary work has to be put in.
    I agree there are a few valid uses for such a
    trigger, I've done it myself. But on the whole, it's
    best to avoid it when possible.Can't follow your argument, really. Maybe another agree to disagree topic?
    C.

Maybe you are looking for

  • Cant access to licensing website

    I got a license of acrobat 11 educational, I got license certificate, I would like to download the program from the link I received in email  https://licensing.adobe.com/sap/bc/bsp/sap/zliclogin/login.htm , but when I enter my username and password o

  • How to input/output a digital signal and acquire an analog signal at the same time?

    Dasylab, version: 8.0.04 Acquirement Card: PCI1002L When I use DasyLab to acquire the analog signals is no problem without digital inputs and outputs, and when I use DasyLab to input or output a digital signal is no problem also, but when I do that a

  • HT1338 how do i run adobe flash player?

    how do i run adobe flash player.  I have downloaded it and it keeps telling me to redownload.

  • PhotoShop Elements photo share

    Hi there - hope anybody can help me - I have been using PSE for several years and love it - I often use the "photo share" to send my friends photos by email - for the last few days my friends have not received them - even though everything looks norm

  • Unable to check for available downloads.....error

    The iTunes Store is temporarily unavailable. Please try again later. I'm getting the above error message when selecting "check for available downloads" in the Store menu. Problem started when I tried to download the updated to the Remote App yesterda