Subject | Query question |
---|---|
Author | Nico Callewaert |
Post date | 2001-05-31T17:30:40Z |
Hi all,
I have a parameterized query that retrieves just 1 record from the server. Now a user is asking if it is possible to go to the next record with the down arrow of the keyboard and go to the previous record with the up arrow. I don't like to use a SELECT * FROM ... query to accomplish this, because I know it's better to use parameterized queries. My query looks like this : SELECT xxxxxxx FROM xxxxxxx WHERE ItemNo = :qItemNo. The problem now is : how could I know the primary key value of the next record ? The next record is not always : Current record + 1. Because the current ItemNo can be 100 and the next 102. I did it like this : I use a stored procedure with a syntax :
FOR SELECT ItemNo FROM Items
WHERE ItemNo > :pItemNo /* As parameter I use the value of the record on the screen and get the next higher value */
DO
BEGIN
SUSPEND;
EXIT;
END
So only the next value is transferred. Is this the preferred way to to that ?
Many thanks,
Nico Callewaert
[Non-text portions of this message have been removed]
I have a parameterized query that retrieves just 1 record from the server. Now a user is asking if it is possible to go to the next record with the down arrow of the keyboard and go to the previous record with the up arrow. I don't like to use a SELECT * FROM ... query to accomplish this, because I know it's better to use parameterized queries. My query looks like this : SELECT xxxxxxx FROM xxxxxxx WHERE ItemNo = :qItemNo. The problem now is : how could I know the primary key value of the next record ? The next record is not always : Current record + 1. Because the current ItemNo can be 100 and the next 102. I did it like this : I use a stored procedure with a syntax :
FOR SELECT ItemNo FROM Items
WHERE ItemNo > :pItemNo /* As parameter I use the value of the record on the screen and get the next higher value */
DO
BEGIN
SUSPEND;
EXIT;
END
So only the next value is transferred. Is this the preferred way to to that ?
Many thanks,
Nico Callewaert
[Non-text portions of this message have been removed]