简体   繁体   中英

How to write a DB2 Function with a Timestamp as input parameter

I try to write a function with an input like ( IN myDate DateTime) but i run into "DATETIME" ist ein nicht definierter Name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.69.56

How can i fix it?

If you want TIMESTAMP input parameter, you should declare it as such. See an example:

$ db2 "create or replace procedure timestamp_to_month(in ts timestamp)
    language sql
    return month(date(ts))"

$ db2 "call timestamp_to_month(current timestamp)" 

  Return Status = 9
$ db2 "call timestamp_to_month(timestamp('2019-01-01'))" 

  Return Status = 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM