Thread: Aleatory exception

Aleatory exception

From
"Sabin Coanda"
Date:
Hi there,

I have a custom function where I execute a dynamic statement. I trap the 
exceptions, and sometimes I got the following error data:           SQLSTATE = 22P02, SQLERRM = invalid input syntax
forinteger: 
 
"NULL::int4"

For instance I got this for the following statement string:

Please explain what could be the reason ?

TIA,
Sabin 




Re: Aleatory exception

From
"Sabin Coanda"
Date:
Sorry for the previous incomplete text. I add the followings:

For instance I got that exception for the following statement string:

'"my_function"( NULL, ''TEXT1'', NULL::int4, NULL::int4, 5413, '''', 
TIMESTAMP  WITH TIME ZONE ''2007-11-23 10:08:29.904+02'', 19255, 0 )'

What is wrong with this statement ?

Regards,
Sabin




Re: Aleatory exception - found cause

From
"Sabin Coanda"
Date:
Hi,

Finally I found the cause of the problem.

I found deeper inside my calls, a function which has to return an integer 
column from a RECORD rec variable. The rec is assigned with the following 
statement:       EXECUTE 'SELECT pk AS "PK" FROM "my_table" WHERE my_where_clause' 
INTO rec.

When my_where_clause is not fulfilled, rec is initialized somehow with null. 
The exception is rised at the end where I call:       RETURN rec."PK"

Maybe someone can explain this behavior.

TIA,
Sabin