RE: Dynamic Database in 4gl?
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
-----Original Message----- From: Paul Wilson [mailto:paul.wilson@the-zone.ndirect.co.uk] Sent: Friday, July 16, 1999 5:56 PM To: informix-list@iiug.org Subject: Re: Dynamic Database in 4gl? The only way you can do it with LIKE Defines is like so:: DATABASE abc DEFINE LIKE statement for table which exists in abc just to get definition set up. DEFINE new_db CHAR(50) MAIN new_db = arg_val(1) DATABASE new_db ... do the bizz ... END MAIN You can't use the define like, you want to dynamically declare your database. You have to explicitly define the each fields in the variable table record. DEFINE systables_rec RECORD tabname char(18), owner char(8), partnum integer, tabid serial, rowsize smallint, ncols smallint, nindexes smallint, nrows integer, created date, version integer, tabtype char(1), locklevel char(1), npused integer, fextsize integer, nextsize integer, flags smallint, site char(18), dbname char(18) END RECORD <strangiato@my-deja.com> wrote in message news:7mnq24$lg8$1@nnrp1.deja.com... > Is it possible to change the databse in 4gl based on a passed parameter? > > The problem I'm running into is that I have "LIKE systables." DEFINES > in my code and they are cuasing errors because I have no *explicit* > DATABASE statement. > > Thanks :) > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't.
Actually, as long as the table structures are the same in the various databases you CAN use LIKE. You need to put a DATABASE statement at the top of the source file, outside of the main program, which will be used by the compiler at compile time to resolve the LIKE clauses. Then at runtime your dynamic DATABASE statement will be used. If you have ONLY a DATABASE statement at the top like that and non in the program then one inside the program is generated by the compiler. Since you will have the dynamic DATABASE statement there the one at the top will NOT be replicated in the generated code (add -keep and checkout the generated .ec file). Art S. Kagel "Gabbard, Mike W." wrote: > > -----Original Message----- > From: Paul Wilson [mailto:paul.wilson@the-zone.ndirect.co.uk] > Sent: Friday, July 16, 1999 5:56 PM > To: informix-list@iiug.org > Subject: Re: Dynamic Database in 4gl? > > The only way you can do it with LIKE Defines is like so:: > > DATABASE abc > > DEFINE LIKE statement for table which exists in abc just to get definition > set up. > > DEFINE new_db CHAR(50) > > MAIN > new_db = arg_val(1) > DATABASE new_db > > ... > do the bizz > ... > > END MAIN > > You can't use the define like, you want to dynamically declare your > database. You have to explicitly define the each fields in the variable > table record. > > DEFINE systables_rec RECORD > tabname char(18), > owner char(8), > partnum integer, > tabid serial, > rowsize smallint, > ncols smallint, > nindexes smallint, > nrows integer, > created date, > version integer, > tabtype char(1), > locklevel char(1), > npused integer, > fextsize integer, > nextsize integer, > flags smallint, > site char(18), > dbname char(18) > END RECORD > > <strangiato@my-deja.com> wrote in message > news:7mnq24$lg8$1@nnrp1.deja.com... > > Is it possible to change the databse in 4gl based on a passed parameter? > > > > The problem I'm running into is that I have "LIKE systables." DEFINES > > in my code and they are cuasing errors because I have no *explicit* > > DATABASE statement. > > > > Thanks :) > > > > > > Sent via Deja.com http://www.deja.com/ > > Share what you know. Learn what you don't.