Re: (Q) Using variables as literals in Informix 4GL
Posted in 1993
->Date: 20 Jul 1993 15:37:05 -0500 (EST) ->From: "JOHN MARSHALL, CUSTOMER SERVICES, JAMES MADISON UNIVERSITY, (703)568-3539"@rmy.emory.edu (703) (703) ->Subject: (Q) Using variables as literals in Informix 4GL ->To: informix-list@rmy.emory.edu ->Sender: informix-list-owner@rmy.emory.edu ->Reply-To: "JOHN MARSHALL, CUSTOMER SERVICES, JAMES MADISON UNIVERSITY, (703)568-3539"@rmy.emory.edu (703) (703) -> ->Please let me know if this is not the appropriate forum to ask such ->questions... -> ->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? -> -> ->Ex. -> ->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 -> ->Thanks, -> ->John ->============================================================================== ->John Marshall || Bitnet: OIT_JOHN@JMUVAX ->Customer Services || Internet: OIT_JOHN@VAX1.ACS.JMU.EDU ->James Madison University || AppleLink: jmu.john ->Harrisonburg, VA 22807 || ->(703)568-6625 || ->============================================================================= -> John, Yes, this is exactly the right forum. You can't do exactly what you want, but you can come close. Ex. { modified } DEFINE the_table CHAR(10) DEFINE big_name CHAR(20) DEFINE statement CHAR(256) { added } ... LET the_table="labs" LET big_name="labs.name" -- assume table called 'labs', column called 'name' ... LET statement = { added } "SELECT COUNT(*) ", { modified } "INTO number_found ", { modified } "FROM ", the_table, { modified } " WHERE temp.name=", big_name { modified } PREPARE request FROM statement { added } EXECUTE request { added; but see below } Actually, this is not *quite* right. SELECT statements can not be EXECUTEd. You must DECLARE a cursor, etc., etc. However, UPDATEs, DELETEs, etc. can be EXECUTEd, so I used the simpler and more general form in the example. Also, I presume that 'temp.name' is a 4GL program variable; otherwise there is an error in the SELECT statement. I hope this helps. O ___________________________ Regards, H | R. Alan Popiel |__________________ Alan H | Martin Marietta, Tech Ops | Internet: |_________________________ H | P.O. Box 179, M/S 5422 | alan@den.mmc.com | / H | Denver, CO 80201-0179 USA | Voice: | Std disclaimers apply./ H |___________________________| 303-977-9998 | ( H (_____________________| (But you knew that!) \\ H (___________________________\\