4 TYPE — define a new data type
8 TYPE type_name IS ctype
12 The TYPE command defines a new C type. It is equivalent to putting a
13 typedef into a declare section.
15 This command is only recognized when ecpg is run with the -c option.
20 The name for the new type. It must be a valid C type name.
23 A C type specification.
27 EXEC SQL TYPE customer IS
34 EXEC SQL TYPE cust_ind IS
41 EXEC SQL TYPE c IS char reference;
42 EXEC SQL TYPE ind IS union { int integer; short smallint; };
43 EXEC SQL TYPE intarray IS int[AMOUNT];
44 EXEC SQL TYPE str IS varchar[BUFFERSIZ];
45 EXEC SQL TYPE string IS char[11];
47 Here is an example program that uses EXEC SQL TYPE:
48 EXEC SQL WHENEVER SQLERROR SQLPRINT;
57 EXEC SQL TYPE tt_ind IS
66 EXEC SQL BEGIN DECLARE SECTION;
69 EXEC SQL END DECLARE SECTION;
71 EXEC SQL CONNECT TO testdb AS con1;
72 EXEC SQL SELECT pg_catalog.set_config('search_path', '', false); EXEC SQL CO
75 EXEC SQL SELECT current_database(), 256 INTO :t:t_ind LIMIT 1;
77 printf("t.v = %s\n", t.v.arr);
78 printf("t.i = %d\n", t.i);
80 printf("t_ind.v_ind = %d\n", t_ind.v_ind);
81 printf("t_ind.i_ind = %d\n", t_ind.i_ind);
83 EXEC SQL DISCONNECT con1;
88 The output from this program looks like this:
96 The TYPE command is a PostgreSQL extension.