Posted: Wed Oct 13, 2004 12:07 am Post subject: Extract Function Error Handling
Apprentice
Joined: 06 Jul 2004 Posts: 33 Location: UK
Hello,
I'm using the EXTRACT function to convert a date_time variable into a string of a particular format. Sometimes, the stored procedure will return "-" indicating that no date exists. In this case EXTRACT will fail as the source is not in the correct format. What is the best way of handling this failure? The ESQL manual doesn't really say much about it....
So far, I'm simply testing for "-" and then handling it another way. Not tested yet...
Joined: 25 May 2002 Posts: 664 Location: South East London
You can either swallow the error by taking corrective action and continuing with the flow (e.g. use a default date), or throw an exception to indicate that the flow cannot continue and intervention is required.
SET dbyear = EXTRACT(YEAR FROM Environment.Variables.Details."WARRANTY_EXPIRY_DATE");
if dbyear = '' then
SET dbdate = '0000/00/00';
else
SET dbmonth = EXTRACT(MONTH FROM Environment.Variables.Details."WARRANTY_EXPIRY_DATE");
SET dbday = EXTRACT(DAY FROM Environment.Variables.Details."WARRANTY_EXPIRY_DATE");
SET dbdate = dbday || '/' || dbmonth || '/' || dbyear;
end if;
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum