error creatinf function db2

please help - i get an error when creating a function:

CREATE FUNCTION GETCURRENTSYSDATE()
     RETURNS CHAR(8)
     DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
     BEGIN ATOMIC
     RETURN CHAR(YEAR(current date))||char(month(current date))||char(day(current day))
   END

this gives the errors


DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "END" was found following "r(day(current day))
".  Expected tokens may include:  "<delim_semicolon>".  LINE NUMBER=5.  
SQLSTATE=42601
LVL 1
hraja77Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Cenjoy100Commented:
Hi hraja77,
Try this,

CREATE FUNCTION GETCURRENTSYSDATE()
     RETURNS CHAR(800)
     DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
     BEGIN ATOMIC
     RETURN select CHAR(YEAR(current date))||char(month(current date))||char(day(current day)) from SYSIBM.SYSDUMMY1;
   END
0
hraja77Author Commented:
db2 => CREATE FUNCTION GETCURRENTSYSDATE()
     RETURNS CHAR(800)
     DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
     BEGIN ATOMIC
     RETURN select CHAR(YEAR(current date))||char(month(current date))||char(day(current day)) from SYSIBM.SYSDUMMY1;
   ENDdb2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) => DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "rom
SYSIBM.SYSDUMMY1".  Expected tokens may include:  "JOIN <joined_table>".  LINE
NUMBER=5.  SQLSTATE=42601
0
Cenjoy100Commented:
CREATE FUNCTION GETCURRENTSYSDATE()
     RETURNS CHAR(800)
   
     BEGIN ATOMIC
     RETURN SELECT CHAR(YEAR(CURRENT_DATE))||char(month(CURRENT_DATE))||char(day(CURRENT_DATE)) from SYSIBM.SYSDUMMY1;
       END
   

Sorry for giving tries..As I dont have right now DB2 environment open so its giving you syntax errors.

Try this...else I will work on it by tomorrow.

Sorry for that.... Hope this will work :)
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

hraja77Author Commented:
db2 =>  CREATE FUNCTION GETCURRENTSYSDATE()
     RETURNS CHAR(800)
   
     BEGIN ATOMIC
     RETURN SELECT CHAR(YEAR(CURRENT_DATE))||char(month(CURRENT_DATE))||char(day(CURRENT_DATE)) from SYSIBM.SYSDUMMY1db2 (cont.) => db2 (cont.) => db2 (cont.) => db2 (cont.) =>
db2 (cont.) => ;
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "END CREATE" was found following
"BEGIN-OF-STATEMENT".  Expected tokens may include:  "<create_or_replace>".  
SQLSTATE=42601
db2 =>
0
tliottaCommented:
CREATE FUNCTION GETCURRENTSYSDATE()
       RETURNS CHAR(8)
       LANGUAGE SQL
       DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
       BEGIN ATOMIC
        RETURN (select CHAR(YEAR(current date))||char(month(current date))||char(day(current date)) from SYSIBM.SYSDUMMY1);
     END

Open in new window

That works for me. I don't know what version of DB2 you're running nor what platform nor what client. But it ought to be very close.

Tom
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hraja77Author Commented:
no this should be deleted as the question is lightly diferent
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.