Subject | Re: [ib-support] Re: Problem with FB's SP |
---|---|
Author | Lucas Franzen |
Post date | 2002-11-27T12:07:21Z |
Andrew,
What's the 3rd record in a relational database?
There's nothing like an absolut position of records.
Try this
CREATE PROCEDURE GETVALUE (
TblIndex Varchar(30),
FldIndex Integer
)
RETURNS (FldValue Varchar(255))
AS
declare variable counter Integer;
begin
counter = 0;
FOR SELECT VALUE from DOC_TABLE
WHERE ID_TABLE = :TblIndex
INTO :FldValue
DO BEGIN
COUNTER = COUNTER + 1;
IF ( COUNTER = FldIndex ) THEN
BEGIN
SUSPEND;
EXIT;
END
END
END
Luc.
> To start with, I don't see my message and the replies.I'll send it to you directly, too.
>Now that's what I call complicated.
> I had to look into the group to find them.
>
> > I don't see what you want to achieve with this procedure, please
> tell us
> > more.
> >
>
> Ok, say you have 2 tables:
>
> DOC_TABLE composed of
> 1) ID_Table
> 2) ID_Value
> 3) ID_Document
>
> TABLES composed of
>
> 1) ID_TABLE
> 2) VALUE
>
> ID_VALUE in DOC_TABLE means the number of values in the "subtable"
> represented by ID_TABLE.
> To be clearer, immagine that TABLES has 4 elements with the same
> ID_TABLE and a different VALUE value for each record.
> If I have an ID_VALUE of 3 then I want the third of the 4 records.
What's the 3rd record in a relational database?
There's nothing like an absolut position of records.
>Ok, you want to step through the subtable and take the record you want?
> So, I just want to count the records and fetch the one I want.
Try this
CREATE PROCEDURE GETVALUE (
TblIndex Varchar(30),
FldIndex Integer
)
RETURNS (FldValue Varchar(255))
AS
declare variable counter Integer;
begin
counter = 0;
FOR SELECT VALUE from DOC_TABLE
WHERE ID_TABLE = :TblIndex
INTO :FldValue
DO BEGIN
COUNTER = COUNTER + 1;
IF ( COUNTER = FldIndex ) THEN
BEGIN
SUSPEND;
EXIT;
END
END
END
Luc.