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