Subject Re: [IBO] select SP & KeyLinks problem
Author Lucas Franzen
Gediminas,

> CREATE PROCEDURE SP_SELECT_TEISEJAI
> RETURNS ( TEISEJO_ID DECIMAL (15, 0), VARDAS VARCHAR (24), PAVARDE
> VARCHAR (24), LYTIS SMALLINT, GIMIMO_DATA DATE, MIESTAS VARCHAR (24),
> SALIS VARCHAR (24))
> AS
> BEGIN
> for select t."Teisejo_ID" , z."Vardas", z."Pavarde", z."Lytis",
> z."Gimimo_data", z."Miestas", z."Salis"
> from TEISEJAI t
> join ZMONES z
> on t."Zmogaus_ID"=z."Zmogaus_ID"
> into :Teisejo_ID, :Vardas, :Pavarde, :Lytis, :Gimimo_data, :Miestas,
> :Salis
> do
> SUSPEND;
> END

> queries SQL code: select * from SP_SELECT_TEISEJAI;
> KeyLinks set to "Teisejo_ID" (as it's a PK in a TEISEJAI table), but
> when try to prepare statement, got warning, that "Blank SQL statement
> is not allowed" (in other cases warning is that invalid KeyLinks
> entry: "Teisejo_ID" - why?), but prepared parameter turns to true.
> When I open dataset, again got several such warnings, but records are
> fetched. Suspect, that select SP is bad, but can't find an error

Always look out that procedures look like:
do begin
SUSPEND;
END
just to avoid a mess up (as soon as you want to enter a second condition
it won't work without).
So do yourself a favour and always work with begin .. end blocks.

The procedure itself looks okay.

But you cannot have KeyLinks to a storedproc, since you're not selecting
directly on the relation (table) but do it via kind of an intermediate
record set (the stoered procedure).

So even if Teisejo.ID is your primary key it is the primary key in the
table not in the stored proc (they don't have primary keys).

Set the keylinks property to autodefine.
And set the RequestLive property to false - this should help.


> If SP raises exception, SUSPEND is needed or not?

What do you mean by that?
If the stored proc raises an exception it will do this regardless if you
have none, one or 10.000 suspends.

Suspend tells the procedure to send the current data out, an exception
will happen if you try (for example) to put a CHAR(30) in a CHAR(5)
output field.


Luc.