-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlcodes.c
196 lines (185 loc) · 5.36 KB
/
sqlcodes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include <oci.h>
#include "common.h"
char *getsqlfn(int sqlfncode) {
int i;
static const sqlfncode_t sqlfnlist[] = {
{ 1, "CREATE TABLE" },
{ 2, "SET ROLE" },
{ 3, "INSERT" },
{ 4, "SELECT" },
{ 5, "UPDATE" },
{ 6, "DROP ROLE" },
{ 7, "DROP VIEW" },
{ 8, "DROP TABLE" },
{ 9, "DELETE" },
{ 10, "CREATE VIEW" },
{ 11, "DROP USER" },
{ 12, "CREATE ROLE" },
{ 13, "CREATE SEQUENCE" },
{ 14, "ALTER SEQUENCE" },
{ 16, "DROP SEQUENCE" },
{ 17, "CREATE SCHEMA" },
{ 18, "CREATE CLUSTER" },
{ 19, "CREATE USER" },
{ 20, "CREATE INDEX" },
{ 21, "DROP INDEX" },
{ 22, "DROP CLUSTER" },
{ 23, "VALIDATE INDEX" },
{ 24, "CREATE PROCEDURE" },
{ 25, "ALTER PROCEDURE" },
{ 26, "ALTER TABLE" },
{ 27, "EXPLAIN" },
{ 28, "GRANT" },
{ 29, "REVOKE" },
{ 30, "CREATE SYNONYM" },
{ 31, "DROP SYNONYM" },
{ 32, "ALTER SYSTEM SWITCH LOG" },
{ 33, "SET TRANSACTION" },
{ 34, "PL/SQL EXECUTE" },
{ 35, "LOCK" },
{ 36, "NOOP" },
{ 37, "RENAME" },
{ 38, "COMMENT" },
{ 39, "AUDIT" },
{ 40, "NO AUDIT" },
{ 41, "ALTER INDEX" },
{ 42, "CREATE EXTERNAL DATABASE" },
{ 43, "DROP EXTERNAL DATABASE" },
{ 44, "CREATE DATABASE" },
{ 45, "ALTER DATABASE" },
{ 46, "CREATE ROLLBACK SEGMENT" },
{ 47, "ALTER ROLLBACK SEGMENT" },
{ 48, "DROP ROLLBACK SEGMENT" },
{ 49, "CREATE TABLESPACE" },
{ 50, "ALTER TABLESPACE" },
{ 51, "DROP TABLESPACE" },
{ 52, "ALTER SESSION" },
{ 53, "ALTER USER" },
{ 54, "COMMIT (WORK)" },
{ 55, "ROLLBACK" },
{ 56, "SAVEPOINT" },
{ 57, "CREATE CONTROL FILE" },
{ 58, "ALTER TRACING" },
{ 59, "CREATE TRIGGER" },
{ 60, "ALTER TRIGGER" },
{ 61, "DROP TRIGGER" },
{ 62, "ANALYZE TABLE" },
{ 63, "ANALYZE INDEX" },
{ 64, "ANALYZE CLUSTER" },
{ 65, "CREATE PROFILE" },
{ 66, "DROP PROFILE" },
{ 67, "ALTER PROFILE" },
{ 68, "DROP PROCEDURE" },
{ 70, "ALTER RESOURCE COST" },
{ 71, "CREATE SNAPSHOT LOG" },
{ 72, "ALTER SNAPSHOT LOG" },
{ 73, "DROP SNAPSHOT LOG" },
{ 74, "CREATE SNAPSHOT" },
{ 75, "ALTER SNAPSHOT" },
{ 76, "DROP SNAPSHOT" },
{ 77, "CREATE TYPE" },
{ 78, "DROP TYPE" },
{ 79, "ALTER ROLE" },
{ 80, "ALTER TYPE" },
{ 81, "CREATE TYPE BODY" },
{ 82, "ALTER TYPE BODY" },
{ 83, "DROP TYPE BODY" },
{ 84, "DROP LIBRARY" },
{ 85, "TRUNCATE TABLE" },
{ 86, "TRUNCATE CLUSTER" },
{ 87, "CREATE BITMAPFILE" },
{ 88, "ALTER VIEW" },
{ 89, "DROP BITMAPFILE" },
{ 90, "SET CONSTRAINTS" },
{ 91, "CREATE FUNCTION" },
{ 92, "ALTER FUNCTION" },
{ 93, "DROP FUNCTION" },
{ 94, "CREATE PACKAGE" },
{ 95, "ALTER PACKAGE" },
{ 96, "DROP PACKAGE" },
{ 97, "CREATE PACKAGE BODY" },
{ 98, "ALTER PACKAGE BODY" },
{ 99, "DROP PACKAGE BODY" },
{ 157, "CREATE DIRECTORY" },
{ 158, "DROP DIRECTORY" },
{ 159, "CREATE LIBRARY" },
{ 160, "CREATE JAVA" },
{ 161, "ALTER JAVA" },
{ 162, "DROP JAVA" },
{ 163, "CREATE OPERATOR" },
{ 164, "CREATE INDEXTYPE" },
{ 165, "DROP INDEXTYPE" },
{ 166, "ALTER INDEXTYPE" },
{ 167, "DROP OPERATOR" },
{ 168, "ASSOCIATE STATISTICS" },
{ 169, "DISASSOCIATE STATISTICS" },
{ 170, "CALL METHOD" },
{ 171, "CREATE SUMMARY" },
{ 172, "ALTER SUMMARY" },
{ 173, "DROP SUMMARY" },
{ 174, "CREATE DIMENSION" },
{ 175, "ALTER DIMENSION" },
{ 176, "DROP DIMENSION" },
{ 177, "CREATE CONTEXT" },
{ 178, "DROP CONTEXT" },
{ 179, "ALTER OUTLINE" },
{ 180, "CREATE OUTLINE" },
{ 181, "DROP OUTLINE" },
{ 182, "UPDATE INDEXES" },
{ 183, "ALTER OPERATOR" },
{ 0, NULL }
};
for (i=0; sqlfnlist[i].sqlfnid; i++)
if (sqlfnlist[i].sqlfnid == sqlfncode)
return sqlfnlist[i].statement;
return NULL;
}
char *getsqltypename(int sqltypecode) {
int i;
/*
* from
* http://download.oracle.com/docs/cd/E18283_01/appdev.112/e10646/oci03typ.htm#i446338
*/
static const sqltypecode_t sqltypecodelist[] = {
{ OCI_TYPECODE_BFILE, "BFILE" },
{ OCI_TYPECODE_BLOB, "BLOB" },
{ OCI_TYPECODE_CHAR, "CHAR" },
{ OCI_TYPECODE_CLOB, "CLOB" },
{ OCI_TYPECODE_NAMEDCOLLECTION, "COLLECTION" },
{ OCI_TYPECODE_DATE, "DATE" },
{ OCI_TYPECODE_TIMESTAMP, "TIMESTAMP" },
{ OCI_TYPECODE_TIMESTAMP_TZ, "TIMESTAMP WITH TIME ZONE" },
{ OCI_TYPECODE_TIMESTAMP_LTZ, "TIMESTAMP WITH LOCAL TIME ZONE" },
{ OCI_TYPECODE_INTERVAL_YM, "INTERVAL YEAR TO MONTH" },
{ OCI_TYPECODE_INTERVAL_DS, "INTERVAL DAY TO SECOND" },
{ OCI_TYPECODE_FLOAT, "FLOAT" },
{ OCI_TYPECODE_DECIMAL, "DECIMAL" },
{ OCI_TYPECODE_DOUBLE, "DOUBLE" },
{ OCI_TYPECODE_BFLOAT, "BINARY_FLOAT" },
{ OCI_TYPECODE_BDOUBLE, "BINARY_DOUBLE" },
{ OCI_TYPECODE_INTEGER, "INTEGER" },
{ OCI_TYPECODE_NUMBER, "NUMBER" },
{ OCI_TYPECODE_OCTET, "OCTET" },
{ OCI_TYPECODE_PTR, "POINTER" },
{ OCI_TYPECODE_RAW, "RAW" },
{ OCI_TYPECODE_REAL, "REAL" },
{ OCI_TYPECODE_REF, "REF" },
{ OCI_TYPECODE_OBJECT, "OBJECT" },
{ OCI_TYPECODE_SIGNED8, "SIGNED(8)" },
{ OCI_TYPECODE_SIGNED16, "SIGNED(16)" },
{ OCI_TYPECODE_SIGNED32, "SIGNED(32)" },
{ OCI_TYPECODE_SMALLINT, "SMALLINT" },
{ OCI_TYPECODE_TABLE, "TABLE" },
{ OCI_TYPECODE_UNSIGNED8, "UNSIGNED(8)" },
{ OCI_TYPECODE_UNSIGNED16, "UNSIGNED(16)" },
{ OCI_TYPECODE_UNSIGNED32, "UNSIGNED(32)" },
{ OCI_TYPECODE_VARRAY, "VARRAY" },
{ OCI_TYPECODE_VARCHAR, "VARCHAR" },
{ OCI_TYPECODE_VARCHAR2, "VARCHAR2" },
{ 0, NULL }
};
for (i=0; sqltypecodelist[i].typename != NULL; i++)
if (sqltypecodelist[i].typecode == sqltypecode)
return sqltypecodelist[i].typename;
return NULL;
}