Re: Passing Parameters to isql scripts
Posted in 1992
Naomi Walker writes: > I have an esql/c program that invokes isql through a system call. > example: > > (void)system("isql - crtable"); > > (crtable.sql creates a few tables and indices) > > I would like to be able to pass the script the name of the database > being worked on. Is this possible? Dead easy. Bung the whole lot in a char buffer, then call system() on the buffer. Viz: #include <stdio.h> main(argc, argv) int argc; char **argv; { char buf[200]; char * db = "foobar"; char * otherargs = "crtable.sql"; sprintf(buf, "isql %s %s", db, otherargs); puts(buf); system(buf); } > If thats not possible, how about > having my script know about the database that I opened in the esql/c > program? > Currently, if I dont explicity open the database in the script, > it doesnt understand that it should use the same one I opened in the > program. Don't think the system'd process can tell - there isn't any communication between them. > I know I could just include the whole hunk of sql stuff in the esql/c > code, but this way its more flexible and easier to install for each of > our customers. Yup, it's a really nice change to be able to use vi on ASCII, rather than emacs and adb on binaries. Probably worth checking the exit status from system(), if you've got a late enuff version of isql that it sets the status on errors. You might also want to do stuff to throw away stout/stderr, or (better) write it to a log file that you can display if the thing doesn't work. Otherwise it tends to appear in strange places on the screen. Hope this helps ! Cheers - Tony. __________________________________________________________________________ Tony Heskett th@bnr.co.uk Voice: (+44) 279 429531 x 2637 BNR, London Road, Harlow, Essex, CM17 9NA Fax: (+44) 279 454187