Jenny Zhang wrote :

>I have one record in my item table with i_id=1. I wrote a storedprocedure
to
>get i_title for items whose i_id=1, which works fine. But if I add 'stop' 
>command(marked as ===>), it returns junk in my output parameter,
>and error message: 
> SQL state: S1000
> SQL code:  2
> SQL Errortext:
>[SAP AG][LIBSQLOD SO][SAP DB]General error;2 POS(1) stop2.
>My understanding the way stop should work is: while returning the first
>i_title1, print out 'stop2' indicating it has stopped.

>Am I missing something?

>Thanks,
>Jenny

>CREATE DBPROC getItem (OUT count fixed(2,0),
>  OUT i_title1 varchar(60), OUT i_title2 varchar(60),
>  OUT i_title3 varchar(60)) AS
>BEGIN
> set i_title1='';
> set i_title2='';
> set i_title3='';
> set count=0;
> select i_title from tpcw.item where i_id=4;
> if $rc=0 then begin
>   fetch into :i_title1;
> end;
> if $rc=0 then begin
>   set count=count+1;
>   fetch into :i_title2;
> end
>===>else stop(1, 'stop1');
> if $rc=0 then begin
>   set count=count+1;
>   fetch into :i_title3;
> end
>===>else stop(2, 'stop2');
>END;
>;

The stop statement is used to inform a caller of a db-procedure
about an error occurred in that procedure. If you call the <stop statement>,
procedure execution is stopped immediately and the sql code defined 
by the first parameter is returned to the caller. 
In this case no output parameters are returned.
This is exactly what your procedure does.
I think you want to stop the procedure without an error. 
With 7.3.0 Build 21 we will provide the <return statement>  for this
purpose.
Until then just remove the stop statements from your code.

Thomas

---

Thomas Anhaus
SAPDB, SAP Labs Berlin
 
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to