Re: (Q) Using variables as literals in Informix 4GL
Posted in 1993
} JOHN MARSHALL Asks..... } } I would like to use a defined char type variable, store a value } (table.column) } in it and then use the variable in a literally. Does anyone out there have } any } suggestions? } } DEFINE the_table CHAR(10) } DEFINE big_name CHAR(20) } ... } } LET the_table="labs" } LET big_name="labs.name" -- assume table called 'labs', column called } 'name' } ... } SELECT COUNT(*) } INTO number_found } FROM the_table } WHERE temp.name=big_name } } I want it to be interpreted as } ... } SELECT COUNT(*) } INTO number_found } FROM labs } WHERE temp.name=labs.name } } - - - - - - - - - -- - - - - - - - } } My solution would be..... } } } DEFINE the_table CHAR(10) } DEFINE big_name CHAR(20) } DEFINE working_str char(100) } } LET the_table="labs" } LET big_name="labs.name" -- assume table called 'labs', column called } 'name' } LET working_str = "SELECT COUNT(*) FROM the_table WHERE ? = ?" } } PREPARE statement_1 FROM working_str } DECLARE cursor_1 CURSOR FOR statement_1 } OPEN cursor_1 using tmp.name,big_name -- this replaces the "?"'s in the } prepare. } FETCH cursor_1 into number_found } CLOSE cursor_1 } } This is a lot more typing, but it works. } } See PREPARE and OPEN in the 4gl reference manual for more details. } } ================================================================= } Tom Lahey } E-Mail: tlahey@avid.com } Avid Technologies, Inc. } Phone: 508.640.3036 } Tewksbury, MA