Keep the SQL Scope_Identity() value

I’ve got a process that inserts data into a sql server using the Execute SQL Statement.
I use the Scope_Identity() to get the index value for subsequent inserts to other tables.
Is there a way to get that value back into the process?
I need to know the value several steps later.

Some strange stuff....
The following works in CF7 with the built-in MSSQL or JDBC
1.0 driver.
It also works in CF8 with the built-in MSSQL driver.
insert into myTable (myField)
values ('myValue');
select scope_identity() as myAliasName
If I'm using the JDBC 1.0 driver in CF8, I must wrap the
query with the "SET NOCOUNT" statements for it to work:
SET NOCOUNT OFF;
insert into myTable (myField)
values ('myValue');
select scope_identity() as myAliasName;
SET NOCOUNT ON:
Now, when using the JDBC v1.2 driver in CF8, the SET NOCOUNT
statements do not work. The insert works but the query is
undefined. result.RECORDCOUNT=0.
If you remove the SET NOCOUNT statements, myAliasName is
undefined but the query will be defined and you will get a value
for queryName.GENERATED_KEYS. result.RECORDCOUNT=1. It seems the
alias is ignored.
If you now
remove the select scope_identity() statement so that you
only have the INSERT statement, the query will be undefined but now
the result variable will contain a GENERATED_KEYS value. Also,
RECORDCOUNT=1 even though the query is undefined. (Note: you must
remove the scope_identity() statement. If you just comment it out
with SQL comments, the insert will work but GENTERATED_KEYS will be
undefined and RECORDCOUNT=0).
I'm not sure yet what to make of this info. I'm using CF8 in
development and CF7 in production. If I use the built-in Microsoft
SQL Server driver for both environments, I don't need to make any
changes to my code. That's what I'm doing for the time being.

Similar Messages

  • Html select change to make JSP page forward keeping the exsting field value

    Hello, All,
    I am trying to make the change of a selection box in HTML form to reload the page and populate the second selection box based on the value in the first selection box. The content of the second selection box is from database....
    i used a javascript funtion and called it by the onChange(), the onChange redirect the page to the same page. However all my previous input is lost and the second selection box is not populated based on the first selection box.
    The question is how do I keep the current input and reload the page based on the change of a selection box?
    Please help..
    Thanks..
    Here is the code
    <script language=javascript type="text/javascript">
    function forward(){
    location.href="trdCapDetail.jsp";
    </script>
    <select name=vehicle onChange="forward()">
    <%for(int i = 0; i < Vehicle.getAll().size(); i++){
         Vehicle vehicle = (Vehicle)(Vehicle.getAll().elementAt(i));     
         out.write("<option value=" + vehicle.getKey()+" >" + vehicle.getCode() + "</option>");
    %>

    Ok two things.
    1 - you need to submit the value which was selected.
    2 - you need to repopulate the select box with it.
    1 - you need to submit the value which was selected.
    You do this by either appending the parameter to the url, or calling form.submit().
    <script language=javascript type="text/javascript">
    // either set parameter on url manually
    function forward(control){
    var param = control.value;
    location.href="trdCapDetail.jsp?vehicle=" + param;
    // or submit the form:
    function forward(control){
      control.form.submit();
    <% pageContext.setAttribute("vehicles", Vehicle.getAll() ) ; %>
    <form name="myForm" action="trdCapDetail.jsp"> 
      <select name="vehicle" onchange="forward(this)">
          <c:forEach var="vehicle" items="${vehicles}">
            <option value="<c:out value="${vehicle.key}"/>"> <c:out value="${vehicle.code}"/> </option>
          </c:forEach>
       </select>   
    </form>2: populating the control
    One way is to use javascript again:
    <c:if test="${not empty param.vehicle}">
      <script language="javascript">
        document.myForm.vehicle.value = "<c:out value="${param.vehicle}"/>";
      </script>
      </c:if>
    // or scriptlet code if you must
    <%
    String selectedVehicle = request.getParameter("vehicle");
    if (selectedVehicle != null){  %>
      <script language="javascript">
        document.myForm.vehicle.value = "<%= selectedVehicle%>";
      </script>
    <%
    %>The other way to keep the current input is to generate the string "selected" inside the option tag for the selected item. In your loop, check if the current id equals the submitted id, and print "selected" if it is.
    Hope this helps,
    evnafets

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • How to delete formula from cells and keep the values in Excel VBA

    Hi,
    In my Excel I have 15 columns. In column F which has a formula (INDEX MATCH), it has contains "RECEIVED" and "INTRANSIT". I need to filter the column F for all "RECEIVED" and then remove the formula from cells and
    retain or keep the values that are already in the cells. something tricky and i'm not sure on how to work on this in Excel VBA.
    Below is my initla VBA code:
    I already have the codes on how to filter. kindly please help me on how to do this. thank you in advance.
    Sub test_Click()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rng As Range
    Dim lrow As Long
    Set wb = ThisWorkbook
    Set ws = wb.Sheets("Intransit_")
    Application.ScreenUpdating = False
    ws.AutoFilterMode = False
    With ws
    lrow = .Range("F" & Rows.Count).End(xlUp).Row
    Set rng = .Range("A1:R" & lrow)
    Debug.Print rng.Address
    rng.AutoFilter Field:=6, Criteria1:="RECEIVED"
    End With
    Application.creenUpdting = True
    End Sub

    Solved.
    Sub test_Click()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rng As Range
    Dim lrow As Long
    Dim rRec As Range
    Dim btField As Byte
    Set wb = ThisWorkbook
    Set ws = wb.Sheets("Intransit_")
    btField = 6
    Application.ScreenUpdating = False
    ws.AutoFilterMode = False
    With ws
    lrow = .Range("F" & Rows.Count).End(xlUp).Row
    Set rng = .Range("A1:R" & lrow)
    With rng
    .AutoFilter Field:=btField, Criteria1:="RECEIVED"
    On Error Resume Next
    Set rRec = .SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    End With
    .AutoFilterMode = False
    If Not rRec Is Nothing Then
    With rRec
    .Columns(btField).Value = .Columns(6).Value
    End With
    End If
    End With
    Application.ScreenUpdating = True
    End Sub

  • Filters 'OR' function not passing the values to the sql

    Hi,
    I am facing an issue with the 'OR' function on the filters that are used in the reports.
    The report needs to fetch all the records on the three tables as the user enters the value in the dashboard prompts.
    eg: [   update_dt_A1 is prompted
    and user_name_A1 is prompted ]
    or
    [    update_dt_B1 is prompted
    and user_name_B1 is prompted ]
    or
    [    update_dt_C1 is prompted
    and user_name_C1 is prompted ]
    The values entered in the dashboard prompt gets passed to the filter, but the vaules are not passed over to the SQL that runs on the database, hence the reports shows all values and does not reflect the values entered.
    When the 'OR' function is replaced with 'AND' the values get passed to the SQL.
    Can anyone help on what is the issue on the filters?
    Thanks

    Here is how my Filters are set up
    Vendor Name is Prompted
    AND
    Vendor Number is Prompted
    AND
    [   [Last_update_date_Vendor is prompted
    AND
    User_name_Vendor is prompted]
    OR
    [Last_update_date_Site is prompted
        AND
        User_name_Site is prompted]
    OR
    [Last_update_date_Bank is prompted
        AND
        User_name_Bank is prompted]
    The values from the dashboard prompts gets passed to the filter, but the sql that runs does not take the values in the where clause.

  • How can i pass the Input value to the sql file in the korn shell ??

    Hi,
    How can i pass the Input value to the sql file in the korn shell ??
    I have to pass the 4 different values to the sql file and each time i pass the value it has to generate the txt file for that value like wise it has to generate the 4 files at each run.
    can any one help me out.
    Raja

    Can you please more elaberate., perhaps you should more elaberate.
    sqlplus is a program. you start it from the korn shell. when it's finished, processing control returns to the korn shell. the korn shell and sqlplus do not communicate back and forth.
    so "spool the output from .sql file to some txt file from k shell, while passing the input parameters to the sql file from korn shell" makes no sense.

  • How can i set the "Keep the following number of major versions" to a limit suppose 20 and then disable it from the users so that they cannot change the value?

    I want to set the value of "Keep the following number of major versions" in the versiong settings of a documnet library to a limit say 20 and then disable the option from the users so that they cannot them. Is it possible thorugh some custom coding?

    Hi Moumita10,
    Just curious about that how the custom CSS code works in your environment if put it in the “LstSetng.aspx” page.
    In my environment, it hides the "Keep the following number of major versions" setting in the “LstSetng.aspx”
    page after applying the custom CSS style there.
    Thanks
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to check the sql:query is return null value

    I have use :
    <sql:query var="sql1" dataSource="${db}">
    select col_name from table_name
    where a=<c:out value="${row.test1}"/>
    and b='<c:out value="${row.test2}"/>'
    </sql:query>
    So, how can I check this statement return null value which is no record within this table?

    The Result should never be null but can be empty. You can check if the Result is empty using an if tag and checking the rowCount property:
        <sql:query var="books"
          sql="select * from PUBLIC.books where id = ?" >
          <sql:param value="${bookId}" />
        </sql:query>
         <c:if test="${books.rowCount > 0}">
         </c:if>http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL7.html#wp84217
    Look for query Tag Result Interface

  • How to pass the bind variable value to the sql statement of the LOV

    Hi,
    I am using Forms 10g builder.
    I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
    For Ex: ( )radio1 ( )radio2
    before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
    Pl any hint is appreciated!
    Thanks
    Reddy

    The variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
    e.g. Select ... From ... Where column = :block.radio_group ...Francois

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Trying to find out the sql for the below 3 values

    HI Experts,
    I am trying to find the sql that can give me the values for the below three values. can some one Help me out getting these ?
    Free buffer waits (%)
    Local write wait (%)
    Latch: cache buffer chains (%)
    Actually these are the metrics which are available in OEM for the DB releases up to 9i. Post 9i releases , these metrics are obsoleted.
    So, trying to find the sql for these and use them as an UDM for the 10g and 11g DB's
    Thanks in Advance.
    Thanks,
    Naveen kumar.

    And is there any why to find using what sql the metrci is formed ?

  • Keeping the values in Request bean across more than 2 pages

    Hi...,
    I have created a Bean with request scope & want to access it across 3 different pages.
    From the 1st page once I submit the values , I do a forward (redirect=no) to the second page where I can print the values . From the 2nd page I then do a forward to the 3rd page (redirect=no) & I loose the values.
    How do I keep the request bean active across multiple pages. But I don't want to make it session as this is a form to enter values & our users might open multiple forms as the same time.
    Regards,
    Praveen

    Hi....Balu,
    We are having a issue when using ajax on top of JSF . Setting the variable hidden is somehow not working.
    Secondly, what is requestMap & where can I find the information.
    Regards,
    Praveen

  • New install of SQL 2014 Std MSDN. Get "The SQL Server product key is not valid. To proceed, re-enter the product key values from the Certificate of Authenticity (COA) or SQL Server packaging."

    Trying to install a new version of SQL 2014 Std 64 or x86. Installing on Windows 8.1Pro 64bit machine.
    I get:
    "TITLE: SQL Server Setup failure.
    SQL Server Setup has encountered the following error:
    The SQL Server product key is not valid. To proceed, re-enter the product key values from the Certificate of Authenticity (COA) or SQL Server packaging.
    Error code 0x858C0017."
    I looked at the summary log and that is the only error.
    I made sure there were no other instances of SQL on this machine. Uninstalled all VS2013 and sql instances just in case. IF there is somewhere to check if a previous version or license is causing the issue, i would be glad to check.
    Any help would be appreciated.

    Hi,
    Please read this thread with similar issue
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bdd94577-515c-49fa-be44-008eacece057/installing-sql-server-2012-on-a-new-vm-error-code-0x858c0017?forum=sqlsetupandupgrade
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles

  • [SQL Server]Violation of PRIMARY KEY constraint 'DeploymentSummary_PK'. Cannot insert duplicate key in object 'dbo.DeploymentSummary'. The duplicate key value is

    I have migrated my SCCm 2007 environment to SCCM 2012 SP1 CU4.
    I noticed in the System Status\Component Status\SMS_STATE_SYSTEM a lot of errors like the one below:
    Microsoft SQL Server reported SQL message 2627, severity 14: [23000][2627][Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of PRIMARY KEY constraint 'DeploymentSummary_PK'. Cannot insert duplicate key in object 'dbo.DeploymentSummary'. The duplicate key value is (1, 0, S0220438, 0). : spUpdateClassi
    Please refer to your Configuration Manager documentation, SQL Server documentation, or the Microsoft Knowledge Base for further troubleshooting information.
    When looking up the deployment ID and recreate the Deployment the problem is solved. But I have 700 packages and don't want to manually do this action on all packages. I think it is related to the migration i did and something went wrong there :-(
    Besides it will retriggers the deployment to the clients which is also not preferred.
    Is there another way to solve this by e.e.g do something directly in the SQL database tables ?

    Hi,
    It is not supported by Microsoft that do something directly in SQL database.
    If you want to do that, you could make a call to CSS.
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How To keep CNiKnob from going directly from the Min axis value to the Max axis value?

    When a user drags the pointer on a CNiKnob with the mouse, he/she is able to drag the pointer directly from the minimum axis value to the maximum axis value.
    This is obviously unacceptable. So is there a way to disable this behavior or a work around?

    Unfortunately, there is not an easy way to do this with CNiKnob. One way you could work around it would be to handle the CNiKnob's OnPointValueChanged event and keep track of the previous value, then detect if the value jumps from the min to the max or vice versa and if it does, set it back.
    If you migrate to .NET in the future, the Measurement Studio Windows Forms .NET Knob control lets you easily configure this and is the default behavior when you add a Knob to your form. For more info, see the documentation for the Knob.InteractionMode property.
    - Elton

Maybe you are looking for

  • Issue in using BIAccelerator with Business Objects WebIntelligence report

    Hi, I am trying to improve performance of Webi Reports on BW queries (with huge data load) with BI Accelerator. When I run one BW query (with millions of records) in Bex 7, am getting data within no time when I used BIA. When I run Webi report on uni

  • Regarding paperlayout in reports.

    hi , how to move and resize the objects in paperlayout in reports.

  • It says "An unknown error has occured" when trying to download apps?

    Just got a new iPod touch 4g from my parents. Trying to download apps and it is saying "An unknown error has occured". Any idea? I am all registered and stuff for app store and such. I have no idea and this *****. Any ideas?

  • Old Space Utilization

    Hello there! Using jstat with -gc flag to analyze our server's health indicates that we are using aroung 1GB of Old Space. But after dumping the heap using jmap. And using a tool (Eclipse Memory Analyzer Tool and Yourkit) both indicates that the heap

  • Why are the demo uits in my local istore 32gig

    As we all know the iphone 6 is available, in the uk in only 16 and 64 gig.  I was in an Apple store in Westfield, London the other day and the units in the store were 32.  I would love one of those.  As you would expect it was too busy to ask someone