Skip to Content
1

Global constant in SQLScript ? select CONST from dummy

Apr 24, 2017 at 03:56 PM

124

avatar image

Hallo,

I'm trying to implement the TIMESTAMPDIFF ODBC function

See: ODBC Time date and interval functions

This function has a constant in the first argument called interval.

Example:

select  TIMESTAMPDIFF( SQL_TSI_DAY, timestamp_exp1, timestamp_exp2) from dummy

When I run it, I got:

SAP DBTech JDBC: [260]: invalid column name: SQL_TSI_DAY: line 1 col 22 (at pos 21)

I have then implemented SQL_TSI_DAY as a function without parameters:

CREATE FUNCTION SQL_TSI_DAY RETURNS output1 NUMERIC AS 
BEGIN 
   output1 := 1;
END;

But you need to run it with parentheses. If you try to run it without parentheses

select  SQL_TSI_DAY from dummy;

you get the same (invalid column name) error as before

SAP DBTech JDBC: [260]: invalid column name: SQL_TSI_DAY: line . col .. (at pos ..)

I have then for now created a request enhancement, with snapshot and more detail. See:

https://ideas.sap.com/D42084

But may be that I didn't see any other solutions ...

Can we overcome this check on the parenthesis syntax ? Can I implement it in an other way ?

Thanks

Nico

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Lars Breddemann
May 30, 2017 at 03:03 AM
0

Ok, I'm not too sure why you would want to implement the ODBC function 1:1 directly on HANA.

Using the ODBC driver should do the mapping for you in this case.

Anyhow, there is no way to define an enumeration (the list of valid ODBC (!) keywords to indicate a time interval) and use elements of that enumeration as parameter values.

What you could do is to define a parameter "interval" and accept string literals ("SQL_TSI_DAY", ...) in it. Still, the value would need to be handed over in single quotation marks.

In short: there is no way that HANA SQL will understand ODBC C/C++ functions directly. For that, you will have to use the ODBC driver.

Share
10 |10000 characters needed characters left characters exceeded