Re: Create procedure from esql
Posted in 1999
Leonid Belov wrote: > > Igor wrote: > > > Hi All > > > > I got some program fromInformix Guide to SQL > > > > #include <stdio.h> > > #include <string.h> > > $include sqlca; > > $include sqlda; > > $include datetime; > > > > main() > > { > > > > $database cl_default; > > $create procedure from "file_name" ; > > } > > Is it possible to change "file_name" .I tried to put argv[1] with > > some other file name but it doesn't accept it.may be there is some > > way to do it. > > #include <stdio.h> > #include <string.h> > $include sqlca; > $include sqlda; > $include datetime; > > main(int argc, char *argv[]) > { > > EXEC SQL BEGIN DECLARE SECTION; > char filename[100]; > EXEC SQL END DECLARE SECTION; > > $database cl_default; > strcpy(filename, argv[1]); > $create procedure from :filename; > } The ultra pedantic (eg me) can suggest better coding details, but the basic answer is right. In fact, this is the basis for the simplest SQL command interpreters. If you download the SQLCMD program from the IIUG, you get a program mkproc that does a slightly more fancy version of this. The main extra bells and whistles are that it allows you to specify the database on the command line, and it does more error checking that this code does. Note, too, that the statement in the file is not restricted to a CREATE PROCEDURE statement; it can be any statement which takes no parameters and which does not return data (no SELECTs and no EXECUTE PROCEDURE where the procedure returns data). -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>