If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > MS SQL to DB2 SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-10, 09:39
blase blase is offline
Registered User
 
Join Date: Apr 2010
Posts: 1
Unhappy MS SQL to DB2 SQL

Hi,
I have an problem creating an DB2 sql procedure on our AS400 5.4
This is sql is direct copy past from a IBM DB2 redbook.
You see the statement below, the error is:
"...at token = is a syntax error ..."
Q: What is wrong here?


CREATE FUNCTION DEC2DATE (
DATEDEC DECIMAL(8, 0) )
RETURNS DATE
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION
BEGIN
DECLARE RESULT DATE ;
DECLARE InvalidDate CONDITION FOR '22007';
DECLARE EXIT HANDLER FOR InvalidDate
BEGIN
RETURN CAST(NULL AS DATE);
SIGNAL SQLSTATE '01HDI' SET MESSAGE_TEXT='Invalid date';
END;
SET RESULT = DATE(
SUBSTRING(DIGITS(DATEDEC),1,4) || '-' ||
SUBSTRING(DIGITS(DATEDEC),5,2) || '-' ||
SUBSTRING(DIGITS(DATEDEC),7,2));
RETURN RESULT;
END ;
Reply With Quote
  #2 (permalink)  
Old 04-06-10, 10:21
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Maybe you didn't copy the example from a redbook for DB2 on AS/400 but rather some other DB2 product? Maybe you had a copy'n'paste error? It would help if you could provide some more details like which redbook, which version of DB2 you are using, and what the exact error message is, and how you handled the statement terminators.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Tags
create procedure error

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On