cancel
Showing results for 
Search instead for 
Did you mean: 

Raiserror in Procedures called in a select Statement

thomas_duemesnil
Participant
5,002

When I use raiserror in a function or procedure that is used by a select statement the Error Message is not clear to understand.

call sa_make_object('procedure', 'TestProc', 'dbo');
ALTER PROCEDURE "dbo"."TestProc"()
-- Return a Result Set for testing
RESULT ( page_count integer )
BEGIN
    declare local temporary table TestProcTable( table_page_count integer );
    insert  into TestProcTable( table_page_count)
    SELECT  "SYS"."SYSTABLE"."table_page_count"
    FROM    "SYS"."SYSTABLE"
    WHERE   "SYSTABLE".table_type = 'BASE';
    message @@rowcount type info to client;
    -- Generate the Error
    raiserror 20000;
    select table_page_count as page_count from TestProcTable
END;

When the Procedure is called directly the Error Message is clear and the error number 20000 shows directly on the screen (in iSQL).

call "dbo"."TestProc"();

If the call is embedded in a select statement like

select page_count from "dbo"."TestProc"();

the Error message states

There was an error reading the results of the SQL statement.

Behind the Show Details Button I can only read

[Sybase][ODBC Driver][SQL Anywhere]RAISERROR executed:

I used currently ASA 10 and would be interested if newer versions behave differently.

The second error message describes more the symptom of the error instead of getting to the point of the problem.

I would be interested if this is only a problem for me or if other users would also prefer the direct raiserror message for this type of errors.

Perhaps you can give me your thoughts on this. Kind Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

VolkerBarth
Contributor

With v12.0.1.3354 and DBISQL, the behaviour is somewhat different:

  • The message for the call statement looks the same.
  • For the select statement, the error message is similar (adding "The displayed results may be incorrect or incomplete.") but the "Show Details" button reveals the full error message:

thomas_duemesnil
Participant
0 Kudos

Volker. Your responses are incredible fast. To much spare time ? Thanks for your support. I hope you can keep the speed for a long time.