Subject | Re: [ib-support] Query question |
---|---|
Author | Lucas Franzen |
Post date | 2001-05-31T19:04:04Z |
Nico,
since I know you use IBObjects you can use a TIB_query for that, setting
the MaxRows property to 1.
As SQL you can use sth. like:
SELECT xxxxxxx FROM xxxxxxx
WHERE ItemNo > :qItemNo
ORDER BY ItemNo
Now you can still use your current value, like:
procedure getNextRec;
var currID: Integer;
begin
with mySingleQuery do
begin
currID := FieldByName ( 'ItemNo' ).AsInteger;
ParamByName := currID + 1;
// with RefreshOnParamChange set to TRUE that should be all
end;
end;
for getting the previous one, you'd need a second query (or change the
SQL).
HTH
Luc.
Nico Callewaert schrieb:
since I know you use IBObjects you can use a TIB_query for that, setting
the MaxRows property to 1.
As SQL you can use sth. like:
SELECT xxxxxxx FROM xxxxxxx
WHERE ItemNo > :qItemNo
ORDER BY ItemNo
Now you can still use your current value, like:
procedure getNextRec;
var currID: Integer;
begin
with mySingleQuery do
begin
currID := FieldByName ( 'ItemNo' ).AsInteger;
ParamByName := currID + 1;
// with RefreshOnParamChange set to TRUE that should be all
end;
end;
for getting the previous one, you'd need a second query (or change the
SQL).
HTH
Luc.
Nico Callewaert schrieb:
>
> 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]
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/