Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-08-07 : 07:37:05
|
| Carlos writes "Hi, I am using MsSql with Power cobol (www.adtools.com)Is there any way to get next record using select clauseThe main ideia is.In the forms there is a field named "Last Name" with "LAGES" if I use Select field1, field2 from table where name >= @Lastnamesql will bring me up all rows >= LAGES but i want onlythe NEXT record, i the user click again , get next and so onOk, I could use Cursor, but i think will be slower.tksCarlos Lages" |
|
|
dsdeming
479 Posts |
Posted - 2003-08-07 : 07:53:51
|
| You can use SELECT TOP:SELECT TOP 1 field1, field2FROM tableWHERE name >= @LastnameOr you can use SET ROWCOUNT:SET ROWCOUNT 1SELECT field1, field2FROM tableWHERE name >= @LastnameDennis |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-08-07 : 09:07:27
|
quote: Originally posted by dsdeming You can use SELECT TOP:SELECT TOP 1 field1, field2FROM tableWHERE name >= @LastnameOr you can use SET ROWCOUNT:SET ROWCOUNT 1SELECT field1, field2FROM tableWHERE name >= @LastnameDennis
Without an ORDER BY clause there is nothing to say this will always work.Jay White{0} |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-08-07 : 09:18:32
|
quote: Ok, I could use Cursor, but i think will be slower.
in this case, I'd say --- i can't believe I'm doing this -- go ahead and use a cursor.To step through 1 row at a time in a table with a PREV and NEXT button, that's what cursors are designed for so go ahead and use one.I need to take a shower now..- Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-08-07 : 10:12:35
|
quote: Originally posted by jsmith8858
quote: Ok, I could use Cursor, but i think will be slower.
in this case, I'd say --- i can't believe I'm doing this -- go ahead and use a cursor.To step through 1 row at a time in a table with a PREV and NEXT button, that's what cursors are designed for so go ahead and use one.I need to take a shower now..- Jeff
AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHDid you accept money for that?I'd like to know what he's trying to accomplish?Brett8-)SELECT POST=NewId() |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-08-07 : 12:54:34
|
| If the software is .Net enabled, don't bother with cursors. ADO.Net has TONS of methods available to navigate through a set of results. It pretty much does it automatically, you don't have to do a lot to get it to page records.You may want to visit a few .Net sites before you get too involved with the data access layer. They probably won't be COBOL, but you'll still get a lot of background on what .Net can do. I strongly recommend the "In-Depth DataGrid" series on [url]http://www.4guysfromrolla.com/[/url] as a start. |
 |
|
|
|
|
|
|
|