michael-mammut
michael-mammut

Reputation: 2783

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?

Upvotes: 0

Views: 638

Answers (1)

kkuduk
kkuduk

Reputation: 601

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

Upvotes: 2

Related Questions