If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > open statement for dynamically prepared select statement in 4gl

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-04, 13:08
jenifer jenifer is offline
Registered User
 
Join Date: Jun 2003
Posts: 12
Question open statement for dynamically prepared select statement in 4gl

How can I open a declared cursor that is a dynamically prepared select statement behind it (different number of parameters for the using clause)?

I built the open statement as a variable, now I need to 'run' it..
(i.e.: depending on the criteria entered, the where clause of the prepared select statement can have 1 to 5 variables.. Can have any combination of the 5 criteria, so if a user wants all programs, there would be no 'and program = ?' clause. The full where clause is:where fy = ? and quarter = ? and program = ? and facility = ? and agency_code = ?. But as mentioned, it could have just 'where fy = ?'

Does anyone have any ideas?


Thanks!
Reply With Quote
  #2 (permalink)  
Old 08-17-04, 08:35
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Hi,

I think that can you use built-in functions ARG_VAL(), NUM_ARGS().
Exemp:
DEFINE pa_args ARRAY[5] OF CHAR(10),
i SMALLINT
FOR i = 1 TO NUM_ARGS()
LET pa_args[i] = ARG_VAL(i)
END FOR


Gustavo.
Reply With Quote
  #3 (permalink)  
Old 08-18-04, 13:33
henson_liu henson_liu is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
Red face

Hi,

First,I think you need to form the null query strings like "1=1".
Secondly,Add more query string like "and ?" if the input condition is not blank.
Thirdly,prepare the sql statement using the query stings you created.

I think that will work.
Reply With Quote
  #4 (permalink)  
Old 08-19-04, 00:40
debindranil debindranil is offline
Registered User
 
Join Date: Aug 2004
Posts: 10
You have to use the CONSTRUCT statement to dynamically prepare the WHERE clause. Then prepare that statement to declare the cursor.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On