[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference orarep::nomahs::sql

Title:SQL notes
Moderator:NOVA::SMITHI
Created:Wed Aug 27 1986
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3895
Total number of notes:17726

3859.0. "is returned_sqlcode useful in a called proc?" by M5::JAKUHN (RDB: 34% better than real life) Thu Jan 30 1997 17:35

        Hi,
        I have a (dumb) "philosphical" question about GET DIAGNOSTICS and
        returned_sqlcode and its behavior in compound statements.
     
    Ok, when an exception is generated (NO_DUP error ect.) in a compound
    statment in a module , it terminates and the only way you can  trap the
    error from a calling routine is the error status the module itself
    returns. Thats fine, but why have the GET DIAGNOSTIC 1 :x =
    returned_sqlcode if the procedure will just abort on an exception? what
    if you want to do if/then's in the module/procedure and rollback or commit,
    you can't do it within the procedure, you have to do the sqlcode check 
    after the CALL statement. 
     
        thank you.
        jk
     
T.RTitleUserPersonal
Name
DateLines
3859.1NOVA::SMITHIDon't understate or underestimate Rdb!Thu Jan 30 1997 21:4030
The MSP language is based closely on the SQL92 PSM (Persistent Stored Modules)
standard.  The language exists to trap and process exceptions.  It is just
that Rdb has not implemented the exception handler.  This is currently an
architectural restriction which we plan to address eventually.

Currently, GET DIAGNOSTICS can be used to test for success, and various
warnings such as string-truncation, end-of-stream, and null-elimination.

In addition the syntax:

	get diagnostics exception n = returned_sqlcode

allows you get various levels of exception.  We currently only support 1. 
i.e. get diagnostics exception 2 = returned_sqlcode is legal according to ANSI
and ISO SQL.

~when an exception is generated (NO_DUP error ect.) in a compound statment in
~a module

A better method is to avoid the exception:

	if exists (select * from T where a = :val) then
	    signal 'xxxxx'
	else
	    insert into T (...) values (..., :val, ...);
	end if;

cheers,

Ian
3859.2THANKSM5::JAKUHNRDB: 34% better than real lifeSun Feb 02 1997 13:1111
    Thanks very much for your explanation.
    
    jay
    
    +------------------------------------------------------------------------+
    |  "Yes, I think it can be most easily done, out on Rdb 6.1"           
    |                              
    |						-- Bob Dylan
    |						   Rdb 6.1 Revisited
    +------------------------------------------------------------------------+