How to get the values of the rows just updated in sql

USE []
GO
/****** Object:  StoredProcedure [dbo].[PriceChanges_Update]    Script Date: 09/01/2014 15:43:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:
-- Create date: August 27, 2014
-- Description: Change cigarette prices based on brands.
-- =============================================
ALTER PROCEDURE [dbo].[PriceChanges_Update] 
-- Add the parameters for the stored procedure here
@BrandIDs AS IntListUDTT READONLY,
@Cost decimal(10,2)=NULL,
@EFT1 decimal(10,2)=NULL,
@EFT2 decimal(10,2)=NULL,
@StateTax decimal(10,2)=NULL,
@StampAllowance decimal(10,2)=NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
    -- Insert statements for procedure here
    UPDATE Brands SET Cost = ISNULL(Cost + @Cost, Cost), EFT1 = ISNULL(@EFT1, EFT1), 
    EFT2 = ISNULL(@EFT2, EFT2),StateTax = ISNULL(@StateTax,StateTax), 
    StampAllowance = ISNULL(@StampAllowance, StampAllowance), 
    Price = (( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax)) * .06) +( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax)),
    PickupPrice = ((( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax)) * .06) +( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax))) - .25,
    Retail = (((( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax)) * .055) +(ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax))) *.0775) + (( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax)) *
.055) +( ISNULL(Cost + @Cost, Cost)+ ISNULL(@StateTax, StateTax))
    WHERE BrandID IN (SELECT ID FROM @BrandIDs)
Above is  a procedure which updates a number of rows in the Brands table. I need to be able to take some data from all the rows that were updated and update a different table if the BrandID matches. How would I be able to do this?
Debra has a question

. I need to be able to take some data from all the rows that were updated and update a different table if the BrandID matches. How would I be able to do this?
Debra has a question
You can also use the
OUTPUT Clause.
Thanks and regards, Rishabh K

Similar Messages

  • How to get the row Count of a ResultSet

    How to get the row Count of a ResultSet

    Hi
    I'v tried rennie1's way ,but I only get zero,my code is:
    rs.executeQuery("select count(*) from t_test");
    if (rs.next()) int rowCount=rs.getInt(1);
    I also tried barni's way ,but the method rs.last() and rs.beforeFirst() throw a same Exception
    I tried another way,the code is:
    while rs.next(){
    // Do nothing ,just move the cursour to the last row
    int rowCount=rs.getRow()
    However,the rowCount still equal zero
    Any help would be greatly apprecite!
    note:
    I get connection by DataSource's JNDI name from client, the Server is Weblogic Server 6, the DBMS is Oracle.

  • How to get the process id of a sql statement or a session  ....

    How to get the process id of a sql statement or a session . ..?
    Thanks

    What about this?
    SELECT pid
      FROM v$session s, v$process p
    WHERE p.addr = s.paddr
       AND s.sid = :sid;   -- replace :sid with your session idRegards.
    Al

  • How to get the Row and Column values in ALV (without using Objects)

    Hi All,
    I need to get the Row / Column when double click is used in ALV, I can use the double click event for this. However, I do not want to use the Object Oriented ALV. I want to implement the same functionality using general (using functions) ALV.
    Is there any way to get the row / column values for a Generia (non-OOPs) ALV report.
    Please help.
    Thanks,
    Vishal.

    Hello,
    The only think you have to do is to get the index where the user clicked, and then read the internal table you sent to the alv
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = 'prg_name'
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND' " this is to the click event!!
          i_callback_top_of_page   = 'TOP_OF_PAGE'
          is_layout                = alv_layout
          it_fieldcat              = alv_fieldcat
          i_save                   = 'A'
          it_events                = alv_events[]
        TABLES
          t_outtab                 = i_totmez.  ---> TOUR IT.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    " then....
    FORM user_commandUSING r_ucomm     TYPE sy-ucomm
                                    ls_selfield TYPE slis_selfield.
    " r_ucomm -> HAS THE STATUS
    " ls_selfield-tabindex  -> HAS THE SELECTED INDEX
    " THEN READ THE INTERNAL TABLE
    " HERE YOU WILL HAVE THE SELECTED ROW
    READ TABLE i_totmez INDEX ls_selfield-tabindex.
    ENDFORM.
    cheers,
    Gabriel P.

  • How to get the row number

    Hi list,
    does any one know how I can get the row number the same as what I have in column rowno?
    thanks
    Arvin
    REATE   TABLE dbo.temptable
    ( y int  NOT NULL,
      e int not null,
      c int not null,
      rowno int not null)
    /* insert values  */
    INSERT INTO dbo.temptable(y,e,c,rowno ) VALUES
    (1,1,1,1),
    (1,1,2,1),
    (1,1,3,1),
    (1,20,1,2),
    (1,20,2,2),
    (1,20,3,2),
    (1,3,1,3),
    (1,3,1,3),
    (2,1,1,1),
    (2,1,1,1),
    (2,2,1,2),
    (2,2,1,2);

    You may update your rownumber column with Column "e".
    But why do you duplicate your data? May be there is no particular reason, you may be wasting space for it
    Try the below:
    CREATE TABLE dbo.temptable
    ( y int NOT NULL,
    e int not null,
    c int not null,
    ronum int null)
    INSERT INTO dbo.temptable(y,e,c ) VALUES
    (1,1,1),
    (1,1,2),
    (1,1,3),
    (1,20,1),
    (1,20,2)
    select * from temptable
    update dbo.temptable Set ronum=e
    Select * From dbo.temptable
    DRop table dbo.temptable

  • How to get the rows from a table having some column has any letter

    Hi All,
    suppose i have a table having columns id(number), code(varchar).
    code has alphanumeric characters (ex. ABC123, 67B56 etc).
    some codes are only numbers (2344, 7898 etc).
    how can i get the rows which have alphabets in the code.
    ex:
    id code
    1 AB45
    2 456
    3 890
    4 67B7
    how can i write a query such that it should give me the ids 1 and 4 (as they have alphabets in code)
    thanks in advance to all

    Thanks to one and all.
    i am gettig my required output.
    But i have a doubt in the operator.
    If i add or remove '[]' in the operator, i am getting different ouputs.
    There is a count difference in the result of the operators used.
    REGEXP_LIKE(<column>,'[[:lower:]]')
    REGEXP_LIKE(<column>,'[[[:lower:]]]')
    REGEXP_LIKE(<column>,'[:lower:]')
    Can anybody please explain what is the difference in using '[]', in the operator?
    What is the correct syntax, whether i have to use two '[]'s or one '[]'.
    Also, can i use REGEXP_LIKE() in oracle 8i version.( I am unable to use the operator in 8i)?
    Any query to get the required output in 8i version?
    Thanks in advance to all.

  • How to get the rows gap in the application file...?

    Hi All,
    Im working with Application server and I have a query like after transferring / printing 100 rows in the App server, I need 2 to 3 rows gap and then remaining will print.
    How to get the gap in the application file.
    Pls let me know.
    Puppy.

    Hi,
    when you are transfering the data to file
    loop at itab in wa_itab.
    counter  = count + 1.
    transfer wa_itab to fiel.
    if counter = 100
        clear wa_itab.
        transfer wa_itab to fiel.
        transfer wa_itab to fiel.
        transfer wa_itab to fiel.
       clear counter.
    endif.
    endloop.
    regards,
    Munibbau.K

  • How to get the row reference of inner table of an advance table

    Hi Gurus,
    Using R12.1.3, How to get the handle of inner table row reference of an advance table in controller.
    Regards,
    Zakir

    The javadoc for oracle.jbo.Key is really helpful.
    getAttributeNames()
    getAttributeValues()
    etc

  • Custom row-fetch and how to get column values from specific row of report

    Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
    table has links that send the user to a single-row DML form, but of course the automatic
    fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
    auto fetch only handles 2 PK columns.
    1)
    I have written a custom fetch (not sure it's the most elegant, see second question) that is working
    for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
    more than 3, I don't know how to get the remaining PK column values for the specific row that was
    selected in the report. How can I access that row's report column values? I'll be doing it from the
    form page, not the report page. (I think... unless you have another suggestion.)
    2)
    My custom fetch... I just worked something out on my own, having no idea how this is typically
    done. For each dependent item (database column) in the form, I have a source of PL/SQL
    function that queries the table for the column in question, using the primary key values. It works
    beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
    a way to manually construct the fetch statement once for the whole form, and have APEX be smart
    about what items get what
    return values, so that I don't have to write PL/SQL for every item? Because my query data sources
    are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
    to streamline the process.
    Thanks,
    Carol

    HI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
    It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
    And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
    Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
    Maybe I'm making this too hard?
    Thanks,
    Carol

  • How to get the SSO user from PL/SQL with Windows native authen

    I connect to a 10g daabase using SSO through Windows Native Authentication wher the OID user mapps to a single Database user.
    I need to get the SSO user from pl/sql
    My fornt end is Portal & Forms

    Hmm, I see.
    Well your problem boils down to being in the database and needing to have access to web environment variables. The SSO sets specific variables in the environment but your stored procedure is not privy to them.
    Now having said that, note that the mod_plsql Web Toolkit has a utility for accessing cgi variables. For instance,
    owa_util.get_cgi_env('Osso-User-Dn')
    If your web application cannot capture the SSO info and pass it to the stored proc in a parameter, OWA may be the only way.
    Check out the Single Sign-On Developers Guide, specifically the part about developing statically protected PLSQL applications.
    Hope this helps.
    regards,
    tt

  • How to get the row that has failed due unique constriant voilation

    Does any body knows how I can get the column values for rows that has failed on unique contriant voilation, I am using 10gr2.
    Also we don't have license for shadow table error logging, otherwise I could have gotten the row from there.
    Any help will be highly appreciated.
    Thanks,
    Ravi

    Hi Ravi,
    Prior to OWB 10.2.0.3 you can use the DML error logging features only for the mappings which runs
    in ROW based mode.
    But from OWB 10.2.0.3 onwards DML error logging features can be used for SET based mappings also.
    You can refer the following Metalink notes for the same
    1. Note 550036.1 DML Error Logging In OWB 10.2.0.3 And OWB 11g
    2. Note 549845.1 How To Use Data Rules And Error Tables Features In OWB10gR2
    Thanks,
    Sutirtha

  • How to get the row selected in af:inputComboBoxListOfValues

    Hi,
    Am using jdev 11.1.1.2.1.
    Am using af:inputComboBoxListOfValues component , i have made the component based on the " department id" and the display value is " department name".
    In the value change listener i want to get the selected department id but currently am getting only the department name.(using valueChangeEvent.getNewValue().toString())
    So is there any way to get the entire row and get the "department id" using that ??
    Please help.
    Thanks,
    Hari

    Sorry for the confusion, needed to check it out:
    this code should work:
        public void nameValueCangeListener(ValueChangeEvent valueChangeEvent) {
            FacesContext contxt = FacesContext.getCurrentInstance();
            valueChangeEvent.getComponent().processUpdates(contxt); // after this the new row is selected!
            BindingContext lBindingContext = BindingContext.getCurrent();
            BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
            JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("YOUR_LIST_BINDING_NAME");
            Row lFromList = (Row)list.getCurrentRow();
            Object lAttribute = lFromList.getAttribute("YOUR_ATTRIBUTE_YUO_WANT_TO_GET");
        }Timo

  • How to get the Row reference

    Hi All,
    There's a method findRowByRef(Stirng rowReference) in the interface OAApplicationModule.
    I have a ViewObject instance in an application module. That VO instance has many rows in its collection.
    Could anyone tell me if there's a way to make the rowRefernce out of a VO Row so as to pass that reference to the am's method.
    Basically I want to get a String representation of a VO row and that string should fetch the right row back when the findRowByRef is called..
    Thanks
    Raj

    You cant derive SourceReference from the Row. This is just one way relationship.
    OAF stores the row in the Application Module's session (note: its not a j2ee session) as a name-value pair.
    Only those rows which are getting displayed on the screen will have a name value pair in the session.
    Hence you cannot derive the sourceReference from the Row object.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to get the rows in a multiselect table automatically checked?

    Hi,
    I have retrieved all the rows whose job status is 'Manager'. Now i need these rows to be automatically checked when a button is clicked.
    how do i do this?
    Please reply as soon as possible.

    Hi,
    is this a new thread or is it a duplicate of http://forums.oracle.com/forums/thread.jspa?messageID=2339633
    Frank

  • How to get the row count of a Table DATA?

    Hi,
      In my Adobe form layout, I have a Table node which is bound to an internal table. Now at runtime, I want to determine the number of rows that the internal table has, i.e the row count of the DATA node of the Table. How will I be able to determine the no. of rows of the internal table at runtime using Javascript? I am not being able to find any suitable answer in this forum. Please suggest. Thanks in advance.

    Hi,
    If you bind the interactive form table to the internal table and specify some properties, the table will vary its row size according to the number of data available in the internal table.
    You have to wrap the table in a sub form,  check 'allow page break with contents' and property 'flowed'.
    the table will automatically increase its row size...
    Is this the reason for which you wanted for the row count..?
    If so, this will help you..
    Regards.
    Surya

Maybe you are looking for

  • How to compare 2 files using Oracle,

    Hi, I've a task to compare 2 files of 2 different sets. in Set 1 I've approx 50,000-70,000 files similarly in set 2 also contains same 50,000-70,000 files so I've compare file 1 of set 1 with all files of Set 2 and store the log of mismatch. And repe

  • How to make Microsoft.VSTS.TCM.Steps reportable ?

    Hi, I am creating a report using report builder and I need to drill down report of test execution. I would need Steps counts of test case. For that I need to mark Microsoft.VSTS.TCM.Steps reportable. But when we try to upload that to server, we get e

  • Master Password won't change

    I recently upgraded to OSX 10.4.11. When I try to set my master password to a new one, it will not recognize the change, it remains my old password. What can I do to remedy this?

  • Error While copy flash IOS from Air-AP1262N-x-k9 to tftp

    i want to copy my flast IOS to tftp but when i try to it using tftp following error Reception#copy flash: tftp: Source filename [ap3g1-k9w7-mx.124-25d.JA1]? Address or name of remote host []? 192.168.1.1    Destination filename [ap3g1-k9w7-mx.124-25d

  • 10.4.11 10.5. 10.6?

    Will OS 10.5 install directly over OS 10.4.11 in my 2007 (Core 2 Duo) MacBook? I'm trying to get to Snow Leopard, then (maybe) to Lion?