Skip to Content
0

How can we type caste a number to date in a dynamic query?

May 09 at 10:37 AM

24

avatar image

I am trying to create a dynamic query.

My query looks like:DATE_FROM EQ ZEDITPOSTMP-TABKEY+000013(000008)

where zeditpostmp is an internal table and tabkey is its column name.

000013 is offset value.

000008 is length of the field

I am getting error because (ZEDITPOSTMP-TABKEY+000013(000008)) is evaluated without colons. And since we are comparing with date so right hand side should be in date format i.e. ' Evaluated_Value'. But I am getting only Evaluated_Value. So if i append these colons myself then it looks like this :-'(ZEDITPOSTMP-TABKEY+000013(000008)' . Now it is considered as a string but there is no evaluation done by compiler because it's no more a function.

My whole query is:

OPEN CURSOR WITH HOLD c1
FOR SELECT (COL_STR)
FROM (JOIN_STR)
UP TO ROWCOUNT ROWS
FOR ALL ENTRIES IN ZEDITPOSTMP
WHERE (WHERESTR).

Where DATE_FROM EQ ZEDITPOSTMP-TABKEY+000013(000008) is part of this wherestr

This works well if I provide the date value as '00010101' instead of constructing the query dynamically.

Please let me know how can I solve this issue.

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

0 Answers