Selecting only one row at a time

Hi experts,
i have following doubt regarding selecting rows from a db:
Is there any way of selecting only one row AT A TIME from a dabase just to collect the data in rows instead of in a unique document containing all the rows?
I would like you to ellaborate on this as i need to send only one row to the IE, and then other row, and so on... without throwing any error!
I have seen that there are SELECT SINGLE and SELECT UP TO 1 ROW, but these two methods are only useful when retrieving only one row, and that does not match my requirements. I need to process all the rows but one by one..
I know that we can use the receiver jdbc adapter as if it was a sender by means of its specific datatype, but how to do it row by row??
Hope i had explained well..
Thanks in advance and best regards,
David

Hi kiran,
Yes, my table has 5 not null fields but i am selecting and updating fixes values so i think that I will definetely go for the next solution:
SELECT * FROM t1 WHERE status='0' and ROWNUM<2;
UPDATE t1 SET status='1' WHERE status='0' and ROWNUM<2;
My only concern is if the update will take the same row that the select.... BTW, I think it will
..What do you guys think?
I ve been trying to operate with your proposed queries but i received some errors. Your queries are very interesting but i think that with the above ones i meet my requirements as the status field will be 0 for not processed rows and 1 for precessed ones (and the update will look for the row that meets the same 'where' clause than the select, and then, and only then, it will set status='1').
The only thing i have to care about is what i questioned before.
Thanks a lot and best regards,
David

Similar Messages

  • How to select only one record at a time in ALV

    Hi all,
    I have to use ALV report.  Each record on the report output should have a button (or radio button) which will allow the record to be selected.  My requirement is to select only one record at a time.
    please guide me how to proceed further.
    regards
    manish

    hi
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/sampleCheckBoxProgram
    Regards
    Pavan

  • How to select only one row

    hello,
    i've got a select query which returns a couple of rows.
    now i would like for the query to return only one row (the first match it can find).
    how do i do that?
    thank you!
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second row .
    84A8E46E8C97     9410     20110812
    84A8E46E8C97     9420     20110813
    84A8E46E8C6E     9410     20110816
    84A8E46E8AFA     9400     20110819

    876602 wrote:
    my sample of my data as below , the first and seconde record is equal and i want to display all the colomn for the first row and ignore the second rowThere is no row order in relational database tables. Same query canreturn rows in different order next time you run it unless you specify ORDER BY. Only ORDER BY guarantees order, so when you say first row/second row you must provide ordering criteria.
    SY.

  • Oracle database link to MySQL select only one row

    Hello,
    I have created a connection from the Oracle batabase 11.2 to a MySQL database via database link. The following statement shows, that 35 rows are in the mySQL table:
    SQL>  select count(*) from "main_pages"@MOREWEB;
      COUNT(*)
            35
    But a normal select statement only return 1 row.
    SQL> select "subject" from "main_pages"@MOREWEB;
    subject
    Übersicht: Referenzen
    I am using the mysql-connector-odbc-3.51.30-winx64 driver. A newer version cann't be installed because on Windows Server 2008 R2 I get an error with an missing dll-file. The DataDirect-ODBC-driver is not possible, because we like to use the free MySQL-database an DataDirect only support the enterprise edition.
    I also have tried to limit the HS_OPEN_CURSORS or dont limit the HS_FDS_FETCH_ROWS, but there is no difference in the result. I always get only one row.
    HS Init.ora
    # This is a sample agent init file that contains the HS parameters that are
    # needed for the Database Gateway for ODBC
    # HS init parameters
    HS_FDS_CONNECT_INFO = moreweb
    HS_FDS_TRACE_LEVEL = ON
    HS_FDS_FETCH_ROWS=1
    # Environment variables required for the non-Oracle system
    #set <envvar>=<value>
    HS tracefile
    Oracle Corporation --- MITTWOCH   NOV 05 2014 13:56:22.066
    Heterogeneous Agent Release
    11.2.0.1.0
    Oracle Corporation --- MITTWOCH   NOV 05 2014 13:56:22.066
        Version 11.2.0.1.0
    HOSGIP for "HS_FDS_TRACE_LEVEL" returned "ON"
    HOSGIP for "HS_OPEN_CURSORS" returned "50"
    HOSGIP for "HS_FDS_FETCH_ROWS" returned "1"
    HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536"
    HOSGIP for "HS_NLS_NUMERIC_CHARACTER" returned ".,"
    HOSGIP for "HS_KEEP_REMOTE_COLUMN_SIZE" returned "OFF"
    HOSGIP for "HS_FDS_DELAYED_OPEN" returned "TRUE"
    HOSGIP for "HS_FDS_WORKAROUNDS" returned "0"
    HOSGIP for "HS_FDS_MBCS_TO_GRAPHIC" returned "FALSE"
    HOSGIP for "HS_FDS_GRAPHIC_TO_MBCS" returned "FALSE"
    HOSGIP for "HS_FDS_RECOVERY_ACCOUNT" returned "RECOVER"
    HOSGIP for "HS_FDS_TRANSACTION_LOG" returned "HS_TRANSACTION_LOG"
    HOSGIP for "HS_FDS_TIMESTAMP_MAPPING" returned "DATE"
    HOSGIP for "HS_FDS_DATE_MAPPING" returned "DATE"
    HOSGIP for "HS_FDS_CHARACTER_SEMANTICS" returned "FALSE"
    HOSGIP for "HS_FDS_MAP_NCHAR" returned "TRUE"
    HOSGIP for "HS_FDS_RESULTSET_SUPPORT" returned "FALSE"
    HOSGIP for "HS_FDS_RSET_RETURN_ROWCOUNT" returned "FALSE"
    HOSGIP for "HS_FDS_PROC_IS_FUNC" returned "FALSE"
    HOSGIP for "HS_FDS_REPORT_REAL_AS_DOUBLE" returned "FALSE"
    using mpgw as default value for "HS_FDS_DEFAULT_OWNER"
    HOSGIP for "HS_SQL_HANDLE_STMT_REUSE" returned "FALSE"
    SQL text from hgopars, id=1, len=36 ...
         00: 53454C45 43542043 4F554E54 282A2920  [SELECT COUNT(*) ]
         10: 46524F4D 20606D61 696E5F70 61676573  [FROM `main_pages]
         20: 60204131                             [` A1]
    Deferred open until first fetch.
    Performing delayed open.
    SQL text from hgopars, id=1, len=40 ...
         00: 53454C45 43542041 312E6073 75626A65  [SELECT A1.`subje]
         10: 63746020 46524F4D 20606D61 696E5F70  [ct` FROM `main_p]
         20: 61676573 60204131                    [ages` A1]
    Deferred open until first fetch.
    Performing delayed open.
    Please can help me someone.
    Thanks.
    Bianca

    mxallen wrote:
    Bianca,
    If you log directly into MySQL and issue the same query (select "subject" from "main_pages";) what data is returned?
    I looks to me that you count is the number of rows in the entire table "main_pages"
    while you select is for the data in the "subject" column only.
    This seems to indicate that you have just one row in that subject column.
    Regards,
    Matt
    WHAATT?
    What do you mean by "just one row in that subject column"?
    That makes no sense at all.  A row is a row.  A column is a part of a row.  All rows have all columns, though not all columns of all rows will necessarily have an assigned value.  Lacking a WHERE clause to filter rows, any SELECT should return all rows.

  • I can select only one row in my table why?

    hi.. i have just started cold fusion. i am trying to connect
    my database. its ok. but i can see only one row? why?
    ff4.cfm =>
    <cfquery name = "myFirstSelect" datasource="calisma">
    select * from fuat1
    </cfquery>
    ff5.cfm =>
    <cfinclude template="ff4.cfm">
    <table>
    <cfoutput query="myFirstSelect">
    <tr height="20" onMouseOver="this.bgColor='#colorlist#';"
    onMouseOut="this.bgColor='#colorrow#';" bgcolor="#colorrow#">
    <td>AD</td>
    <td>SOYAD</td>
    <td>NUMBER</td>
    </tr>
    <tr height="20" onMouseOver="this.bgColor='#colorlist#';"
    onMouseOut="this.bgColor='#colorrow#';" bgcolor="#colorrow#">
    <td>#AD#</td>
    <td>#SOYAD#</td>
    <td>#NUMBER#</td>
    </tr>
    </table>
    </cfoutput>
    i can retrieve only one row. Cannot access the second row of
    table. What can I do? What can I reach the second row?
    thankx

    ok i solve this problem thanx

  • Question about selecting only one tree at a time...Please help

    Hi , guys
    does anybody know how to make only one tree selected in an application which shows three trees simultaniously.
    Untill now I can select both trees at a time (the third one is not implemented yet ) This is probably so because the trees are showed in different panels I have no idea....Please give me some hints or ideas.
    I thank you in advance.

    write a TreeSelectionListener which knows all Trees in your application. add the listener to all three Trees. within the valueChanged method, check the events source to evaluate the tree, which fired the event. close all selections of all trees ( method clearSelection() ) except the one, which fired the event.
    regards,
    stefan

  • Selecting only one row from a query

    Hi,
    I am using database version 10.2.0.4.0
    I have 2 tables:
    artist(artistid, artistname, titleid)
    trans(transid, datesold, salesprice, titleid, artistid)
    This is what i used and got the below results.
    SELECT max(worksold) AS mostworksold
    FROM (
    SELECT artistname, COUNT(t.artistid) AS worksold
    FROM table.artist a, table.trans t
    WHERE a.artistid = t.artistid
    GROUP BY artistname
    MOSTWORKSOLD
    12
    However I also want to show the artist name who sold the most work. So i added artist name in the select, but the result came out very different.
    SELECT artistname, max(worksold) AS mostworksold
    FROM (
    SELECT artistname, COUNT(t.artistid) AS worksold
    FROM table.artist a, table.trans t
    WHERE a.artistid = t.artistid
    GROUP BY artistname
    group by artistname;
    ARTISTNAME MOSTWORKSOLD
    John 3
    Mary 4
    Alvin 9
    Trevor 5
    Jess 12
    What should I do to make it show only this?
    ARTISTNAME MOSTWORKSOLD
    Jess 12
    Regards,
    Keith
    Edited by: 963214 on Oct 5, 2012 10:12 AM
    Edited by: 963214 on Oct 5, 2012 10:40 AM

    try this... hope this helps...
    with xx as(
      select '1' as aid,'john' as anm from dual union all
      select '2' as aid,'mary' as anm from dual union all
      select '3' as aid,'alvin' as anm from dual union all
      select '4' as aid,'trevor' as anm from dual union all
      select '5' as aid,'jess' as anm from dual
    ), yy as(
      select '1' aid from dual union all
      select '2' aid from dual union all
      select '2' aid from dual union all
      select '3' aid from dual union all
      select '3' aid from dual union all
      select '3' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '4' aid from dual union all
      select '5' aid from dual
    select x.* from
    (SELECT a.anm as nm, COUNT(t.aid) AS worksold
    FROM xx a, yy t
    WHERE a.aid = t.aid
    GROUP BY anm
    order by worksold desc) x
    where rownum = 1; gives
    trevor     5In 2 ^nd^ table, i've considered only 1 column which is actually used. Rest columns are unessential.
    Ranit B.
    Edited by: ranit B on Oct 6, 2012 12:20 AM

  • Only one row appendable at a time in alv

    I would like to limit only one blank row at a time in my alv grid. Means, if i append a row using the standard "Append Row" Button, the user should not be able to append a second blank row till he fills out the first one.
    Any hints ??
    regards,
    Priyank

    Hi Sascha,
    Thanks for the reply but it does not work.
    i put some code in the ...AFTER event, but it seems it is not executed on clicking the append button. I set a breakpoint there but it did not break.
    any other suggestions?
    my main problem is that when i append multiple rows in the alv and subsequently save the data from this alv grid, somehow one field is getting cleared and not holding the value the user has entered. for example, if i add 5 rows and then put data in these rows and save it, second row shows an initial value for a date field in the table. rest of the rows hold the correct value.  i don't know if it is a webdynpro bug or my mistake...i tried redoing everything but to no avail...same problem everywhere.
    thus i m trying to restrict the user to one row at a time only. it will be ideal if i can somehow solve the original problem. if not, even restricting to one row will be good enough.
    regards,
    Priyank

  • Select event not triggered in table with only one row

    Hi all,
    I am building a BI VC application where query data is displayed in a table. When the user clicks on a table row another query is then triggered and output in a second table. The output from table 1 is linked to the input of query2/table2 with a select event.
    The problem that I am facing is that if there is only one row in table 1, the select event is never triggered. If, however there are two or more rows in the table the select event is triggered and query 2 is executed. I have searched the forums but all I could find on select event problems was how to avoid the initial select event.
    Has anyone else experienced this issue and what is the workaround or is this a bug in Visual Composer? We are on VC 7.0 SP19.
    Cheers,
    Astein Meland

    Thanks Chittya,
    Yes we have considered this option as well. But as we have more than one table linked together we would like to avoid having to manually click several buttons.
    In the end I found Note 1364334 describing bugfixes released in VC 7.0 SP20:
    "Normally, when a Visual Composer table is populated from a data service, the first row is selected by default. However, we have found that if only one data row is returned from the data service, this row is not selected by default and cannot be manually selected by clicking on it either."
    So I think we will just have to upgrade our Portal to the latest support packs to solve this problem.
    Thanks,
    Astein

  • Issue with Selection Listener when the table has only one row

    Hi All ,
    I have developed a table in which I am using Selection Listener to perform some task when any row is selected.
    It is working fine when I have more than 1 row in the table, but when I have only one row in the table , the selection listener do not call the corresponding method in bean.
    I understand that selection event will be raised only when the row is changed, but in the use case when only one row is there, what should be done to make the selection listener work ?
    In the selection listener I have written code to make the selected row as current row , and perform the required task.
    Please suggest a way out for this situation.
    Thanks in advance.

    Hi,
    try removing this attr from table
    selectedRowKeys="#{bindings.xxx_VO1.collectionModel.selectedRow}"

  • Select Single * and Select upto one row

    Hi all,
    Can anybody tell me what is difference between Select single * and select upto one row?
    And which one is better?
    Thanks in advance.......

    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Mainly: to check if entries exist.
    Select Single is the best one compared to UPto one rows.
    Select Single will get the first record from the table which satisfies the given condition.So it will interact once with the database.
    UTO 1 rows will get the list of the records for the given match and iwll show the first record from the list.So it will take time to get the record.
    SELECT SINGLE VBELN from VBAK
    where MATNR = '1M20'.
    ---Thjis will get the first matched record and will display the record
    SELECT VBELN from VBAK
    where MATNR = '1M20' upto 1 rows.
    ---Thjis will get the list of matched records and will display the first record
    The Major difference between Select Single and Select UPTO 1 rows is The Usage Of Buffer for each.
    Select Single will search for all the satisfied data and bring all that data into Buffer and later it will give to that data to the program.
    Select UPTO 1 Rows will end the search after getting the 1st satisfied record and gives that record to the program.
    Thus Select Single will take much processing time when compare with Select UPTO 1 rows.
    Also
    check these threads..
    Difference between Select Single and Selct upto 1 row
    Difference between Select Single and Select upto 1 row
    Difference between select single and select upto one row
    Difference between 'select single *' and 'select upto 1 rows'
    difference between select single and select up to 1 rows
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • SQL Server 2012 Undetected Deadlock in a table with only one row

      We have migrated our SQL 2000 Enterprise Database to SQL 2012 Enterprise few days ago.
      This is our main database, so most of the applications access it.
      The day after the migration, when users started to run tasks, the database access started to experiment a total failure.
      That is, all processes in the SQL 2k12 database were in lock with each other. This is a commom case of deadlock, but the Database Engine was unable to detect it.
      After some research, we found that the applications were trying to access a very simple table with only one row. This table has a number that is restarted every day and is used to number all the transactions made against the system.   So, client
    applications start a new transaction, get the current number, increment it by one and commit the transaction.
      The only solution we found was to kill all user processes in SQL Server every time this situation occurs (no more than 5 minutes when all clients are accessing the database).
      No client application was changed in this migration and this process was working very well for the last 10 years.
      The problem is that SQL 2k12 is unable to handle this situation compared to SQL 2k.
      It seems to occurs with other tables too, but as this is an "entry table" the problem occurs with it first.
      I have searched internet and some suggest some workarounds like using table hints to completely lock the table at the begining of the transaction, but it can't be used to other tables.
      Does anyone have heard this to be a problem with SQL 2k12? Is there any fixes to make SQL 2k12 as good as SQL 2k?

    First off re: "Unfortunatelly, this can't be used in production environment as exclusive table lock would serialize the accesses to tables and there will be other tables that will suffer with this problem."
    This is incorrect. 
    Using a table to generate sequence numbers like this is a bad idea exactly because the access must be serialized.  Since you can't switch to a SEQUENCE object, which is the correct solution, the _entire goal_ of this exercise to find a way to properly
    serialize access to this table.  Using exclusive locking will not be necessary for all the tables; just for the single-row table used for generating sequence values with a cursor.
    I converted the sample program to VB.NET:
    Public Class Form1
    Private mbCancel As Boolean = False
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim soConn As ADODB.Connection
    Dim soRst As ADODB.Recordset
    Dim sdData As Date
    Dim slValue As Long
    Dim slDelay As Long
    'create database vbtest
    'go
    ' CREATE TABLE [dbo].[ControlNumTest](
    ' [UltData] [datetime] NOT NULL,
    ' [UltNum] [int] NOT NULL,
    ' CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    ' [UltData] Asc
    ' )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
    ' ) ON [PRIMARY]
    mbCancel = False
    Do
    ' Configure the Connection object
    soConn = New ADODB.Connection
    With soConn
    .ConnectionString = "Provider=SQLNCLI11;Initial Catalog=vbtest;Data Source=localhost;trusted_connection=yes"
    .IsolationLevel = ADODB.IsolationLevelEnum.adXactCursorStability
    .Mode = ADODB.ConnectModeEnum.adModeReadWrite
    .CursorLocation = ADODB.CursorLocationEnum.adUseServer
    .Open()
    End With
    ' Start a new transaction
    Call soConn.BeginTrans()
    ' Configure the RecordSet object
    soRst = New ADODB.Recordset
    With soRst
    .ActiveConnection = soConn
    .CursorLocation = ADODB.CursorLocationEnum.adUseServer
    .CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly
    .LockType = ADODB.LockTypeEnum.adLockPessimistic
    .Open("SELECT * FROM dbo.ControlNumTest")
    End With
    With soRst
    sdData = .Fields!UltData.Value ' Read the last Date (LOCK INFO 1: See comments bello
    slValue = .Fields!UltNum.Value ' Read the last Number
    If sdData <> Date.Now.Date Then ' Date has changed?
    sdData = Date.Now.Date
    slValue = 1 ' Restart number
    End If
    .Fields!UltData.Value = sdData ' Update data
    .Fields!UltNum.Value = slValue + 1 ' Next number
    End With
    Call soRst.Update()
    Call soRst.Close()
    ' Ends the transaction
    Call soConn.CommitTrans()
    Call soConn.Close()
    soRst = Nothing
    soConn = Nothing
    txtUltNum.Text = slValue + 1 ' Display the last number
    Application.DoEvents()
    slDelay = Int(((Rnd * 250) + 100) / 100) * 100
    System.Threading.Thread.Sleep(slDelay)
    Loop While mbCancel = False
    If mbCancel = True Then
    Call MsgBox("The test was canceled")
    End If
    Exit Sub
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    mbCancel = True
    End Sub
    End Class
    And created the table
    CREATE TABLE [dbo].[ControlNumTest](
    [UltData] [datetime] NOT NULL,
    [UltNum] [int] NOT NULL,
    CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    [UltData] Asc
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
    ) ON [PRIMARY]
    go insert into ControlNumTest values (cast(getdate()as date),1)
    Then ran 3 copies of the program and generated the deadlock:
    <deadlock>
    <victim-list>
    <victimProcess id="processf27b1498" />
    </victim-list>
    <process-list>
    <process id="processf27b1498" taskpriority="0" logused="0" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1970" ownerId="3181" transactionname="implicit_transaction" lasttranstarted="2014-02-14T15:49:31.263" XDES="0xf04da3a8" lockMode="X" schedulerid="4" kpid="9700" status="suspended" spid="51" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="21152" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3181" currentdb="35" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
    <executionStack>
    <frame procname="adhoc" line="1" stmtstart="80" sqlhandle="0x020000008376181f3ad0ea908fe9d8593f2e3ced9882f5c90000000000000000000000000000000000000000">
    UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </frame>
    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
    unknown </frame>
    </executionStack>
    <inputbuf>
    (@Param000004 datetime,@Param000005 int)UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </inputbuf>
    </process>
    <process id="processf6ac9498" taskpriority="0" logused="10000" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1971" schedulerid="5" kpid="30516" status="suspended" spid="55" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="27852" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3182" currentdb="35" lockTimeout="4294967295" clientoption1="671156256" clientoption2="128058">
    <executionStack>
    <frame procname="adhoc" line="1" sqlhandle="0x020000003c6309232ab0edbe0a7790a816a09c4c5ac6f43c0000000000000000000000000000000000000000">
    FETCH API_CURSOR0000000000000001 </frame>
    <frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
    unknown </frame>
    </executionStack>
    <inputbuf>
    FETCH API_CURSOR0000000000000001 </inputbuf>
    </process>
    </process-list>
    <resource-list>
    <keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
    <owner-list>
    <owner id="processf6ac9498" mode="S" />
    <owner id="processf6ac9498" mode="U" requestType="wait" />
    </owner-list>
    <waiter-list>
    <waiter id="processf27b1498" mode="X" requestType="convert" />
    </waiter-list>
    </keylock>
    <keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
    <owner-list>
    <owner id="processf27b1498" mode="U" />
    <owner id="processf27b1498" mode="U" />
    <owner id="processf27b1498" mode="X" requestType="convert" />
    </owner-list>
    <waiter-list>
    <waiter id="processf6ac9498" mode="U" requestType="wait" />
    </waiter-list>
    </keylock>
    </resource-list>
    </deadlock>
    It's the S lock that comes from the cursor read that's the villian here.  U locks are compatible with S locks, so one session gets a U lock and another gets an S lock.  But then the session with an S needs a U, and the session with a U needs an
    X.  Deadlock. 
    I'm not sure what kind of locks were taken by this cursor code on SQL 2000, but on SQL 2012, this code is absolutely broken and should deadlock.
    The right way to fix this code is to add (UPDLOCK,SERIALIZABLE) to the cursor
    .Open("SELECT * FROM dbo.ControlNumTest with (updlock,serializable)")
    So each session reads the table with a restrictive lock, and you don't mix S, U and X locks in this transaction.  This resolves the deadlock, but requires a code change.
    I tried several things that didn't require a code, which did not resolve the deadlock;
    1) setting ALLOW_ROW_LOCKS=OFF ALLOW_PAGE_LOCKS=OFF
    2) SERIALIZABLE isolation level
    3) Switching OleDB providers from SQLOLEDB to SQLNCLI11
    Then I replaced the table with a view containing a lock hint:
    CREATE TABLE [dbo].[ControlNumTest_t](
    [UltData] [datetime] NOT NULL,
    [UltNum] [int] NOT NULL,
    CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
    [UltData] Asc
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
    ) ON [PRIMARY]
    go
    create view ControlNumTest as
    select * from ControlNumTest_t with (tablockx)
    Which, at least in my limited testing, resovlved the deadlock without any client code change.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Diffrence b/w select single & select upto one row

    hi
       wat is the diffrence b/w select single & select upto one row?
    deepak

    Hi,
    Select single has to be used with a where condition that has all the key fields:
    It will always return a unique record(If a match is found).
    Select upto 1 rows would get your the first record if multiple matches are found.
    and select up to has to be end with endselect statements.
    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Mainly: to check if entries exist.
    When you say SELECT SINGLE, it means that you are expecting only one row to be present in the database for the condition you're going to specify in the WHERE clause. so that means, you will have to specify the primary key in your WHERE clause. Otherwise you get a warning.
    SELECT UP TO 1 ROWS is used in cases where you just want to make sure that there is at least one entry in the database table which satisfies your WHERE clause. Generally, it is meant to be used for existence-check.
    You may not want to really use the values returned by the SELECT statement in this case (thought this may not necessarily be so).And in each case the database optimizer may choose a different strategy to retrieve the data.
    Knowing when to use SELECT SINGLE or SELECT ... UP TO 1 ROWS
    A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
    So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?
    If you're considering the statements
    SELECT SINGLE field INTO w_field FROM table.
    and
    SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
    then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
    Why is this ?? The answer is simple.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    http://sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm
    Check these links -
    The specified item was not found.
    diff between select single and up to one row
    diff b/w SECELT SINGLE *   AND SELECT UPTO ONE ROW
    Regards,
    Priyanka.

  • Diff bw select single *  and select upto one row

    hai,
        what is the difference  between select single *  and select upto one row.

    hi,
    ex code
    Report Z_Difference
    Message-id 38
    Line-Size 80
    Line-Count 0
    No Standard Page Heading.
    Start-Of-Selection.
    Data: w_Single type Posnr,
    t_Rows type standard table of Posnr
    initial size 0
    with header line.
    Select single Posnr
    from zDifference
    into w_Single.
    Select Posnr
    into table t_Rows
    from zDifference
    up to 1 rows
    order by Posnr descending.
    Write :/ 'Select single:', w_Single.
    Skip 1.
    Write :/ 'Up to 1 rows :'.
    Loop at t_Rows.
    Write t_Rows.
    EndLoop.
    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not
    using all the primary key fields.
    select single is a construct designed to read database records with primary key. In the absence of the primary key,
    it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key
    supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s)
    you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the
    second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional
    level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause
    If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that
    are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns
    the first record of the result set.
    Mainly: to check if entries exist.
    You can refer to the below link..
    http://www.sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm
    rgds
    anver
    if hlped pls mark points

  • Select single * & Select  * upto one row

    What is the difference between Select single * & Select * upto one row?Performance wise which is a better one?

    Hi,
        According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Mainly: to check if entries exist.
    Select Single
    You need to mention all the key fields of the table.
    No END SELECT required.
    More performance compared to upto 1 row.
    Where as UP to 1 row.
    YOu can use if you do not have all the primiary key fields available.
    END SELECT requeired.
    Since all keys are not passing, possiblities of have other rows which satisfies the condition.
    Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.
    Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.
    The most important thing to remember about the SELECT SINGLE is
    There are several things to remember:
    1) It retrieves only one row
    2) It does not need an ENDSELECT statement
    3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN
    THE WHERE CLAUSE OF THE SELECT STATEMENT
    Regards

Maybe you are looking for

  • Basics of Final cut pro

    Hi, could someone please tell me at what stage do you add imported media you would like to edit. When you create the event, or the project? Is it normal to have multiple projects in one event? will that create any problems?

  • Cant get JTextArea setText  working correctly

    I am developing an app where a user selects rows from a table, and the selections are listed in a textarea. if a user selects a row twice, he deselects that item -- because of this I use setText instead of append (easiest way to display selected rows

  • How to attach documents to BPM workspace from IPM ?

    Hi All, I want to attach a document to BPM workspace, which is uploaded from Oracle IPM. I can create the BPM instance and pass the metadata form IPM to BPM workspace. Passing image URL to one of the field, also possible but i want to attach the docu

  • Questions about Clipping Warnings

    I'm not certain if i'll be able phrase my question correctly or clearly, i'll try my best. Pardon me if it comes across wrong or ignorant. I open a raw file in Camera Raw. I adjust the basic sliders such that the Highlight Clipping Warning arrow is B

  • Problems converting XviD files using Adobe Media Encoder

    hi guys, so i downloaded a trial of adobe premier cs4 to see if it would be any good for editing my videos, im importing media from 2 compact video devices that encode in XviD MPEG-4. I heard that you cant really directly edit XviD and that i should