Age Owner TLA Line data Source code
1 : #include "sqltypes.h"
2 : #include <stdlib.h>
3 :
4 : $include ../regression;
5 : $define NUMBER 12;
6 :
7 : static void
6077 meskes 8 CBC 20 : test_null(int type, char *ptr)
9 : {
10 20 : printf("null: %d\n", risnull(type, ptr));
11 20 : }
12 :
13 1 : int main(void)
14 : {
5717 15 1 : $char c[] = "abc";
6077 16 1 : $short s = 17;
17 1 : $int i = -74874;
18 1 : $bool b = 1;
221 andres 19 GNC 1 : $float f = (float) 3.71;
6077 meskes 20 CBC 1 : $long l = 487444;
21 1 : $double dbl = 404.404;
22 : $decimal dec;
23 : $date dat;
24 : $timestamp tmp;
25 :
26 1 : ECPGdebug(1, stderr);
27 : $whenever sqlerror do sqlprint();
28 :
29 1 : $connect to REGRESSDB1;
30 1 :
31 1 : $create table test(id int, c char(10), s smallint, i int, b bool,
32 : f float, l bigint, dbl double precision,
33 : dec decimal, dat date, tmp timestamptz);
34 1 : $commit;
35 1 :
36 1 : $insert into test (id, c, s, i, b, f, l, dbl) values (
37 : 1, :c, :s, :i, :b, :f, :l, :dbl
38 : );
39 1 : $commit;
40 1 :
41 1 : rsetnull(CCHARTYPE, (char *) c);
42 1 : rsetnull(CSHORTTYPE, (char *) &s);
43 1 : rsetnull(CINTTYPE, (char *) &i);
44 1 : rsetnull(CBOOLTYPE, (char *) &b);
45 1 : rsetnull(CFLOATTYPE, (char *) &f);
46 1 : rsetnull(CLONGTYPE, (char *) &l);
47 1 : rsetnull(CDOUBLETYPE, (char *) &dbl);
48 1 : rsetnull(CDECIMALTYPE, (char *) &dec);
49 1 : rsetnull(CDATETYPE, (char *) &dat);
50 1 : rsetnull(CDTIMETYPE, (char *) &tmp);
51 :
52 1 : $insert into test (id, c, s, i, b, f, l, dbl, dec, dat, tmp) values (
53 : 2, :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
54 : );
55 1 : $commit;
56 1 :
57 1 : printf("first select\n");
58 :
59 1 : $select c, s, i, b, f, l, dbl, dec, dat, tmp
60 : into :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
61 : from test where id = 1;
62 1 :
63 1 : test_null(CCHARTYPE, (char *) c);
64 1 : test_null(CSHORTTYPE, (char *) &s);
65 1 : test_null(CINTTYPE, (char *) &i);
66 1 : test_null(CBOOLTYPE, (char *) &b);
67 1 : test_null(CFLOATTYPE, (char *) &f);
68 1 : test_null(CLONGTYPE, (char *) &l);
69 1 : test_null(CDOUBLETYPE, (char *) &dbl);
70 1 : test_null(CDECIMALTYPE, (char *) &dec);
71 1 : test_null(CDATETYPE, (char *) &dat);
72 1 : test_null(CDTIMETYPE, (char *) &tmp);
73 :
74 1 : printf("second select\n");
75 :
76 1 : $select c, s, i, b, f, l, dbl, dec, dat, tmp
77 : into :c, :s, :i, :b, :f, :l, :dbl, :dec, :dat, :tmp
78 : from test where id = 2;
79 1 :
80 1 : test_null(CCHARTYPE, (char *) c);
81 1 : test_null(CSHORTTYPE, (char *) &s);
82 1 : test_null(CINTTYPE, (char *) &i);
83 1 : test_null(CBOOLTYPE, (char *) &b);
84 1 : test_null(CFLOATTYPE, (char *) &f);
85 1 : test_null(CLONGTYPE, (char *) &l);
86 1 : test_null(CDOUBLETYPE, (char *) &dbl);
87 1 : test_null(CDECIMALTYPE, (char *) &dec);
88 1 : test_null(CDATETYPE, (char *) &dat);
89 1 : test_null(CDTIMETYPE, (char *) &tmp);
90 :
91 1 : $drop table test;
92 1 : $commit;
93 1 :
94 1 : $close database;
95 1 :
96 1 : return 0;
97 : }
|