Dynamic SQL with cursors
Posted in 1998
Topics: Installation, Setup & Upgrades, Connectivity: ESQL/C, 4GL & Embedded SQL
I'm trying to do something that I'm sure I've seen done before, but I must be losing my mind because what I'm reading in the documentation seems to indicate it can't be done. Basically, I have an existing application with a function that has a parameter x. I have several cursors that I am opening, and inside my function I want to fetch from one of these cursors depending on the value of x (basically I want to alternate between cursors depending on x). The brute force method is to set up my cursor references within a switch/case construct (there are 5 cursors for each of the 16 possible values of x). It just seems like there should be a cleaner method to do this than to cut and paste all this code with slight modifications in all these switch/case statements. It seems like I should be able to use dynamic SQL to do this, building the name of the cursor to be used, etc with sprintfs, but my documentation says that you can't use prepare/execute for declare, execute, fetch and open statements (which just happen to be the ones I need!). I tried to do it anyway just for giggles but I end up getting a syntax error. This may be different in newer versions of Informix, I have a REALLY old version of (like 2.x, and no way around that). Or maybe I'm just forgetting something ... it's been awhile since I've done much heavy duty esql/c. Any suggestions other than "upgrade" would be appreciated. :) Thanks, Eric Eric -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum