You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
postgres/src/interfaces/ecpg/test/test_informix.pgc

69 lines
1.1 KiB

#include "sqltypes.h"
void openit(void);
int main()
{
$int i = 14;
$decimal j, m, n;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
$connect to mm;
$create table test(i int primary key, j int);
rsetnull(CDECIMALTYPE, (char *)&j);
$insert into test (i, j) values (7, :j);
$insert into test (i, j) values (:i, 1);
$declare c cursor for select * from test where i <= :i;
openit();
deccvint(0, &j);
while (1)
{
$fetch in c into :i, :j;
if (sqlca.sqlcode == 100) break;
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
if (risnull(CDECIMALTYPE, (char *)&j))
printf("%d\n", i);
else
{
int a;
dectoint(&j, &a);
printf("%d %d\n", i, a);
}
}
deccvint(7, &j);
deccvint(14, &m);
decadd(&j, &m, &n);
$delete from test where i=:n;
printf("delete: %ld\n", sqlca.sqlcode);
$select 1 from test where i=14;
printf("Exists: %ld\n", sqlca.sqlcode);
$select 1 from test where i=147;
printf("Does not exist: %ld\n", sqlca.sqlcode);
$commit;
$drop table test;
$commit;
$disconnect;
return 0;
}
void openit(void)
{
$open c;
}