Selecting and Updating in SQL 2005

I have a situation where I need to select some records from a table. This select query will run again after a certain amount of time. I dont want the second execution of the query to select the records that were selected in the first run. So, what I want is that as soon as I run the first run (or the subsequent runs) and I get the resultset I need to update a flag (which is a column in that table) for all the entries selected in the result set so that next time I run that query, I wont get the same records again.

hamburger wrote:
I have a situation where I need to select some records from a table. This select query will run again after a certain amount of time. I dont want the second execution of the query to select the records that were selected in the first run. So, what I want is that as soon as I run the first run (or the subsequent runs) and I get the resultset I need to update a flag (which is a column in that table) for all the entries selected in the result set so that next time I run that query, I wont get the same records again.Presumably this is for a process and not a GUI.
Write a stored proc that does the following.
1. Create a transaction.
2. Make a timestamp
3. Update the records that have NOT been previously selected using the timestamp from 2.
4. Select the records using the timestamp.
5. Commit the transaction.
6. Return the selected records - including the timestamp as part of each record.
That last little bit, the timestamp, allows the possibility of logging to a file or back to the database that indicates that a particular block has completed (maybe a status is set.) That way if the process fails there is some way to find the records that were not processed.

Similar Messages

  • Can I use a select and update statement in a single jsp file?

    I want to update the BUY table everytime I would add a SELL transaction.....I want to minus the stocks that I sold to those that Ive bought before.....
    note: I used a seperate table in BUY and SELL transaction
    After I Have added a transaction, I want to update the buy table. This is my problem, can I used both SELECT and UPDATE statement at the same time in a single jsp file for example like this:
    select * from test, test1;
    update test
    set total_shares=total_shares-Stotal;
    where stock_code=Scode AND name_broker=Sbroker;
    Can i have both of these statements in the same jsp file in oder to update the buy table?
    Or can anyone suggest how can process that update?THANKS!
    --------------------

    Can i have both of these statements in the same jsp file in oder to update the buy table?Yes. But wouldn't it have been easier just to try it?

  • JDBC Sender - Different number of records selected and updated.

    Hi people,
    We have a JDBC -> Abap proxy scenario. The JDBC sender is pooling an Oracle database to retrieve data from a table X, each 30 minutes. The select and update statements in jdbc sender are below
    SELECT FIELD1, FIELD2, FIELD3 FROM MY_TABLE WHERE STATUS = 1
    UPDATE MY_TABLE SET STATUS = 2 WHERE STATUS = 1
    Sometimes the message sent to Abap proxy has, for example, 400 records. Looking at runtime workbench, message monitoring, for the same message there is a log like this
    Channel SENDER_JDBC_CHANNEL: Query executed successfully. Start update
    Channel SENDER_JDBC_CHANNEL: 510 row(s) updated successfully
    Someone has already experienced something like this? How can I handle this to guarantee to update only those read records?
    regards.
    roberti

    Hi All,
    Even we are facing the same problem.
    In our scenario, receiver is SAPR3. (IDOC)
    Will this parameter serialization work in our case?
    1. SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM PMBPITS.PITS_UNITY WHERE STATUS = '01' and rownum<200 . 
    2. UPDATE PMBPITS.PITS_UNITY SET STATUS = '02' , SAPTIMESTAMP = sysdate WHERE STATUS = '01' and rownum<200  ( currently the value is rownum < 5 )
    Thanks!!
    Regards
    Gouri

  • Select and update in same instruction

    Can i select and update a column in table by one query only
    I donot want to execute two queries one for updation and one for retrieval
    e.g. instead of UPDATE t1 set val=val+1 and then SELECT val from t1;
    i wanna have a single query (compliant to mysql and ORACLE)
    because when i passa query UPDATE t1 set val=val+1; SELECT val from t1; on the command prompt is is fine but when i do so through jdbc it gives me errror
    please help

    Why would a stored procedure change anything?
    The stored procedure would have the UPDATE ... ; SELECT sequence in it.
    Which results in the same "work" the database has to do, compared to sending the two statements via JDBC.
    The only thing that a stored procedure would save, is the second JDBC call, but I doubt that this makes a big difference (provided this is not done in a loop. Then I'd retrieve the new values in one statement after all the updates have been committed)
    So I would simply do Statement statement = connection.createStatement();
    int rows = statement.executeUpdate("UPDATE ....");
    ResultSet rs = statement.executeQuery("SELECT ... ");
    String val = null;
    if (rs.next()) val = rs.getString(1);
    rs.close();The code for the stored procedure would look very similar to this with the disadvantage that that you have to maintain it for every DBMS that has to be supported.

  • Report error after update to SQL 2005

    We revently updated our database server from SQL 2000 to SQL 2005.  After the update we have a report getting the following error.
    Failed to retrieve data from the database.
    Details: 22018:[Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting the varchar value '96.48' to data type int. [Database Vendor Code: 245]
    The report contains 2 views with one join and worked fine previously.  The field referenced by the error will display fine as long as there are no fields from the other view on the report.  As soon as I add a field from the second view, no data is displayed.  I have not created any conversion to integer within the Crystal report for any field.  Any help getting this to work again would be greatly appreciated.

    Hi,
    What steps did you perform before upgrading? dont update. Try to back-up all your database and restore to SQL Server 2005 manually lets see if it have problems, seems to me a conflict datatypes.
    Regards,
    Clint

  • Select and update with lock exclusive

    Hello Everybody
    In our application we have a table autonum     to handle unique keys for all other tables.
    In Autonum we have a column "SUCHBEGRIFF" char(40) unique KEY and a column "WERT" fixed(10,0).
    Suchbegriff has values like Rechnungsnr,Auftragsnr,Bestellnr ...
    Example:
    Befor inserting a record into table rechnungen we do:
    Select wert from autonun where suchbegriff = "Rechnungsnr" with lock exclusive.
    l_rechnrneu = wert + 1 
    update autonum set wert = ?l_rechnrneu where suchbegriff = "Rechnungsnr"
    commit
    (then l_rechnrneu is used for an insert into rechnungen command)
    This technic works for all tables (250) in our application.
    We have about 400 concurrent users working with maxdb 7.6 via odbc 7.6
    No problems since 2 years!
    Now we start some backgroundjobs from an xp-workstation.
    We have scheduled 5 jobs, starting every 5 minutes, same time.(Same user,same odbc-connection)
    Each job inserts records into a table joblogs and therefore needs a unique JOBLOGNR from autonum.
    Now we run into problems 2 or 3 times a day?
    <Sometimes the backgound jobs are running (waiting?) without inserting a record into joblogs (deadlock?)
    And more worse:
    Sometimes the insert into joblogs failes with "duplicate key" ??
    We don't know where to begin? Maxdb Problem ? Workstation problem?
    Any help welcomed
    Best regards
    Albert

    > >Gosh - that's information overloading at it's best...
    > We call this needed information.
    > What does our SAP-System? We have 1 mandt,60 accounting areas and about 200 werks!
    > Of course SAP uses internal unique keys for all tables, but we configured different "number intervals" for each werks.
    With "information overloading" I was referring to the multiple meanings you encode in just one column (your "rechnungs-no").
    SAP tables do not have this.
    As you wrote, there is "MANDT", "BUKRS", "WERKS" ... and the primary key is defined over all relevant columns.
    There is no primary key column where all the different meanings are concatenated together.
    So there aren't any surrogate keys here (a.k.a. AUTOID) used here - (ok except the infamous DDLOG sequence...).
    > >What do you do, when the value of an invoice has to be changed? Update the primary key of the table?
    > Update rechnungen set amount = xyz,...... where rechnungnr = nnn
    > We never change rechnungsnr,if the invoice was wrong we produce a credit for it and then write a new invoice
    So, you could use a sequence here instead as well.
    > > We don't use rollback when fetching logids from autonum.
    > >So what do you do, when connection fails, the database crashes or the client application hits an error?
    > >You use rollback. There is no way to avoid it.
    > >Your application gets a "duplicate key" error - the database performs a rollback of your last action. What does your application do then? Commit?
    > Sorry, i meant that we do not do rollbacks over  2 or 3 inserts or updates in different tables.
    > SQL-Command,On error = messagebox,errorlog,quit
    You don't handle the fetching of the new number in the same transaction as the actual insert of your application data in the same transaction?
    > >What isolation level do you use?
    > We use DATABASE ISOLATION LEVEL 0
    Hmm... did you read the documentation on SQL Locks?
    [Internals Course - SQL Locks|http://maxdb.sap.com/training/internals_7.6/locking_EN_76.pdf] :
    "Isolation level 0 does not offer any protection against access anomalies."
    Basically it might have happened that the same number is read twice.
    Perhaps the application is not always requiring locks when reading data from this table?
    > After connecting to the database via odbc we do
    > =SQLSETPROP(verbindungsnr,"Transactions",2)
    > 2 = Transaction processing is handled manually through SQLCOMMIT( ) and SQLROLLBACK( ). Read/write.
    > =SQLSETPROP(verbindungsnr,"DisconnectRollback",.T.)
    >
    >
    > So normal select commands are fired without a following commit.
    > Insert and update commands are fired with a following commit command.
    > Selects from autonum are fired with "look exclusive"
    Please be more detailed here.
    What is the exact sequence of actions here?
    1. Fetch number from number table and update number table.
    2. COMMIT
    3. Insert new application data with the just fetched number.
    4. COMMIT
    or
    1. Fetch number from number table and update number table.
    2. Insert new application data with the just fetched number.
    3. COMMIT
    And what does your application do with its data when a rollback occurs?
    Is it guaranteed that all variables are reset?
    > Nevertheless you dislike our design, do you think it would be better (quicker,safer...) to use an internal databases procedure to get
    > the next speaking number for a given "suchbegriff" from our autonum table? (no translation of the sql-command every time)
    No, currently we don't know what is causing the problem, so we cannot tell whether such a change would help. In fact, right now it would make things more complicated because we would less understand, what's happening here.
    Concerning your design: it's not about "liking" or "not liking it".
    I just pointed out some problems that result from the design as it is.
    > select   wert into :neuerwert FROM "BWPROGI"."AUTONUM"  WHERE upper(suchbegriff)     = upper(:suchkey) WITH LOCK EXCLUSIVE;
    > update  "BWPROGI"."AUTONUM" set wert = wert + 1 WHERE upper(suchbegriff)     = upper(:suchkey) ;
    > SET neuerwert = neuerwert + 1;
    > end;
    1. The WHERE clause UPPER(suchbegriff) = UPPER(...) is the best way to disable the efficient use of any index structure. Better make sure that your data is in the right format in the table when you enter it and then look it up without the UPPER() conversion. 
    2. I wouldn't perform the increment two times.
    Get the current value into your variable, increment this variable, set the current value in the table to the variable.
    > A char(10) return value would be nice and i don't know wether this would be the quicker way.
    Why should it? You would have to convert it first - that's additional work.
    Anyhow, to move ahead with your duplicate keys problem, you may perform a vtrace with the "stop on error" option.
    As your error is a duplicate key on a primary key constraint you should set "stop on error" to the error code "200".
    The next time your application hits the error, the vtrace automatically stops and we could examine what happened before.
    See [MaxDB database trace|https://wiki.sdn.sap.com/wiki/x/2yg] for details on how to activate the trace.
    When the error occurs next time and you caught it in the vtrace we can take a look at it.
    regards,
    Lars

  • Controversy between SELECT and UPDATE

    I have 2 queries one with SELECT and the other with UPDATE. The WHERE clause in both the queries are exactly same. When I do the SELECT I am getting a row and when I do the UPDATE I am not getting any rows. The following are the queries and descriptions of the tables involved. I tried executing these 2 queries many times and no difference.
    SQL&gt; SELECT * FROM Fraud_30_Day_Summ S1
    2 WHERE s1.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
    3 AND s1.Fraud_Category_Cd = 'CPI'
    4 AND s1.On_Off_Net_Ind = 'Y'
    5 AND s1.Threshold_ind = 'Y'
    6 AND (s1.Icon_Ind IS NULL OR s1.Icon_Ind &lt;&gt; 'N' )
    7 AND (
    8 ( s1.Call_Cnt * .5 &lt;=
    9 ( SELECT SUM(s2.Call_Cnt)
    10 FROM Fraud_CPCS_Call_Detail s2
    11 WHERE s2.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
    12 AND s2.Component_Group_Cd = s1.Component_Group_Cd
    13 AND s2.Component_Grp_Val = s1.Component_Grp_Val
    14 AND s2.Call_type_cd = s1.Call_type_cd
    15 AND s2.On_Off_Net_Ind = 'Y'
    16 AND EXISTS
    17 (
    18 SELECT s3.ROWID
    19 FROM Threshold_Element_Value s3
    20 WHERE s3.Threshold_Element_Val = s2.icon_country_cd
    21 AND s3.Threshold_Id = '405') ) ) );
    DISCONNECT_DT FRAUD_CATEGORY_CD ON_OFF_NET_IND COMPONENT_GRP_VAL COMPONENT_GROUP_CD CALL_CNT CALL_DUR_VAL ICON_IND CELLULAR_IND CUST_SPECIFIC_IND THRESHOLD_IND LAST_USED_IND CALL_TYPE_CD
    10/1/2008 CPI Y 234546575678 CP 3 2474 Y
    Y C
    SQL&gt; Update Fraud_30_Day_Summ s1 SET s1.Icon_Ind = 'N'
    2 WHERE s1.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
    3 AND s1.Fraud_Category_Cd = 'CPI'
    4 AND s1.On_Off_Net_Ind = 'Y'
    5 AND s1.Threshold_ind = 'Y'
    6 AND (s1.Icon_Ind IS NULL OR s1.Icon_Ind &lt;&gt; 'N' )
    7 AND (
    8 ( s1.Call_Cnt * .5 &lt;=
    9 ( SELECT SUM(s2.Call_Cnt)
    10 FROM Fraud_CPCS_Call_Detail s2
    11 WHERE s2.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
    12 AND s2.Component_Group_Cd = s1.Component_Group_Cd
    13 AND s2.Component_Grp_Val = s1.Component_Grp_Val
    14 AND s2.Call_type_cd = s1.Call_type_cd
    15 AND s2.On_Off_Net_Ind = 'Y'
    16 AND EXISTS
    17 (
    18 SELECT s3.ROWID
    19 FROM Threshold_Element_Value s3
    20 WHERE s3.Threshold_Element_Val = s2.icon_country_cd
    21 AND s3.Threshold_Id = '405') ) ) );
    0 rows updated.
    DESC FRAUDCPCS_CALL_DETAIL_
    RECORD_ID{                                                                                         }NUMBER(5,0)
    ORIG_BILL_FILE_ID{                                      }NUMBER(10,0)
    RECORD_SEQ {                                            }NUMBER(10,0)
    BILLING_CYCL_ID {                                        }NUMBER(5,0)
    CUSTOMER_ACCT_ID {                                    } NUMBER(10,0)
    OCCR_NO {                                                    }NUMBER(10,0)
    FRAUD_CATEGORY_CD{    } NOT NULL{        } VARCHAR2(3)
    CALL_TYPE_CD {                } NOT NULL {        } VARCHAR2(1)
    ORIG_TERM_NPA_NXX_CD{                            } VARCHAR2(6)
    COMPONENT_GROUP_CD {    } NOT NULL{    } VARCHAR2(2)
    COMPONENT_GRP_VAL{        } NOT NULL{    } VARCHAR2(26)
    ORIGINATING_DT {        } NOT NULL{    } DATE
    ORIGINATING_TIME_VAL{        } NOT NULL {    } NUMBER(10,0)
    DISCONNECT_DT {                    } NOT NULL{    } DATE
    DISCONNECT_TIME_VAL {        } NOT NULL{    } NUMBER(10,0)
    ORIG_STATE_CD {                                            } VARCHAR2(2)
    TERM_STATE_CD {                                            } VARCHAR2(2)
    CALL_DUR_VAL {                    } NOT NULL {        } FLOAT(12)
    PRCMP_ID{                                                        } NUMBER(5,0)
    ORIG_COUNTRY_CD{                                        } VARCHAR2(3)
    TERM_COUNTRY_CD {                                    } VARCHAR2(3)
    ORIG_CITY_CD {                                                } VARCHAR2(15)
    TERM_CITY_CD {                                                } VARCHAR2(15)
    GSA_ORIG_JURISD_ID{                                      } NUMBER(10,0)
    GSA_TERM_JURISD_ID {                                    } NUMBER(10,0)
    USAGE_CATEGORY_CD{                                    } VARCHAR2(8)
    CALLING_NO {                                                     }VARCHAR2(16)
    CALLED_NO {                                                    } VARCHAR2(20)
    USAGE_TYP{                                                    } VARCHAR2(35)
    INTERNATIONAL_CALL_TYP{                            } VARCHAR2(20)
    VOICE_MAIL_IND {                                            } VARCHAR2(1)
    DIR_ASST_IND {                                                } VARCHAR2(1)
    CALL_FWD_IND {                                                } VARCHAR2(1)
    ROAMING_IND{                                                } VARCHAR2(1)
    CALL_TO_OHSA_IND {                                    }VARCHAR2(1)
    MOBILE_TO_MOBILE_IND {                                }VARCHAR2(1)
    ON_OFF_NET_IND {            } NOT NULL{            } VARCHAR2(1)
    DESTINATION_TXT {                                          } VARCHAR2(14)
    CALL_CNT {                                                      } FLOAT(12)
    ICON_COUNTRY_CD{                                        } VARCHAR2(3)
    DESC FRAUD30_DAY_SUMM_
    DISCONNECT_DT {            } NOT NULL{                    } DATE
    FRAUD_CATEGORY_CD {    } NOT NULL{                } VARCHAR2(3)
    ON_OFF_NET_IND {            } NOT NULL{                } VARCHAR2(1)
    COMPONENT_GRP_VAL {                                    } VARCHAR2(26)
    COMPONENT_GROUP_CD {    } NOT NULL {            } VARCHAR2(2)
    CALL_CNT {                            } NOT NULL {            }FLOAT(12)
    CALL_DUR_VAL{                    } NOT NULL{                } FLOAT(12)
    ICON_IND {                                                              } VARCHAR2(1)
    CELLULAR_IND{                                                        } VARCHAR2(1)
    CUST_SPECIFIC_IND{                                            } VARCHAR2(1)
    THRESHOLD_IND {                                                } VARCHAR2(1)
    LAST_USED_IND {                                                }VARCHAR2(1)
    CALL_TYPE_CD {                    }NOT NULL{            } VARCHAR2(1)
    DESC THRESHOLDELEMENT_VALUE_
    THRESHOLD_ID {                        } NOT NULL {        } NUMBER(5,0)
    THRESHOLD_ELEMENT_VAL {    } NOT NULL {        }VARCHAR2(18)
    Edited by: user10568649 on Nov 8, 2008 11:27 AM
    Edited by: user10568649 on Nov 8, 2008 12:44 PM

    Would it be possible to edit your post to remove all the extra carriage returns? Having two blank lines between every line of code & results is making it somewhat difficult to follow.
    While you are editing the post, it would also be helpful if you could enclose the code & results in the \ tag in order to preserve white space.
    Justin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Combine select and update into single statement,without bind-variable

    I have a problem, that I think is not possible to solve the way I want to, but I just wanted to check before leaving the idea...
    I am looking for a way to combine the select and the update statement into one single statement. This is what I wan't to achive: select some data, and update the data selected before returning them.
    On this site http://www.psoug.org/reference/update.html I see that the following are possible:
    var bnd1 NUMBER
    var bnd2 VARCHAR2(30)
    var bnd3 NUMBER
    UPDATE employees
    SET job_id ='SA_MAN', salary = salary + 1000,
    department_id = 140
    WHERE last_name = 'Jones'
    RETURNING salary*0.25, last_name, department_id
    INTO :bnd1, :bnd2, :bnd3;
    I need to have this as a single statement, and cannot use bind-variables. So I was hoping that something like this could be possible:
    UPDATE customer c
    SET c.HAS_CREDIT ='1'
    WHERE c.HAS_CREDIT = '0'
    RETURNING c.CUSTOMER_NO, c.FIRSTNAME, c.LASTNAME
    where c.HAS_CREDIT = '1'
    But this doesn't compile, complaining of missing into (ORA-00925: missing INTO keyword). And even though I would like this to be possible because this would solve my current problem, I think it would be very confusing. For instance; would the where clause of the returning part be operating after the update or before?
    Any comments or suggestions on how to get it work in a single statement, or should I just leave this path straight away?

    Hi,
    RETURNING only works with bind variables, see
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm#sthref3006
    The real problem is that the form of RETURNING clause with bind variables is only valid for single row update or insert statements.
    To update (or insert) multiple rows and return the data, you will need to use
    RETURNING BULK COLLECT INTO clause. See
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2236
    Cheers,
    Colin

  • Select and update rownum sender jdbc

    Dear all
    i am using PI 7.31 sender jdbc adapter.
    table(TB_AA)  has 10000 row with pi_stat = 'R'   and then  sender jdbc adapter tried  10 row  in using rownum  every  120 second and update same rownum
    but  result of select query and udpate query  were different.  not same record update for selecting data.
    co_cd,  memid  is PK.
    select co_cd , mem_id,  reg_n  FROM TB_AA  where PI_STAT = 'R' AND rownum <= 10
    update  TB_AA  set  PI_STAT = 'S', where  PI_STAT = 'R' and rownum <= 10
    query is wrong?  ,  what is correct update query with several PK ?

    Hi Arten Solohin.
    co_cd,  memid  is Primary Key.
    select co_cd , mem_id,  reg_n  FROM TB_AA  where PI_STAT = 'R' AND rownum <= 10
    update  TB_AA  set  PI_STAT = 'S', where  PI_STAT = 'R' and rownum <= 10
    could you make your query with above my query ?  because i am confusing ORDER BY <your unique id_field>   AND LINE_ID ....
    will be highly appreciated  in advance
    thanks you very much.

  • Select and update leave request data - oracle !!

    Dears,
    We have a very important presentation here to one of our stakeholders and he is interested to see how to submit and update leave requests using Adobe LiveCycle Workspace.
    I have a simple PDF form where the user can choose to submit new leave or update an existing one, if the user choses to update an existing leave he will enter the leave start date and press on a button to retrieve this leave information form the database ( select * from leaves where leave_date=’the entered date’ and requestor=’requestor name’) as requestor name and entered date are variables in the PDF, And then he can update the start date or leave duration and submit his request after updating this record in the database.
    Will you please help me how to do that knowing my PDF contains a digital signature and the data saved in a document variable?
    The connection with oracle created by updating the adobe-ds.xml file in “C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy” and deploying the ojdbc14.jar in “C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\lib”.
    Database is oracle10.2.0.1.0
    Adobe LiveCycle Workbench ES2
    Version: 9.5.0.0.20100908.1.247189
    Many thanks in advanced,
    Mohammed Al-Mosleh

    I solved updating single row issue and retrieving single row from data base issue too ...
    I need an example, that shows us how to retrieve multiple records from a database, we did this, and DISPLAY, we couldn't, the results in a table within a pdf.
    the data stored in XML after using Query Multi Rows in XML Activity in Workbench...
    Can any one Help me how to Disply this XML in a table ??

  • Combine and simplify SELECT and UPDATE sql query

    foreach (BidList t in bidList)
    query = "SELECT operator_id, plot_id, status FROM booking " +
    "WHERE status='open' AND postcode='" + _plot + "' AND operator_id='0'" +
    "ORDER BY datetime ASC;" +
    "UPDATE booking SET operator_id='" + t.OperatorId + "', status='allocated' " +
    "WHERE (plot_id=" + t.PlotId + " AND operator_id='0' AND status='open') LIMIT 1;";
    dbObject.InsertBooking(query);
    I am cleaning up my code, and came across the above SQL query. Before I make use of SQL parameters, I wanted to ask if it is possible to combine them, and if so, how?

    Consider making a single long query using ‘;’ as a separator:
        query = "";
        foreach (BidList t in bidList)
            query += "UPDATE . . . ; ";
        dbObject.InsertBooking(query);
    Use StringBuilder for more improvements.

  • SQL 2005 x64 poor performance after migration from SQL 2005 x86

    Recently We've migrated SQL 2005 x86 SP1 Enterprise running on Windows 2003 Enterprise to new hardware where is running Windows 2008 SP2 and SQL 2005 x64 SP4 with CU3.
    In the work day, there are sometime SQL excpetions like this below. On other hand i can also tell that we already found some queries which has some inner joins and where clauses on nvarchar fileds, because of the nature of application. Such a query
    is running for about 11 seconds on old SQL server, and about 6 minutes on new SQL server. My main question if is this possible just with a change to new architecture of SQL and more last patches and updates for SQL 2005. Is there any way how to get
    this queries running faster, without rewritng them with new ones? Is this also possible this could be also cause for SQL exceptions, which we are facing on SQL server?
    About new hardware, for now we can't find it something wrong. There is basic configuration:
    Cisco UCS  C220 M3S (1U server)
    32GB RAM
    Intel(R)Xeon® CPU [email protected], 6 core
    Disk system: 4xSAS 300GB in RAID5 (OS and DATA) and 2xSATA 1TB in RAID1 (SQL backup)
    RAID controller: LSI MegaRAID SAS 9271-8i (with latest driver and firmware)
    Part of log of dump file:
    2014-05-09 08:30:07.08 spid86      Error: 17311, Severity: 16, State: 1.
    2014-05-09 08:30:07.08 spid86      SQL Server is terminating because of fatal exception c0000264. This error may be caused by an unhandled Win32 or C++ exception, or by an access violation encountered during exception handling.
    Check the SQL error log for any related stack dumps or messages. This exception forces SQL Server to shutdown. To recover from this error, restart the server (unless SQLAgent is configured to auto restart).
    2014-05-09 08:30:07.08 spid86      Using 'dbghelp.dll' version '4.0.5'
    2014-05-09 08:30:07.08 spid86      **Dump thread - spid = 86, PSS = 0x0000000132A67ED0, EC = 0x0000000132A67EE0
    2014-05-09 08:30:07.08 spid86      ***Stack Dump being sent to D:\MSSQL.1\MSSQL\LOG\SQLDump0087.txt
    2014-05-09 08:30:07.08 spid86      * *******************************************************************************
    2014-05-09 08:30:07.08 spid86      *
    Thanks for any help,
    Matjaž

    >Is there any way how to get this queries running faster, without rewriting them with new ones?
    You need to perform basic performance tuning steps in the new environment.
    Software optimization:
    http://www.sqlusa.com/articles/query-optimization/
    Disk optimization:
    http://www.sqlusa.com/bestpractices/configureharddisk/
    Memory optimization:
    http://www.sqlusa.com/bestpractices/memory-configuration/
    REBUILD INDEXES, eliminate missing indexes & UPDATE STATISTICS.
    If there is still a problem, look in Activity Monitor for expensive queries. Optimize them. As a general rule, you don't want to have expensive queries in RDBMS.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Install Mini SAP and SQL 2005

    Hi there,
    I hope someone can help me with the question.
    I’ve bought the ABAP objects book called “An Introduction to Programming SAP Applications” from Horst Keller and Sascha Kruger (black color). There are 2 CD's to install the application Mini Basis SAP and work with the ABAP workbench. I was able to install that on a pc Win2000 and it worked and that pc had no sql server/database installed
    But I've now another pc Windows XP and has has SQL 2005 Dev edition. I need to keep this.
    My problem is when I try to install the Mini Basis I get error. Is it because of I’ve already installed the Ms SQL 2005 dev edition? 
    I’m using Windows XP prof edition. How can I install on XP pro this software on my pc keeping the SQL 2005?
    I have tried resume_setup.bat and also enabled remote_services for the registry update. no hope.
    Can someone please help?
    Cheers, mesut
    Book reference: ISBN 0-201-75080-5  (SAP Press)

    Hi Sravan,
    That's exactly what I did. I bought the book and I try install on Win XP pro with SQL 2005 dev edition pre-installed.
    I'm in possession of the Mini SAP, I own the book. I also looked at the site you suggested
    http://www.sap-img.com/mini-sap.htm.
    It seems to be I should be able to install on WIN XP pro due to the site above.
    This is how a work
    1) CD 1 starts with home page
    2) I choose REsume (because I have already pre-installed the SQL 2005)
    3) Setup starts
    4) asks me which directory, it proposes C:\MBS  -- I accept
    5) It asks me where is the DATA and the KERNEL CD --- it proposes D: ---I accept
    6) at the mean time I click on switch view and I see the logs and this is finally I get (I just copy/paste below the errors no the whole log)
    So I don't know how to proceed further. I contacted SAP and they propose me this forums.
    Could you please advice?
    thanks mesut
    Error: DBCOMMONDBENV_IND_MSS SubstituteVariables 2 416
           The function RegOpenKeyEx with the parameterlist    
           (Software\Microsoft\MSSQLServer\MSSQLServer\Parameters) returned with error code 2 and error text:
            The system cannot find the file specified.
    Error: DBCOMMONDBENV_IND_MSS InstallationDo 2 416
          Phase failed.
    Error: Main {} 2 416
           Installation aborted.

  • Concatenate date time and update SQL datetime field

    I have a form that captures date and time in 2 separate fields data and time.
    I need to combine these fileds and UPDATE a SQL database (datetime field)
    The date field is passed like this  DSDATE={ts '2013-11-18 00:00:00'}
    The time field is passed like this   TIME_IN1=14:05
    How do I concatenate DSDATE AND TIME_IN1 so that I can insert like this 2013-11-18 14:05:00.000 ?

    The easiest way may be the best. You judge.
    <cfset DSDATE = parsedatetime('2013-11-18')>
    <cfset  TIME_IN1="14:05">
    <cfset yr = year(DSDATE)>
    <cfset mnth = month(DSDATE)>
    <cfset d = day(DSDATE)>
    <cfset hr = listGetAt(TIME_IN1,1,":")>
    <cfset mn = listGetAt(TIME_IN1,2,":")>
    <cfset datetime=createdatetime(yr,mnth,d,hr,mn,0)>
    <cfoutput>#datetime#</cfoutput>

  • How to execute query (select or update) without VO and EO

    hi
    i want to make simple select and updates in my processformrequest just to make some verifications in the database. how can i do it without using any view object and entity object ?
    thanks
    Dan

    You can use createPreparedStatement, createStatement api in OADBTransaction to issue a select statement. But as updated by Suvarna, shooting direct queries to DB is not recommended.

Maybe you are looking for

  • Ctl+0 Doesn't Make Image go full screen

    CS5 in Win7, 64 Bit, 12Gb RAM, Eizo Monitor CG222W. It seems like CS5 can't find the whole workspace to expand the image.  Had worked fine on CS4.  Anyone know what's wrong?  Thanks! Bob

  • Sub total text in ALV report

    Hi, I need to do subtotalling in my program using ALV. I am getting the subtotal value in ALV list display , but not getting the text for subtotalling. matnr               werks                       stock 154                  1001                   

  • Sunlink X.25 9.0 vs. Solstice X.25 9.2

    Hi there, We have some problems with installing Sunlink 9.0 on a Solaris 8 system which has no zsh device... It seems that Sunlink 9.0 only supports zsh devices and during installation, the x25 device fails to install. Sunlink 9.0 doesn't support the

  • Is there any advantage to use database helper class

    Is there any advantage to use database helper class ( e.g. database.bookDB in Duke's bookstore)in servlet design? What if I setup a DB connection for every servlet?

  • Why won't my movie widget work

    I have a new computer running mac OS 10.7 lion. when I tried o access the movie widget it is black. how can I fix it anfd get it to work?