isqltcl-4.0.readme

来自「TCL的数据库处理支撑库及一些示例」· README 代码 · 共 410 行 · 第 1/2 页

README
410
字号
                If type is 0, then the output sqlda is used.                This number reflects the number of columns fetched from the                dynamic query or the number of bind variables specified.            char **sql_sqlda(int fd, int type, int elnum, int *numvalues)                Returns array of character pointers (the number of such                pointers is set in numvalues) for the sqlda element elnum.                This contains information like the column name, type,                value etc.                type is the same as in sql_sqld                elnum varies from 0 to sql_sqld(int fd, int type)            int sql_finish()                Closes the database opened earlier with sql_database                Returns 0 on success, < 0 on failure            char *sql_getdatabase()                Gets the database name opened with sql_database            All the C calls above should ensure that the fd is valid            before it proceeds.    COMPILING TCL            To add support to TCL, two files have been provided            1) sqlinf.ec  - code containing C calls to database            2) tclsql.c   - code for wrappers around sqlinf.ec calls                            which adds SQL support to TCL.            Copy these files into the tcl distribution directory            Users who want SQL support in TCL should add the call                isql_init(interp) in tclAppInit.c (for tcl versions >= 7)                or in their main.c             Compile sqlinf.ec with c4gl                c4gl -c sqlinf.ec            Add the file tclsql.o in the Makefile (to the GENERIC_OBJS define)            Do a make with                make CC=c4gl            Use c4gl if you are using Informix 4 or greater since it does a            better job of freeing cursors (in my opinion). Use esql if you            do not have c4gl.    COMPILING TK            Users who want SQL support in TK should add the call                isql_init(interp) in main.c or tkAppInit.c            and link the wish interpreter again with                make CC=c4gl.    EXAMPLES#ifdef TESTmain() {    int fd, ret;    sql_database("test");    {        char *argv[] = { "A%"};        fd = sql_open("select emp_name from employee where emp_name like ?",                        1, argv);        ret = 0;        while (ret == 0) {            ret = sql_fetch(fd);            if (ret == 0) sql_print(fd);        }    }    {        char **argv;        sql_reopen(fd);        sql_fetch(fd);        argv = sql_values(fd, &ret, 0);        if (!argv) printf("No values for fd%d\n", fd);        else {            int i;            for (i = 0; i < ret; i++)                printf("Value %d is (%s)\n", i, argv[i]);        }    }    {        char *argv[] = { "19"};        if (sql_exists("employee", "emp_name", 0, 0)==0)            printf("At least 1 employee exists\n");        if (sql_exists("employee", "emp_name", "JOLLY'GOOD", 0)==0)            printf("Employee JOLLY'GOOD exists\n");        if (sql_exists("employee", "emp_name", 0, "emp_name matches 'A*'")==0)            printf("Employee matching A* exists\n");        if (sql_run("set lock mode to wait", 0, 0) == 0)            printf("Successful lock mode\n");        if (sql_run("update employee set salary = ?", 1, argv) == 0)            printf("Successful update \n");    }}#endif    CONCLUSIONS        I have posted the archived file isqltcl.tar.Z to        harbor.ecn.purdue.edu. It should be available there soon.        The command            zcat isqltcl.tar.Z | tar xvf -        will create the following files in the current directory            sqlinf.ec            tclsql.c            readme.sql (this document)        Follow the instructions provided earlier to compile it.        If you have any suggestions or comments,        please write skumar@netcom.com (It may take some time for me to        respond in the next two weeks since I will be relocating).Informix SQL TCL - Release 2.1 fixed coredumps and new feature--------------------------------------------------------------    The sql close routine was freeing the descriptor which    was allocated by describe. Now you may use esql or c4gl    to compile the file.    sql reopen now accepts bind parameters. Thus, the overhead of    prepare,describe etc. in sql open is avoided.    for e.g.    sql database "db"    set fd [sql open "select * from employee where emp_name = ?" "ABC"]    puts stdout [sql fetch $fd]    sql reopen $fd "XYZ"    puts stdout [sql fetch $fd]    I have uploaded the file isqltcl.tar.Z (containing    readme.sql, sqlinf.ec and tclsql.c) to harbor.ecn.pudue.edu.    It should be available there soon.    If you have any suggestions or comments (or any problems),    please write skumar@netcom.comInformix SQL TCL - Release 3.0 - support for BLOBs and Informix 7.X---------------------------------------------------------------------		This release now supports blob data types - byte and text. It also	supports Informix 7.X stored procedure execution in the "sql run"	command. 	The syntax for running the stored procedures is identical to the	one used in ISQL or DBACCESS programs provided by Informix.	Text values are stored and retrieved as-is. Byte values are converted	to hex on output and the input is assumed to be in hex.	e.g.	sql database db	sql run "create table blob1 (x1 text, x2 char(10))"	sql run "insert into blob1 values(?,?)" [exec cat /etc/passwd] "END"	source sql.tcl 	# contains the function sql_one	sql_one "select * from blob1"		# should return a list with two elements : contents of password 		# file and the word END	sql run "create table blob2 (x1 byte, x2 char(10))"	sql run "insert into blob2 values(?,?)" 6d6d6d6d6d END	sql_one "select * from blob2"		# should return 6D6D6D6D6D and END in a list	sql run "delete from blob1"	sql run "insert into blob1 select * from blob2"	sql_one "select * from blob1"		# should return mmmmm and END in a list (since 6d is m in ascii)	sql run "drop table blob1; drop table blob2"	# sql_one "execute procedure ins_sel()" 	A compatibility file called sql.tcl is also provided which allows	programs which use sql_ calls to work with the sql command.	Also using the sql_ calls will provide for easier migration to other	database access routines.	Two TCL functions in sql.tcl will allow for fetching one row	from a cursor i.e. open cursor fetch one row and close cursor	e.g.	sql database db	sql_one "select * from employee where emp_name = ?" "ABC"		will fetch the first row 	sql_onetrim "select * from employee"		will fetch the first row and strip trailing blanks from the		returned columns	A windowing ISQL (plagiarized from Tom Pointdexter's Sybase 	package) is provided. Run it by typing	cd uco;wish -f wsql	The wish should have ISQL and WISH-X extensions compiled in.	You will be able to generally form SQL queries on the fly (without	having to know SQL), look at different database tables etc. using	this small but wonderful package. 	This release compiles in the same manner as earlier releases	(look at the compiling section in this document).Informix SQL TCL - Release 3.1 - Minor fixes---------------------------------------------------------------------	Some minor fixes to code to workaround Informix bugs	(Fixed sql_set_values to initialize sqlda pointer to NULL	if sqlda's sqld element is 0; otherwise the pointer sqlvar is	pointing to an illegal reference).	Also added casts for calloc where appropriate.	Removed wisql from the distribution since it did not work at all	on TK4.1. 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?