Re: Returning a value from .4gi
Posted in 1994
Topics: General Discussion
In article nnp@nova.avid.com, .Chris_Swecker@mac.avid.com (Chris) writes: >I am trying to return an integer value from one .4gi to another ie; > >I would like to return a specific integer value back to the calling >program and use this integer value. > >Unfortunatly the returned integer value is not the value in the >EXIT PROGRAM(value) I use the following scheme for returning data from a "RUN" process. 1) Provide a PERMANENT table with the following fields: primary_key SERIAL PRIMARY KEY, return_val_1 whatever_type, return_val_2 whatever_type, ... return_val_n whatever_type, error_code INTEGER 2) The calling process first inserts a record into this table containing only the primary_key and NULLS. 3) The calling process executes the RUN statement, passing the primary_key of the record just inserted. 4) The called process inserts the appropriate values into the "communication" table by UPDATEing the record identified by the primary_key it received as a parameter. If an error value must be returned, I provide a separate error_code field in the table explicitly for that information. 5) The calling function (which obviously did a "WAITED" RUN) now SELECTs the row, processes it based on the returned values and error_code, and then DELETEs the row from the table. There are some shortcomings of this approach. Some that come to mind: - Assuming the called process can access the database - Error-recovery isn't complete (how does the called process tell the calling process that it didn't receive the primary_key argument, etc) However, I have had success with this approach. I believe this is the type approach referenced by Paul Hatcher: In article 1nJ@cix.compulink.co.uk, phatcher@cix.compulink.co.uk ("Paul Hatcher") writes: >You can't do this with return values as they are restricted in range to >0..255. Also, temp tables may cause a problem as the child process may >not be able to 'see' the temp table - a better idea is to have a >permanent table and have the parent process create a record passing the >PK as a parameter. --- cbair@informix.com (Craig Bair) | A man doesn't automatically get my respect - Informix Software, Inc. | He must get down in the dirt and beg for it. Menlo Park, CA | -- Jack Handy, SNL