INSERTED Table - When it gets populated with single or multiple rows?

Hi,
I'm trying to create a trigger which then insert to a table. i'm wondering when does the INSERTED table gets populated with single or multiple rows?
Should I always assume that the INSERTED Table will contains several rows? What does the scope of the INSERTED table in the trigger, isn't based on the user session?
 The reason why i asked this is because as far as i know inserted table may contain several table when the trigger fires which is why I use cursor to insert  records in the table ( there's a behind why i use cursor).
But if the inserted table will only contain a single record during the session of the trigger then i can avoid the cursor.
Thanks.

But since we control the transaction process and we know for a fact that user will only be able to save a record one at a time, do we still expect multiple rows? I just want to have a clear concept on the INSERTED table.
...and then the DBA or someone else sees fit to enter a number of rows directly from a query window. And don't laugh. That is bound to happen sooner or later.
However, just because this can (and will) happen does not mean that you need to handle it on equal footing with the normal case user entering data through the application. What you cannot permit yourself to is to drop the DBA case on the floor, that is write
the trigger as if there would either be single-row inserts and produce incorrect results for multi-row inserts.
But, yes, allowing yourself to use a cursor, if you want to reuse the existing stored procedure is feasible. That is also the more drastic solution suggested by Tom to add an explicit check that disallows multi-row inserts.
Finally, permit me to comment on this:
Additionally, it's  difficult to use the code below as i need to pass the identity id of tbl_A to tbl_B
You can use the OUTPUT clause to capture the values, but that requires that you have something you can map the identity values to in the columns you insert, and this is not always the case. However, there is a lot simpler solution to the problem: don't
use IDENTITY. IDENTITY is one of these over-used and over-abused features in SQL Server. You need it when you want to support high-concurrency inserts, because rolling your own requires a serialisation point. But with a moderate insertion frequency, IDENTITY
only gives you headache.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • When CDB gets populated? what is load parameters and syn parameter?

    hi all,
    myself have a query with regards to consolidated database where would to like to know when does the CDB gets populated. when we deploy the MBO does the mbo bring the data from backend sys or when we call it from UI client.
    what is load parameters and syn parameter got confused. please explain in very normal term.
    thnaks
    sk

    thanks rincy and reddy for reply
    myself understood the concepts of load and sync parameters thanks for your inputs....
    we are doing a scenario with backend as SAP and front end ui with ios. we have done all the things in place and when executing from ui front end only the last record is displayed. for example if it is returning 6 records then it displays only the last record.
    check in CDB and foun only the last record is ther in it but when doing the PREVIEW of MBO to test it their it displays all the record but from UI it is displaying only 6th record
    this where my query is that hw and when CDB gets populated and where i have to look in to rectify it....
    thanks
    SK

  • Table PPFTTRIGG not getting populated

    Hi,
    I am in the process of solving an issue where some of service confirmations are locked. Some of the service confirmations are not getting sent from CRM to ECC system. If we run the program RSPPFPROCESS, it picks up the actions from table PPFTTRIGG and sends it. However all this works only if the table PPFTTRIGG gets populated with the actions. How does this table get populated? I have not found anything in the where used list of the table or in the BADIs.. Does the configuration in SPPFCADM have anything to do with it? Please help me.
    Edited by: NeenaJ on Dec 26, 2011 12:52 PM

    Hi,
       You are trying to pass too many fields for the structure (wwt_fields) .
       Look at the FM 'RFC_READ_TABLE' for 'RAISE DATA_BUFFER_EXCEEDED' you'll have an idea.
    Regards,
    Srini.

  • How and when does table SWIWIOBJCT being updated / populated with workitem

    Hi Experts,
    I am currently debugging an issue wherein a Invoice Workflow is being displayed in the Purchase Order Workflow Overview. I debugged this and found out that this is because there are entries being selected from table SWIWIOBJCT and this will be also displayed in the workflow overview.
    So what I am trying to look into is how does this table being populated. Like, what are the criteria and requirements that this table will be updated / populated.
    Any help is highly appreciated.
    Thanks so much in advance,
    Larissa
    Edited by: Larissa Taguiamon on Apr 14, 2010 7:48 PM

    Abdullah
    The EKBE table will have items related to PO history - so if you go to a PO line item and look at the PO history you will see an invoice but you will NOT see a payment.   Payments are not directly related to a PO and therefore no payment information would appear in your PO history and therefore it wouldn't be on the EKBE table either 
    Sandra

  • KINAK field in Table KONV not getting updated with value W

    Hi,
    I have a PO where I am deleting a line item.
    After I delet line item the field KINAK in table KONV gets updated with value W.
    But I am getting instance where in some cases the field KINAK is not getting updated.
    The result is deleted line item is getting populated in PO output also.
    Regards
    Nandiini

    KINAK is updated only when a Condition is inactive ! So when a item is deleted the condition becomes inactive and gets updated with 'W' which means statistical(not to be counted)
    A     Condition exclusion item
    K     Inactive due to calculation basis/shipping material type
    L     Condition exclusion header or inactive at header level
    M     Inactive due to manual entry
    T     Inactive at header level
    W     The document item is statistical
    X     Inactive via formulae of incorrect
    X     Inactive via formulae of incorrect
    Y     Inactive because of subsequent price

  • BBP_DOCUMENT_TAB does not get populated with shopping cart

    Hello Gurus,
    We are facing some weird issue out of blue. We have SRM 5.0 Classic scenario with ECC 6.0 backend system. We have everything configured and it was working i mean shopping carts were successfully transferring into ECC system as PR.
    Suddnely now we are getting error Item in transfer process for all the shopping carts. While checking into RZ20 monitor it shows following error " Backend application errors: Shopping cart  (PReq. 7000027359): W5 002 No items exist (not possible to save)".
    When we put debug in CLEAN_REQREQ_UP we found out that table BBP_DOCUMENT_TAB which should get populated whenever shopping cart is approved it not getting any data.
    Could you please let us know what could be the reason? As all the user IDs with which RFC's are maintained at SRM and ECC level active and all proper authorization are there.
    Please advise.
    Thanks
    Ritesh

    Hello Ritesh,
    Actually, the document tab is updated by the SC transfer (SC spooler). Each time the system starts the shopping cart transfer, an entry is created in BBP_DOCUMENT_TAB until the CLEAN_REQREQ_UP is executed.
    You could debug the shopping cart transfer and check if the follow-on document is being created.
    Also, you could check the SPRO customizing -> SRM SERVER -> Techcnical Basic Settings -> Set Control Parameters, and check its value.
    As additional information, you can check the note 1173815, which provides some information regarding the follow-on document creation (customizing tables).
    I hope it helps.
    Kind regards,
    Ricardo

  • Files get open with single click sometimes

    I recently started having this problem. When I browse through different image/video files, some of the files get open with one click only. This is really very annoying. I am event thinking to migrate back to Windows because of this problem.
    How to reproduce the issue:
    -> Open a folder that contains many images/video files
    -> Click on anyone of them to select it
    -> Now click outside the window. So, the finder goes out of the focus (but should stay visible)
    -> Now, inside finder click any other image/video just once, it will open up automatically with just single click

    If you have access to a mouse, try using it. If everything is okay using the mouse, then it is likely trackpad related. Other troubleshooting.
    Try setting up another admin user account to see if the same problem continues. If Back-to-My Mac is selected in System Preferences, the Guest account will not work. The intent is to see if it is specific to one account or a system wide problem. This account can be deleted later.
    Isolating an issue by using another user account
    If the problem is still there, try booting into the Safe Mode.  Shut down the computer and then power it back up. Immediately after hearing the startup chime, hold down the shift key and continue to hold it until the gray Apple icon and a progress bar appear. The boot up is significantly slower than normal. This will reset some caches, forces a directory check, and disables all startup and login items, among other things. If the system operates normally, there may be 3rd party applications which are causing a problem. Try deleting/disabling the third party applications after a restart by using the application unistaller. For each disable/delete, you will need to restart if you don't do them all at once.
    Safe Mode
    Safe Mode - About
    General information.
    Isolating issues in Mac OS X
    Troubleshooting Permission Issues
    Step by Step to Fix Your Mac

  • Table in XMLP not populating with all rows

    I am creating a letter template with a table using XMLP where a table should be populated with an employee's current benefit elections. An employee could have between one and three rows of data. For each employee I can get the first row of data to populate, but if they have more than one row it is populated on the next page causing one employee to have between one and three letters. Can anyone give me some advice as to how I can get all of the rows to populate on one employee's letter? Thanks!!

    Have you forgotten how to [use code tags|http://forums.sun.com/thread.jspa?threadID=5231522]?
    db

  • Field of a table is not getting populated correctly in xml file.

    Hi Experts,
    I have an issue.
    I transfer a ABAP table as an XML messgae on to application server.
    BUt the correct format is not comming on Server.
    Eg: i have a filed in table as /abc/def this field is getting populated on xml messgae as -abc-def
    How do i solve thi sproblem.
    Inouts are highly appreciated.
    Regards,
    Varun

    Hi,
    Check following will helpul
    http://blogs.oracle.com/jdevotnharvest/entry/how_to_programmatically_set_focus

  • Excise table J_1IEXCDTL not getting updated with Excise Base value.

    Hi All,
    The the field EXBAS of table J_1IEXCDTL is not getting updated for ETT (Transaction Type) DLFC.
    For other transaction types, the same is getting populated.
    Is there a setting for controlling the same?
    If yes, can you please guide me.
    Best Regards
    Debaditya Ghosh

    First you should ensure that it is flowing in your billing document.  If so, automatically, it will also flow in your excise invoice and the field EXBAS will be updated accordingly.
    From your comments, it seems, the amount is not flowing in your billing document and excise invoice.  If so, ensure that you have assigned  the correct tax code in FV11 for your ED condition type.
    thanks
    G. Lakshmipathi

  • Copy Function with Single selection of row

    I want to copy necessary Planning items in my Input ready query from period 1 to remaining periods based on variable entries.  To achieve this I have created a copy planning function to copy amount entered in period 1 (variable) to range of posting period variable entries (e.g. 2 -12 or 6-12).
    I have created structure for GL accounts and I want to copy from period 1 to 2 - 12 for one row at a time.
    I have created WAD template, I selected in behavior section of Analysis item, single with command option and assigned Planning sequence (consisting of copy function) as command.
    On execution of WAD, I select single row in my input ready query and instead of one row getting copied over to the range of posting period, all rows consisting of Planning Items with amount are getting copied over, which I am not expecting with single selection option.
    How can I have only one row getting copied over?
    Am I am missing something?
    Your suggestions are highly appreciated.
    Regards,
    Sachin

    Hello Gregor,
    Thanks for your response.  I tried what you have suggested and also followed the documentation, not sure why it is not working as expected
    In my variable I have characterictis such as:
    Version
    Fiscal Year
    Fiscal Year Variant
    Profit Center
    In my rows:
    Planning Item
    Columns:
    Period
    Amount
    In behavior I have selected Row Selection Single.  I am using Button group and assigned following:
    Command: Execute a Planning Function -> In Data Binding -> Selection Binding -> Characteristic -> Planning Item -> Binding Type -> Item Characteristic -> Web Item Selection -> Item Binding -> Query (Analysis Item) -> Characteristic -> Planning item.
    For Variable I have defined nothing.
    Do you think my settings are correct?
    Regards,
    Sachin

  • Inserting values into multiple tables in one jsf page with single commit op

    hi all,
    i have two tables ,
    one is parent table and other is child record.
    record details:
    table1:(parent table)
    emplid (primary key)
    empl_name
    table 2:(child table)
    empl id ( Foreign key)
    empl_name ( Foreign key)
    contact_no (primary key)
    my senario is , i need insert values into both parent and child table in one save option.
    and both the tables will be in one jsf page.
    is this possible to do?
    thanks all,
    regards,
    M vijayalakshmi

    hi,
    i feel my question is not clear.
    let me explain my question clearly.
    1. i have two records
    *1. emp_names*
    attributes of this table is 1.emplid
    2.emp_name.
    emplid is a primary key.
    2. emp_contact
    attributes of this table is 1.emplid
    2. contact_no
    In this table emplid is forigen key from emp_name table
    contact_no is primary key.
    and my senerio is,
    for one emplid there are many contact no.
    in database diagram i have created these two entities. and from that i have generated two views objects.
    now in jsf page ,
    i shd have all fields from both the records.
    wn ever i click on add button , i shd be able to insert one complete row of data to both the tables.
    means,
    emplid
    empl_name
    contact_no.
    and if i click on commit button data shd be insert in both the tables.
    so how to achive this?
    am very beginner to the jdeveloper tool.
    regards,
    m vijayalakshmi.

  • Getting Counts with single query

    HI,
    I need help in writing a query that gets account counts in a single query,
    CREATE TABLE ACCOUNTINFO(     
    ACCOUNTID VARCHAR2(20 BYTE) NOT NULL,
    ACCOUNTNO VARCHAR2(10 BYTE) NOT NULL,
    LAST_DEPOSIT_DATE DATE,
    BALANCE NUMBER(10,0));
    I have a table like above and I am trying to write a query that gets
    Count of accounts with deposits made in last 1 month,
    Count of accounts with deposits made in last 2 months
    Account Count with balance > 0,
    Also, I need to join this ACCOUNTINFO with ACCOUNTMAIN to get name etc details
    CREATE TABLE ACCOUNTINFO(     
    EMPID VARCHAR2(20 BYTE) NOT NULL,
    FNAME VARCHAR2(30 BYTE) NOT NULL,
    MNAME VARCHAR2(30 BYTE),
    LNAME VARCHAR2(30 BYTE) NOT NULL,
    DOB DATE,
    ACCOUNTID VARCHAR2(20 BYTE));
    Question, how to write a query since I getting too-many counts (I have only 3 in sample above, actual goes on like 3-6, 6-9 etc).

    SELECT SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-1) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_MONTH,
           SUM  (CASE WHEN LAST_DEPOSIT>=ADD_MONTHS(SYSDATE,-2) THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_LAST_TWO_MONTHS,
           SUM  (CASE WHEN BALANCE>0 THEN
                   1
                 ELSE
                   0
                 END
                ) COUNT_BALANCE_GREATER_ZERO
      FROM ACCOUNTINFO

  • Getting result with single query

    Hi,
    I'm using db 10.2.0.1.0
    I have a table emp_shift , with data like below
    EmpCode           Shift     Effdate            Default
    1                 SHFT1    02-jan-2012          N
    1                 SHFT2    04-jan-2012          Y
    1                 SHFT3    04-jan-2012          NSo if user inputs EmpCode and Effdate, based on that i've to take the latest record, with default = 'Y' (if any) else default 'N'
    Suppose
    Case 1 : Input Empcode:1 Date:10-jan-2012
    Then i should get the below record
    1                 SHFT2    04-jan-2012          YCase 2 : Input Empcode:1 Date:03-jan-2012
    Then i should get the below record
    1                 SHFT1    02-jan-2012          NI want this result with a single query, is this possible?
    Thanks
    Divya

    Hi Thank you both,
    I'm trying this process through forms. and my forms version is 6i.
    There where i'm trying the query with the cursor, i'm getting error
    Encountered the symbol Order when expecting one of the following
    .()...and my cursor is
    Cursor cur_shft(vemp Varchar2,vdate Varchar2) is Select ESM_SHIFT_TYPE
         from (Select ESM_SHIFT_TYPE from EMPLOYEE_SHIFT_MASTER
                   Where ESM_EMP_CODE = vemp
                   and ESM_EFF_DATE <= vdate
                   Order by ESM_EFF_DATE desc,Esm_Default desc)
                   Where rownum=1 ;Whats wrong?

  • How to get this with Single query

    Friends
    I am sure using SQL analytical function, the following can be achieved using a single query:
    Date_value | Cust_id | Customer_tenue | avg_bal
    01-aug-09 | 111 | 0 | 1000
    01-aug-09 | 112 | 1 | 2000
    01-aug-09 | 113 | 2 | 900
    01-aug-09 | 114 | 3 | 1250
    01-sep-09 | 111 | 1 | 1200
    01-sep-09 | 112 | 2 | 2000
    01-sep-09 | 113 | 3 | 1900
    01-sep-09 | 114 | 4 | 1250
    01-oct-09 | 111 | 2 | 1100
    01-oct-09 | 112 | 3 | 2200
    01-oct-09 | 113 | 4 | 1900Expected result
    If customer’s tenure is 0 then mark as ‘New’,
    If customer’s balance is increased from last month then mark as ‘Augment’
    If customer’s balance is same as last month then mark as ‘Maintain’
    If customer’s balance is decreased from last month then mark as ‘Diminish’
    Else ‘Left’
    Help please....

    If customer’s tenure in last month is 0 then mark as ‘New’,There's not such case in test data... last month is October, isn't it?
    SQL> with t as (select DATE '2009-08-01' Date_value, 111 Cust_id, 0 Customer_tenue, 1000 avg_bal from dual union all
      2  select DATE '2009-08-01', 112 , 1 , 2000 from dual union all
      3  select DATE '2009-08-01', 113 , 2 , 900 from dual union all
      4  select DATE '2009-08-01', 114 , 3 , 1250 from dual union all
      5  select DATE '2009-09-01', 111 , 1 , 1200 from dual union all
      6  select DATE '2009-09-01', 112 , 2 , 2000 from dual union all
      7  select DATE '2009-09-01', 113 , 3 , 1900 from dual union all
      8  select DATE '2009-09-01', 114 , 4 , 1250 from dual union all
      9  select DATE '2009-10-01', 111 , 2 , 1100 from dual union all
    10  select DATE '2009-10-01', 112 , 3 , 2200 from dual union all
    11  select DATE '2009-10-01', 113 , 4 , 1900 from dual)
    12  select date_value, cust_id, avg_bal, oldbal, case when Customer_tenue=0 and nextbal is null then 'NEW'
    13                                                    when oldbal<avg_bal then 'Augment'
    14                                                    when oldbal=avg_bal then 'Maintain'
    15                                                    when oldbal>avg_bal then 'Diminish'
    16                                                    else 'Left' end status
    17    from (select date_value, cust_id, customer_tenue, avg_bal, LEAD(avg_bal) over (partition by cust_id order by date_value desc) oldbal,
    18                 LAG(avg_bal) over (partition by cust_id order by date_value desc) nextbal
    19            from t)
    20  order by cust_id, date_value;
    DATE_VALU    CUST_ID    AVG_BAL     OLDBAL STATUS
    01-AGO-09        111       1000            Left
    01-SET-09        111       1200       1000 Augment
    01-OTT-09        111       1100       1200 Diminish
    01-AGO-09        112       2000            Left
    01-SET-09        112       2000       2000 Maintain
    01-OTT-09        112       2200       2000 Augment
    01-AGO-09        113        900            Left
    01-SET-09        113       1900        900 Augment
    01-OTT-09        113       1900       1900 Maintain
    01-AGO-09        114       1250            Left
    01-SET-09        114       1250       1250 Maintain
    Selezionate 11 righe.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/]

Maybe you are looking for

  • Overheads not calculated in CK11N cost estimation

    Hi all, I have two issues 1. When i am executing CK11N,i am not able to get the overhead calculation in itemization,but its showing some ridiculess firgure in cost component structure.I am using dependency D020. 2 . when i am using  dependency D050 t

  • Can I have different page sizes in the same Pages document?

    I am doing an e-zine and since it will be delivered in PDF format Pages page layout features will make it easy....except in some cases I want 2 page spreads and to show that way so I'd want that page to be 17x11 and the rest to be 8.5x11...is there a

  • Suppres the validity period in a time dep hierarchy with a temporal join

    Dear all, With our customer we have an reporting presentation issue that we cannot solve. Can you please help us with a solution? It is a hierachy display problem in a report. We present a time dependent hierarchy structure with a temporal join. This

  • Incripting Data Output

    Many of my programs use the write to measurement file.vi or the write to spreadsheet file.vi and save the output data as a standard tab-deligniated spreadsheet, .lvm file.  My question is if there is a way to make an incripted file so that it is save

  • Mysterious sent mail pic files disappearing?

    Hi, this keeps happening to me with mail app. I'll send an attachment or pic file and after its sent it reside in my "sent" folder briefly. I go to see later what I sent and its gone, no where to be found. and then i'm stumped on whether I sent it or