Age Owner TLA Line data Source code
1 : #include <stdio.h>
2 :
3 : exec sql include sqlca;
4 : exec sql include ../regression;
5 :
5072 meskes 6 CBC 1 : int main()
7 : {
8 : exec sql begin declare section;
6094 9 1 : int intvar = 5;
10 1 : int nullind = -1;
11 : exec sql end declare section;
12 :
13 1 : ECPGdebug(1,stderr);
14 :
15 1 : exec sql connect to REGRESSDB1;
16 1 : exec sql set autocommit to off;
17 :
5717 18 1 : exec sql create table indicator_test (
19 : "id" int primary key,
20 : "str" text NOT NULL,
21 : val int null);
6094 22 1 : exec sql commit work;
23 :
5717 24 1 : exec sql insert into indicator_test (id, str, val) values ( 1, 'Hello', 0);
25 :
26 : /* use indicator in insert */
27 1 : exec sql insert into indicator_test (id, str, val) values ( 2, 'Hi there', :intvar :nullind);
6094 28 1 : nullind = 0;
5717 29 1 : exec sql insert into indicator_test (id, str, val) values ( 3, 'Good evening', :intvar :nullind);
6094 30 1 : exec sql commit work;
31 :
32 : /* use indicators to get information about selects */
5717 33 1 : exec sql select val into :intvar from indicator_test where id = 1;
34 1 : exec sql select val into :intvar :nullind from indicator_test where id = 2;
6094 35 1 : printf("intvar: %d, nullind: %d\n", intvar, nullind);
5717 36 1 : exec sql select val into :intvar :nullind from indicator_test where id = 3;
6094 37 1 : printf("intvar: %d, nullind: %d\n", intvar, nullind);
38 :
39 : /* use indicators for update */
40 1 : intvar = 5; nullind = -1;
5717 41 1 : exec sql update indicator_test set val = :intvar :nullind where id = 1;
42 1 : exec sql select val into :intvar :nullind from indicator_test where id = 1;
6094 43 1 : printf("intvar: %d, nullind: %d\n", intvar, nullind);
44 :
5717 45 1 : exec sql drop table indicator_test;
6094 46 1 : exec sql commit work;
47 :
48 1 : exec sql disconnect;
49 1 : return 0;
50 : }
|