Talk About Network

Google





Data Bases > IBM DB2 > Re: How to chec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 9 Topic 9091 of 9564
Post > Topic >>

Re: How to check SQLCODE in trigger

by "lenygold via DBMonster.com" <u41482@[EMAIL PROTECTED] > Jul 16, 2008 at 04:40 PM

Thank you Serge for  promt responce.
But i am using this trigger for screen edit.
When edit is passed (sqlcode = 0 after insert) row is deleted from the
table.
But if i have  several DATES on the screen -180 OR -181 does not tell me
what
date field is wrong.
Message generated by trigger: '292 INVALID HIREDATE' tells me what 
field on the screen is invalid and 292 is  the HIREDATE screen position
which
will be used in SEND MAP CICS statement ,to position cusrsor in invalid
field.

Using triggers for edit saved us 70% coding time and also made available
all best DB2 features insted 1000's  lines of COBOL coding.    
So if i can not use triggers to overlay system generated error message,
how can I resolve this issue. May be Constraint on data fields will help?
Thahk You again Serge. I learn a lot new things on this board.       


Date is invalid.    

Serge Rielau wrote:
>Hmm, OK perhaps I am a bit slow these days, but I think I start to get 
>what you are doing... and it won't work...
>
>When you insert into a DATE column. DB2 will aggressively(!) ensure the 
>date is sane. That is this error is being raised before your trigger is 
>being called.
>Now clearly DB2 will not allow bad dates into the table (which is what 
>you rely on with your AFTER trigger.
>But DB2 will also not allow bad dates to flow through it's runtime code.
>Thus even a BEFORE trigger will do you no good.
>
>There are three ways to do what you want to do on the database side:
>* Use an instead of trigger on a view where the view maps the DATe in
>   the table to a VARCHAR and the INSTEAD OF trigger maps it back
>   That is a horrible idea
>* Store a string in the database instead of a date.
>   Preferably in a yyyymmdd format, so you can do comparisons on it.
>   That is slightly less horrid
>* Use a stored procedure instead of an INSERT to drive your
>   modification.
>   There are users who do this on principle.
>   "No SQL other than a CALL in my app"
>   This way your proc can do everything it wants to and you
>   insert once you are satisfied.
>
>Now, all this can be avoided if you ****ft your thinking:
>DB2 gave you a perfectly good error message saying exactly what you 
>wanted to say. Why not use it? Let the application catch the -181 (or 
>the associated SQLSTATE which is likely ANSI Standard)
>
>Cheers
>Serge

-- 
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums.aspx/ibm-db2/200807/1
 




 9 Posts in Topic:
How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-15 15:10:46 
Re: How to check SQLCODE in trigger
Serge Rielau <srielau@  2008-07-15 14:35:48 
Re: How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-15 23:36:21 
Re: How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-15 23:47:11 
Re: How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-16 00:33:51 
Re: How to check SQLCODE in trigger
Serge Rielau <srielau@  2008-07-15 21:33:12 
Re: How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-16 02:29:09 
Re: How to check SQLCODE in trigger
Serge Rielau <srielau@  2008-07-16 08:14:26 
Re: How to check SQLCODE in trigger
"lenygold via DBMons  2008-07-16 16:40:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 22:10:53 PST 2009.