gt8963a@prism.gatech.EDU (MCCARTNEY,JEFFREY ELWOOD) (06/17/91)
I'm trying to parameterize the column-name in an Informix WHERE clause. Here's what I mean: SELECT * FROM customer WHERE col_var = NULL ^^^^^^^ I want to be able to make it a var such that I can fill in the column-name at run time. Additionally, I'd like to be able to fill in the column-name from the systems tables as well. Any ideas? (The Informix doc says it can be an expr as well as a column-name. And I've gotten it to compile with a variable, just no selected rows.) Thank you -- uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt8963a Internet: gt8963a@prism.gatech.edu
alan@ferus.lonestar.org (Alan Caldera) (06/18/91)
In article <31474@hydra.gatech.EDU>, gt8963a@prism.gatech.EDU (MCCARTNEY,JEFFREY ELWOOD) writes: > I'm trying to parameterize the column-name in an Informix WHERE clause. > > Here's what I mean: > > SELECT * FROM customer WHERE col_var = NULL > > ^^^^^^^ I'm assuming that you are refering to Informix-4GL in which case the following maybe used: LET sel_1 (a char variable) = "SELECT * FROM customer WHERE ",col_var_name, " IS NULL " PREPARE sel_stmt (some unique undefined var) FROM sel_1 Then you have 2 choices: EXECUTE sel_stmt -or- DECLARE some_curs CURSOR FOR sel_stmt FOREACH some_curs INTO some_record_var.* I have found that this works very well, the only caveat being that when dealing with numerics to first convert them into some sort of reasonable char value first. (So that you can concatenate into the string.) Remember also to put quotes around any string within the SELECT statement Hope this helps --alan -------------------------------------------------------------------------- Alan Caldera/ 10610 Metric Rd/ Logic Process Corporation / Dallas, TX 75423 (214) 340-5172 #include <std.cute.disclaimer>