Groups > dBase > dBase SQL Servers > Re: Question about the SUSPEND command




Question about the SUSPEND command

Question about the SUSPEND command
Tue, 11 Mar 2008 10:38:11 -050
Dear friends,
When reading some firebird/Interbase documents, I usually find a sentence like
this: "In a Interbase/Firebird stored procedure you always have to use the
SUSPEND command to return a result".... I do not understand  the reazon, or
maybe I have not found a good explanation for this
.... I have not been using the SUSPEND command in my stored procedures. Could
someone explain why it is necessary to use this command. Why the stored
procedures seem to work ok without this command?
Thanks a lot for any help,
Post Reply
Re: Question about the SUSPEND command
Tue, 11 Mar 2008 12:17:03 -050
Lysander Wrote:

> SUSPEND means something like "take the results you have, wrap them
into a row, and mark them 'ready' for dispatching to the client".

Thanks André, that is a clear explanation. Now, how about the EXIT command
inside a stored procedure?.. how does this SUSPEND command work with it?. If I
understood correctly, I should place a SUSPEND command before the EXIT
command... is that right?

Thanks a lot for your help,
Have a nice day
Jaime Escobal



Post Reply
Re: Question about the SUSPEND command
Tue, 11 Mar 2008 15:02:07 -050
Lysander Wrote:

> EXIT is optional.
> You do not have to use it.
> You can use it, for example, to break out of a loop or out of a cursor 
> (for select a,b,c from t do begin...end)

André, 
Thanks, Yes, I know it... but there are some stored procedures where I use the
EXIT command (because I don't like very big loops)... What I was asking is
whether I have to place a SUSPEND command before an EXIT command in these cases.
Let's say that when de value of the variable nCondition is 1, then I need to
exit the stored procedure.... It would be like this:

  IF ( nCondition = 1 ) THEN
     BEGIN
         SUSPEND;
         EXIT;
     END

So, If I follow the rule, I have to use the SUSPEND command, Otherwise the
SUSPEND  command at the end of the stored procedure would never be executed. is
that right?

Thanks again,
Jaime Escobal











Post Reply
Re: Question about the SUSPEND command
Tue, 11 Mar 2008 15:38:52 -050
I have come across the next statement

"The SUSPEND statement (for stored procedures only), providing the
capability to write stored procedures that output a virtual table in direct
response to a SELECT statement—selectable stored procedures"

So.. What if I'm not receiving from the stored procedure a set of rows, but just
a (memory) value, It seems that this SUSPEND statemen is not necessary in these
cases. Am I right?



Post Reply
Re: Question about the SUSPEND command
Tue, 11 Mar 2008 15:43:39 -050
I think I found the answer (in a text on the internet):

"The SUSPEND statement is not valid in triggers. In executable stored
procedures it has the same effect as an EXIT statement—that is, it terminates
the procedure immediately and any statements following it will never
execute."
Post Reply
<< Previous 1 2 3 Next >>
( Page 1 of 3 )
about | contact