testd4.ec
上传用户:dgyhgb
上传日期:2007-01-07
资源大小:676k
文件大小:3k
- /*
- * $Id$
- *
- * This file is a part of GNU SQL Server
- *
- * Copyright (c) 1996, Free Software Foundation, Inc
- * Developed at Institute of System Programming of Russian Academy of Science
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Contacts: gss@ispras.ru
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "tests.h"
- #include "dyn_funcs.h"
- extern char *err_str[];
- #define G(p)
- {
- fprintf(stderr,"%s running...",#p);
- int_res = p;
- if(int_res<0)
- goto errexit;
- }
- int
- main(void)
- {
- char s[100],*op,*op1,*op2,*str1 =
- "CREATE TABLE TTBL1(k int not null primary key, t0 char(10), k2 smallint not null unique, t1 char(20) default user, unique (t0,t1))" ,
- *str2= "INSERT INTO TTBL1(k,t0,k2)"
- "VALUES ( 10, 'aaa', 2) "
- ,
- *str3= "DROP TABLE TTBL1"
- ;
- int int_res, i_ind, s_ind;
- {
- SQL_DESCR descr1,descr2;
-
- __SQL_prepare(op, str1);
- descr1=__SQL_allocate_descr("IN",0);
- descr2=__SQL_allocate_descr("OUT",0);
- __SQL_describe(op, 1, descr1);
- __SQL_describe(op, 0, descr2);
- __SQL_execute(op, descr1, descr2);
- }
-
- /* PREPARE op FROM str1
- EXECUTE op USING SQL DESCRIPTOR "IN"
- ;*/
- _SQL_commit();
-
- __SQL_prepare(op1,str2);
- {
- SQL_DESCR tmp_in=__SQL_allocate_descr("IN" ,0);
- SQL_DESCR tmp_out=__SQL_allocate_descr("OUT" ,0);
- SQL_DESCR tmp;int flag=0, i=0;
- __SQL_describe(op1, 1, tmp_in);
- __SQL_describe(op1, 0, tmp_out);
- tmp=tmp_in;
- tmp_in=__SQL_get_descr("INP");
- __SQL_execute(op1, tmp_in, tmp_out);
- flag=1;
- tmp=tmp_out;
- }
- _SQL_commit();
-
- __SQL_prepare(op2,str3);
- {
- SQL_DESCR tmp_in=__SQL_allocate_descr("IN" ,0);
- SQL_DESCR tmp_out=__SQL_allocate_descr("OUT" ,0);
- SQL_DESCR tmp;int flag=0, i=0;
- __SQL_describe(op2, 1, tmp_in);
- __SQL_describe(op2, 0, tmp_out);
- tmp=tmp_in;
- tmp_in=__SQL_get_descr("INPUT");
- __SQL_execute(op2, tmp_in, tmp_out);
- flag=1;
- tmp=tmp_out;
- }
- _SQL_commit();
- return 0;
- errexit:
- if (int_res < 0)
- printf ("SQL_ERROR: '%s'n", err_str[-int_res]);
- else
- {
- int_res = __SQL_execute_immediate ("COMMIT WORK");
- if (int_res < 0)
- printf ("SQL_ERROR: '%s'n", err_str[-int_res]);
- }
- return 0;
- }