ruby-oci8 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/ChangeLog +569 -0
  2. data/Makefile +51 -0
  3. data/NEWS +322 -0
  4. data/README +415 -0
  5. data/VERSION +1 -0
  6. data/dist-files +70 -0
  7. data/doc/api.en.html +527 -0
  8. data/doc/api.en.rd +554 -0
  9. data/doc/api.ja.html +525 -0
  10. data/doc/api.ja.rd +557 -0
  11. data/doc/manual.css +35 -0
  12. data/ext/oci8/MANIFEST +22 -0
  13. data/ext/oci8/attr.c +415 -0
  14. data/ext/oci8/bind.c +194 -0
  15. data/ext/oci8/const.c +165 -0
  16. data/ext/oci8/define.c +53 -0
  17. data/ext/oci8/describe.c +81 -0
  18. data/ext/oci8/descriptor.c +39 -0
  19. data/ext/oci8/env.c +276 -0
  20. data/ext/oci8/error.c +234 -0
  21. data/ext/oci8/extconf.rb +118 -0
  22. data/ext/oci8/handle.c +262 -0
  23. data/ext/oci8/lob.c +386 -0
  24. data/ext/oci8/oci8.c +137 -0
  25. data/ext/oci8/oci8.h +345 -0
  26. data/ext/oci8/ocinumber.c +117 -0
  27. data/ext/oci8/oraconf.rb +1026 -0
  28. data/ext/oci8/oradate.c +426 -0
  29. data/ext/oci8/oranumber.c +445 -0
  30. data/ext/oci8/param.c +37 -0
  31. data/ext/oci8/post-config.rb +5 -0
  32. data/ext/oci8/server.c +182 -0
  33. data/ext/oci8/session.c +99 -0
  34. data/ext/oci8/stmt.c +624 -0
  35. data/ext/oci8/svcctx.c +229 -0
  36. data/lib/DBD/OCI8/OCI8.rb +549 -0
  37. data/lib/oci8.rb.in +1605 -0
  38. data/metaconfig +142 -0
  39. data/pre-distclean.rb +7 -0
  40. data/ruby-oci8.gemspec +54 -0
  41. data/ruby-oci8.spec +62 -0
  42. data/setup.rb +1331 -0
  43. data/support/README +4 -0
  44. data/support/runit/assert.rb +281 -0
  45. data/support/runit/cui/testrunner.rb +101 -0
  46. data/support/runit/error.rb +4 -0
  47. data/support/runit/method_mappable.rb +20 -0
  48. data/support/runit/robserver.rb +25 -0
  49. data/support/runit/setuppable.rb +15 -0
  50. data/support/runit/teardownable.rb +16 -0
  51. data/support/runit/testcase.rb +113 -0
  52. data/support/runit/testfailure.rb +25 -0
  53. data/support/runit/testresult.rb +121 -0
  54. data/support/runit/testsuite.rb +43 -0
  55. data/support/runit/version.rb +3 -0
  56. data/test/README +4 -0
  57. data/test/config.rb +129 -0
  58. data/test/test_all.rb +43 -0
  59. data/test/test_bind_raw.rb +53 -0
  60. data/test/test_bind_time.rb +191 -0
  61. data/test/test_break.rb +81 -0
  62. data/test/test_clob.rb +101 -0
  63. data/test/test_connstr.rb +80 -0
  64. data/test/test_dbi.rb +317 -0
  65. data/test/test_dbi_clob.rb +56 -0
  66. data/test/test_describe.rb +137 -0
  67. data/test/test_metadata.rb +243 -0
  68. data/test/test_oci8.rb +273 -0
  69. data/test/test_oradate.rb +263 -0
  70. data/test/test_oranumber.rb +149 -0
  71. metadata +118 -0
@@ -0,0 +1,194 @@
1
+ /*
2
+ define.c - part of ruby-oci8
3
+
4
+ Copyright (C) 2002,2006 KUBO Takehiro <kubo@jiubao.org>
5
+
6
+ =begin
7
+ == OCIBind
8
+ The bind handle, which is created by ((<OCIStmt#bindByPos>)) or ((<OCIStmt#bindByName>)).
9
+
10
+ super class: ((<OCIHandle>))
11
+
12
+ correspond native OCI datatype: ((|OCIBind|))
13
+ =end
14
+ */
15
+ #include "oci8.h"
16
+
17
+ /*
18
+ =begin
19
+ --- OCIBind#get()
20
+ get the bind value, which set by OCI call.
21
+
22
+ :return value
23
+ the bind value. Its datatype is correspond to the 2nd argument of ((<OCIStmt#bindByPos>)) or ((<OCIStmt#bindByName>)).
24
+
25
+ correspond native OCI function: nothing
26
+ =end
27
+ */
28
+ static VALUE oci8_get_data(VALUE self)
29
+ {
30
+ oci8_bind_handle_t *defnhp;
31
+ VALUE obj;
32
+
33
+ Data_Get_Struct(self, oci8_bind_handle_t, defnhp);
34
+ obj = oci8_get_value(defnhp);
35
+ return obj;
36
+ }
37
+
38
+ /*
39
+ =begin
40
+ --- OCIBind#set(value)
41
+ get the bind value to pass Oracle via OCI call.
42
+
43
+ :value
44
+ the value to set the bind handle. Its datatype must be correspond to the 2nd argument of ((<OCIStmt#bindByPos>)) or ((<OCIStmt#bindByName>)).
45
+
46
+ correspond native OCI function: nothing
47
+ =end
48
+ */
49
+ static VALUE oci8_set_data(VALUE self, VALUE val)
50
+ {
51
+ oci8_bind_handle_t *hp;
52
+
53
+ Data_Get_Struct(self, oci8_bind_handle_t, hp);
54
+ oci8_set_value(hp, val);
55
+ return self;
56
+ }
57
+
58
+ void Init_oci8_bind(void)
59
+ {
60
+ rb_define_method(cOCIBind, "get", oci8_get_data, 0);
61
+ rb_define_method(cOCIBind, "set", oci8_set_data, 1);
62
+ }
63
+
64
+ VALUE oci8_get_value(oci8_bind_handle_t *hp)
65
+ {
66
+ ora_date_t *od;
67
+ ora_vnumber_t *ovn;
68
+ VALUE obj;
69
+ unsigned char buf[ORA_NUMBER_BUF_SIZE];
70
+ int year, month, day, hour, minute, second;
71
+ static ID id_local = (ID)-1;
72
+
73
+ if (hp->ind != 0)
74
+ return Qnil;
75
+ switch (hp->bind_type) {
76
+ case BIND_STRING:
77
+ return rb_str_new(hp->value.str.buf, hp->value.str.len);
78
+ case BIND_FIXNUM:
79
+ return LONG2NUM(hp->value.lng);
80
+ case BIND_INTEGER_VIA_ORA_NUMBER:
81
+ ora_number_to_str(buf, NULL, &(hp->value.on), hp->rlen);
82
+ return rb_cstr2inum(TO_CHARPTR(buf), 10);
83
+ case BIND_TIME_VIA_ORA_DATE:
84
+ oci8_get_ora_date(&(hp->value.od), &year, &month, &day, &hour, &minute, &second);
85
+ if (id_local == (ID)-1)
86
+ id_local = rb_intern("local");
87
+ return rb_funcall(rb_cTime, id_local, 6, INT2FIX(year), INT2FIX(month), INT2FIX(day), INT2FIX(hour), INT2FIX(minute), INT2FIX(second));
88
+ case BIND_FLOAT:
89
+ case BIND_BINARY_DOUBLE:
90
+ return rb_float_new(hp->value.dbl);
91
+ case BIND_ORA_DATE:
92
+ obj = Data_Make_Struct(cOraDate, ora_date_t, NULL, xfree, od);
93
+ memcpy(od, &(hp->value.od), sizeof(ora_date_t));
94
+ return obj;
95
+ case BIND_ORA_NUMBER:
96
+ obj = Data_Make_Struct(cOraNumber, ora_vnumber_t, NULL, xfree, ovn);
97
+ ovn->size = hp->rlen;
98
+ memcpy(&(ovn->num), &(hp->value.on), sizeof(ora_number_t));
99
+ return obj;
100
+ case BIND_HANDLE:
101
+ return hp->value.handle.v;
102
+ }
103
+ rb_bug("unsupported data type: %d", hp->bind_type);
104
+ }
105
+
106
+ void oci8_set_value(oci8_bind_handle_t *hp, VALUE val)
107
+ {
108
+ ora_date_t *od;
109
+ ora_vnumber_t *ovn;
110
+ int year, mon, day, hour, min, sec;
111
+ static ID id_year = (ID)-1;
112
+ static ID id_mon = (ID)-1;
113
+ static ID id_day = (ID)-1;
114
+ static ID id_hour = (ID)-1;
115
+ static ID id_min = (ID)-1;
116
+ static ID id_sec = (ID)-1;
117
+
118
+ if (NIL_P(val)) {
119
+ hp->ind = -1;
120
+ return;
121
+ }
122
+ switch (hp->bind_type) {
123
+ case BIND_FIXNUM:
124
+ Check_Type(val, T_FIXNUM);
125
+ hp->value.lng = FIX2LONG(val);
126
+ break;
127
+ case BIND_STRING:
128
+ Check_Type(val, T_STRING);
129
+ if (hp->value_sz - 4 < RSTRING_LEN(val)) {
130
+ rb_raise(rb_eArgError, "Assigned string is too long. %ld (max %d)", RSTRING_LEN(val), hp->value_sz - 4);
131
+ }
132
+ memcpy(hp->value.str.buf, RSTRING_PTR(val), RSTRING_LEN(val));
133
+ hp->value.str.len = RSTRING_LEN(val);
134
+ break;
135
+ case BIND_TIME_VIA_ORA_DATE:
136
+ if (!rb_obj_is_instance_of(val, rb_cTime)) {
137
+ rb_raise(rb_eTypeError, "invalid argument (expect Time)");
138
+ }
139
+ #define GET_TIME_OF_XXX(name) \
140
+ if (id_##name == (ID)-1) \
141
+ id_##name = rb_intern(#name); \
142
+ name = FIX2INT(rb_funcall(val, id_##name, 0))
143
+ GET_TIME_OF_XXX(year);
144
+ GET_TIME_OF_XXX(mon);
145
+ GET_TIME_OF_XXX(day);
146
+ GET_TIME_OF_XXX(hour);
147
+ GET_TIME_OF_XXX(min);
148
+ GET_TIME_OF_XXX(sec);
149
+ oci8_set_ora_date(&(hp->value.od), year, mon, day, hour, min, sec);
150
+ break;
151
+ case BIND_FLOAT:
152
+ case BIND_BINARY_DOUBLE:
153
+ Check_Type(val, T_FLOAT);
154
+ hp->value.dbl = RFLOAT(val)->value;
155
+ break;
156
+ case BIND_ORA_DATE:
157
+ if (!rb_obj_is_instance_of(val, cOraDate)) {
158
+ rb_raise(rb_eTypeError, "invalid argument (expect OraDate)");
159
+ }
160
+ Data_Get_Struct(val, ora_date_t, od);
161
+ memcpy(&(hp->value.od), od, sizeof(ora_date_t));
162
+ break;
163
+ case BIND_INTEGER_VIA_ORA_NUMBER:
164
+ case BIND_ORA_NUMBER:
165
+ if (rb_obj_is_instance_of(val, cOraNumber)) {
166
+ Data_Get_Struct(val, ora_vnumber_t, ovn);
167
+ hp->rlen = ovn->size;
168
+ memcpy(&(hp->value.on), &(ovn->num), sizeof(ora_number_t));
169
+ } else if (rb_obj_is_kind_of(val, rb_cNumeric)) {
170
+ ora_vnumber_t ovn;
171
+ if (set_oci_vnumber(&ovn, val, hp->errhp) == 0) {
172
+ rb_raise(rb_eTypeError, "could not bind value.");
173
+ }
174
+ hp->rlen = ovn.size;
175
+ memcpy(&(hp->value.on), &(ovn.num), sizeof(ora_number_t));
176
+ } else {
177
+ rb_raise(rb_eTypeError, "invalid argument (expect OraNumber)");
178
+ }
179
+ break;
180
+ case BIND_HANDLE:
181
+ if (rb_obj_is_kind_of(val, hp->value.handle.klass)) {
182
+ oci8_handle_t *h;
183
+ Get_Handle(val, h);
184
+ hp->value.handle.v = val;
185
+ hp->value.handle.hp = h->hp;
186
+ } else {
187
+ rb_raise(rb_eTypeError, "invalid argument: %s (expect %s)", rb_obj_classname(val), rb_class2name(hp->value.handle.klass));
188
+ }
189
+ break;
190
+ default:
191
+ rb_bug("unsupported data type: %d", hp->bind_type);
192
+ }
193
+ hp->ind = 0;
194
+ }
@@ -0,0 +1,165 @@
1
+ /*
2
+ const.c - part of ruby-oci8
3
+
4
+ Copyright (C) 2002-2006 KUBO Takehiro <kubo@jiubao.org>
5
+
6
+ define constant values.
7
+ */
8
+ #include "oci8.h"
9
+
10
+ ID oci8_id_code;
11
+ ID oci8_id_define_array;
12
+ ID oci8_id_bind_hash;
13
+ ID oci8_id_message;
14
+ ID oci8_id_new;
15
+ ID oci8_id_parse_error_offset;
16
+ ID oci8_id_server;
17
+ ID oci8_id_session;
18
+ ID oci8_id_sql;
19
+
20
+ struct oci8_names {
21
+ const char *name;
22
+ VALUE value;
23
+ };
24
+ typedef struct oci8_names oci8_names_t;
25
+ #define ENTRY(name) {#name, INT2FIX(name)}
26
+
27
+ static oci8_names_t oci8_typecode[] = {
28
+ ENTRY(OCI_TYPECODE_VARCHAR), /* 1(SQLT_CHR) */
29
+ ENTRY(OCI_TYPECODE_NUMBER), /* 2(SQLT_NUM) */
30
+ ENTRY(OCI_TYPECODE_DATE), /* 12(SQLT_DAT) */
31
+ ENTRY(OCI_TYPECODE_UNSIGNED8), /* 23(SQLT_BIN) */
32
+ ENTRY(OCI_TYPECODE_RAW), /* 95(SQLT_LVB) */
33
+ ENTRY(OCI_TYPECODE_CHAR), /* 96(SQLT_AFC) */
34
+ #ifdef OCI_TYPECODE_BDOUBLE
35
+ ENTRY(OCI_TYPECODE_BDOUBLE), /* 101(SQLT_IBDOUBLE) */
36
+ #endif
37
+ ENTRY(OCI_TYPECODE_OBJECT), /* 108(SQLT_NTY) */
38
+ ENTRY(OCI_TYPECODE_BLOB), /* 113(SQLT_BLOB) */
39
+ ENTRY(OCI_TYPECODE_CLOB), /* 112(SQLT_CLOB) */
40
+ ENTRY(OCI_TYPECODE_NAMEDCOLLECTION), /* 122(SQLT_NCO) */
41
+ ENTRY(SQLT_RDD) /* 104 */
42
+ };
43
+ #define NUM_OF_OCI8_TYPECODE (sizeof(oci8_typecode) / sizeof(oci8_typecode[0]))
44
+
45
+ static VALUE oci8_make_names(oci8_names_t *names, size_t size)
46
+ {
47
+ volatile VALUE ary;
48
+ int i;
49
+
50
+ ary = rb_ary_new();
51
+ for (i = 0;i < size;i++)
52
+ rb_ary_store(ary, FIX2INT(names[i].value), rb_str_new2(names[i].name));
53
+ return ary;
54
+ }
55
+
56
+ void Init_oci8_const(void)
57
+ {
58
+ int i;
59
+
60
+ oci8_id_code = rb_intern("code");
61
+ oci8_id_define_array = rb_intern("define_array");
62
+ oci8_id_bind_hash = rb_intern("bind_hash");
63
+ oci8_id_message = rb_intern("message");
64
+ oci8_id_new = rb_intern("new");
65
+ oci8_id_parse_error_offset = rb_intern("parse_error_offset");
66
+ oci8_id_server = rb_intern("server");
67
+ oci8_id_session = rb_intern("session");
68
+ oci8_id_sql = rb_intern("sql");
69
+
70
+ rb_define_global_const("OCI_DEFAULT", INT2FIX(OCI_DEFAULT));
71
+ rb_define_global_const("OCI_OBJECT", INT2FIX(OCI_OBJECT));
72
+ rb_define_global_const("OCI_CRED_RDBMS", INT2FIX(OCI_CRED_RDBMS));
73
+ rb_define_global_const("OCI_CRED_EXT", INT2FIX(OCI_CRED_EXT));
74
+ rb_define_global_const("OCI_MIGRATE", INT2FIX(OCI_MIGRATE));
75
+ rb_define_global_const("OCI_SYSDBA", INT2FIX(OCI_SYSDBA));
76
+ rb_define_global_const("OCI_SYSOPER", INT2FIX(OCI_SYSOPER));
77
+ rb_define_global_const("OCI_PRELIM_AUTH", INT2FIX(OCI_PRELIM_AUTH));
78
+
79
+ /* OCIStmt#prepare */
80
+ rb_define_global_const("OCI_NTV_SYNTAX", INT2FIX(OCI_NTV_SYNTAX));
81
+ rb_define_global_const("OCI_V7_SYNTAX", INT2FIX(OCI_V7_SYNTAX));
82
+ rb_define_global_const("OCI_V8_SYNTAX", INT2FIX(OCI_V8_SYNTAX));
83
+
84
+ /* OCIStmt#execute */
85
+ #ifdef OCI_BATCH_ERRORS
86
+ rb_define_global_const("OCI_BATCH_ERRORS", INT2FIX(OCI_BATCH_ERRORS));
87
+ #endif
88
+ rb_define_global_const("OCI_COMMIT_ON_SUCCESS", INT2FIX(OCI_COMMIT_ON_SUCCESS));
89
+ rb_define_global_const("OCI_DESCRIBE_ONLY", INT2FIX(OCI_DESCRIBE_ONLY));
90
+ rb_define_global_const("OCI_EXACT_FETCH", INT2FIX(OCI_EXACT_FETCH));
91
+ #ifdef OCI_PARSE_ONLY
92
+ rb_define_global_const("OCI_PARSE_ONLY", INT2FIX(OCI_PARSE_ONLY));
93
+ #endif
94
+ #ifdef OCI_STMT_SCROLLABLE_READONLY
95
+ rb_define_global_const("OCI_STMT_SCROLLABLE_READONLY", INT2FIX(OCI_STMT_SCROLLABLE_READONLY));
96
+ #endif
97
+
98
+ rb_define_global_const("OCI_AUTH", INT2FIX(OCI_AUTH));
99
+ #ifdef OCI_SHARED
100
+ rb_define_global_const("OCI_SHARED", INT2FIX(OCI_SHARED));
101
+ #endif
102
+ #ifdef OCI_CPOOL
103
+ rb_define_global_const("OCI_CPOOL", INT2FIX(OCI_CPOOL));
104
+ #endif
105
+ #ifdef OCI_NO_SHARING
106
+ rb_define_global_const("OCI_NO_SHARING", INT2FIX(OCI_NO_SHARING));
107
+ #endif
108
+
109
+ rb_define_global_const("OCI_FETCH_NEXT", INT2FIX(OCI_FETCH_NEXT));
110
+
111
+ for (i = 0;i < oci8_attr_size;i++) {
112
+ rb_define_global_const(oci8_attr_list[i].name, INT2FIX(i));
113
+ }
114
+
115
+ /* TYPE CODE */
116
+ for (i = 0;i < NUM_OF_OCI8_TYPECODE;i++)
117
+ rb_define_global_const(oci8_typecode[i].name, oci8_typecode[i].value);
118
+ rb_define_global_const("OCI_TYPECODE_NAMES", oci8_make_names(oci8_typecode, NUM_OF_OCI8_TYPECODE));
119
+
120
+ /* OCI Parameter Types */
121
+ rb_define_global_const("OCI_PTYPE_UNK", INT2FIX(OCI_PTYPE_UNK));
122
+ rb_define_global_const("OCI_PTYPE_TABLE", INT2FIX(OCI_PTYPE_TABLE));
123
+ rb_define_global_const("OCI_PTYPE_VIEW", INT2FIX(OCI_PTYPE_VIEW));
124
+ rb_define_global_const("OCI_PTYPE_PROC", INT2FIX(OCI_PTYPE_PROC));
125
+ rb_define_global_const("OCI_PTYPE_FUNC", INT2FIX(OCI_PTYPE_FUNC));
126
+ rb_define_global_const("OCI_PTYPE_PKG", INT2FIX(OCI_PTYPE_PKG));
127
+ rb_define_global_const("OCI_PTYPE_TYPE", INT2FIX(OCI_PTYPE_TYPE));
128
+ rb_define_global_const("OCI_PTYPE_SYN", INT2FIX(OCI_PTYPE_SYN));
129
+ rb_define_global_const("OCI_PTYPE_SEQ", INT2FIX(OCI_PTYPE_SEQ));
130
+ rb_define_global_const("OCI_PTYPE_COL", INT2FIX(OCI_PTYPE_COL));
131
+ rb_define_global_const("OCI_PTYPE_ARG", INT2FIX(OCI_PTYPE_ARG));
132
+ rb_define_global_const("OCI_PTYPE_LIST", INT2FIX(OCI_PTYPE_LIST));
133
+ rb_define_global_const("OCI_PTYPE_TYPE_ATTR", INT2FIX(OCI_PTYPE_TYPE_ATTR));
134
+ rb_define_global_const("OCI_PTYPE_TYPE_COLL", INT2FIX(OCI_PTYPE_TYPE_COLL));
135
+ rb_define_global_const("OCI_PTYPE_TYPE_METHOD", INT2FIX(OCI_PTYPE_TYPE_METHOD));
136
+ rb_define_global_const("OCI_PTYPE_TYPE_ARG", INT2FIX(OCI_PTYPE_TYPE_ARG));
137
+ rb_define_global_const("OCI_PTYPE_TYPE_RESULT", INT2FIX(OCI_PTYPE_TYPE_RESULT));
138
+ #ifdef OCI_PTYPE_SCHEMA
139
+ rb_define_global_const("OCI_PTYPE_SCHEMA", INT2FIX(OCI_PTYPE_SCHEMA));
140
+ #endif
141
+ #ifdef OCI_PTYPE_DATABASE
142
+ rb_define_global_const("OCI_PTYPE_DATABASE", INT2FIX(OCI_PTYPE_DATABASE));
143
+ #endif
144
+
145
+ /* Bind and Define Options */
146
+ rb_define_global_const("OCI_DATA_AT_EXEC", INT2FIX(OCI_DATA_AT_EXEC));
147
+ rb_define_global_const("OCI_DYNAMIC_FETCH", INT2FIX(OCI_DYNAMIC_FETCH));
148
+
149
+ /* OCI Statement Types */
150
+ rb_define_global_const("OCI_STMT_SELECT", INT2FIX(OCI_STMT_SELECT));
151
+ rb_define_global_const("OCI_STMT_UPDATE", INT2FIX(OCI_STMT_UPDATE));
152
+ rb_define_global_const("OCI_STMT_DELETE", INT2FIX(OCI_STMT_DELETE));
153
+ rb_define_global_const("OCI_STMT_INSERT", INT2FIX(OCI_STMT_INSERT));
154
+ rb_define_global_const("OCI_STMT_CREATE", INT2FIX(OCI_STMT_CREATE));
155
+ rb_define_global_const("OCI_STMT_DROP", INT2FIX(OCI_STMT_DROP));
156
+ rb_define_global_const("OCI_STMT_ALTER", INT2FIX(OCI_STMT_ALTER));
157
+ rb_define_global_const("OCI_STMT_BEGIN", INT2FIX(OCI_STMT_BEGIN));
158
+ rb_define_global_const("OCI_STMT_DECLARE", INT2FIX(OCI_STMT_DECLARE));
159
+
160
+ /* Piece Definitions */
161
+ rb_define_global_const("OCI_ONE_PIECE", INT2FIX(OCI_ONE_PIECE));
162
+ rb_define_global_const("OCI_FIRST_PIECE", INT2FIX(OCI_FIRST_PIECE));
163
+ rb_define_global_const("OCI_NEXT_PIECE", INT2FIX(OCI_NEXT_PIECE));
164
+ rb_define_global_const("OCI_LAST_PIECE", INT2FIX(OCI_LAST_PIECE));
165
+ }
@@ -0,0 +1,53 @@
1
+ /*
2
+ define.c - part of ruby-oci8
3
+
4
+ Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
5
+
6
+ =begin
7
+ == OCIDefine
8
+ The define handle, which is created by ((<OCIStmt#defineByPos>)).
9
+
10
+ The fetched data of select statements is got via this handle.
11
+
12
+ super class: ((<OCIHandle>))
13
+
14
+ correspond native OCI datatype: ((|OCIDefine|))
15
+ =end
16
+ */
17
+ #include "oci8.h"
18
+
19
+ /*
20
+ =begin
21
+ --- OCIDefine#get()
22
+ get the selected date.
23
+
24
+ :return value
25
+ fetched data. Its datatype is correspond to the 2nd argument of ((<OCIStmt#defineByPos>)).
26
+
27
+ correspond native OCI function: nothing
28
+ =end
29
+ */
30
+ static VALUE oci8_get_data(VALUE self)
31
+ {
32
+ oci8_bind_handle_t *defnhp;
33
+ VALUE obj;
34
+
35
+ Data_Get_Struct(self, oci8_bind_handle_t, defnhp);
36
+ obj = oci8_get_value(defnhp);
37
+ return obj;
38
+ }
39
+
40
+ static VALUE oci8_set_data(VALUE self, VALUE val)
41
+ {
42
+ oci8_bind_handle_t *hp;
43
+
44
+ Data_Get_Struct(self, oci8_bind_handle_t, hp);
45
+ oci8_set_value(hp, val);
46
+ return self;
47
+ }
48
+
49
+ void Init_oci8_define(void)
50
+ {
51
+ rb_define_method(cOCIDefine, "get", oci8_get_data, 0);
52
+ rb_define_method(cOCIDefine, "set", oci8_set_data, 1);
53
+ }
@@ -0,0 +1,81 @@
1
+ /*
2
+ describe.c - part of ruby-oci8
3
+
4
+ Copyright (C) 2002 KUBO Takehiro <kubo@jiubao.org>
5
+
6
+ =begin
7
+ == OCIDescribe
8
+ The describe handle, which is used for the explicit describe.
9
+
10
+ super class: ((<OCIHandle>))
11
+
12
+ correspond native OCI datatype: ((|OCIDescribe|))
13
+
14
+ For example:
15
+ dsc = env.alloc(OCIDescribe)
16
+ dsc.describeAny(svc, "EMP", OCI_PTYPE_TABLE)
17
+ parm = dsc.attrGet(OCI_ATTR_PARAM)
18
+ ...get various information from parm...
19
+
20
+ TODO: more explanation and examples.
21
+
22
+ =end
23
+ */
24
+ #include "oci8.h"
25
+
26
+ /*
27
+ =begin
28
+ --- OCIDescribe#describeAny(svc, name, type)
29
+ get various information of Oracle's schema objects: tables, views, synonyms,
30
+ procedures, functions, packages, sequences, and types.
31
+
32
+ :svc
33
+ ((<service context handle|OCISvcCtx>)) in which the object to describe exists.
34
+ :name
35
+ name of object to describe.
36
+ :type
37
+ type of object to describe.
38
+
39
+ * ((|OCI_PTYPE_TABLE|)), for tables
40
+ * ((|OCI_PTYPE_VIEW|)), for views
41
+ * ((|OCI_PTYPE_PROC|)), for procedures
42
+ * ((|OCI_PTYPE_FUNC|)), for functions
43
+ * ((|OCI_PTYPE_PKG|)), for packages
44
+ * ((|OCI_PTYPE_TYPE|)), for types
45
+ * ((|OCI_PTYPE_SYN|)), for synonyms
46
+ * ((|OCI_PTYPE_SEQ|)), for sequences
47
+ * ((|OCI_PTYPE_SCHEMA|)), for schemas
48
+ * ((|OCI_PTYPE_DATABASE|)), for databases
49
+ * ((|OCI_PTYPE_UNK|)), for unknown schema objects
50
+
51
+ correspond native OCI function: ((|OCIDescribeAny|))
52
+
53
+ ((*note*)): To use this method in Oracle 8.0.5 for Linux,
54
+ call OCIEnv.create with OCI_OBJECT or segmentation fault occurs.
55
+ This bug was fixed 8.0.6 or later.
56
+ =end
57
+ */
58
+ static VALUE oci8_describe_any(VALUE self, VALUE vdsc, VALUE vname, VALUE vtype)
59
+ {
60
+ oci8_handle_t *h;
61
+ oci8_handle_t *svch;
62
+ oci8_string_t name;
63
+ ub1 type;
64
+ sword rv;
65
+
66
+ Get_Handle(self, h); /* 0 */
67
+ Check_Handle(vdsc, OCISvcCtx, svch); /* 1 */
68
+ Get_String(vname, name); /* 2 */
69
+ type = FIX2INT(vtype); /* 3 */
70
+
71
+ rv = OCIDescribeAny(svch->hp, h->errhp, name.ptr, name.len, OCI_OTYPE_NAME, OCI_DEFAULT, type, h->hp);
72
+ if (rv != OCI_SUCCESS) {
73
+ oci8_raise(h->errhp, rv, NULL);
74
+ }
75
+ return self;
76
+ }
77
+
78
+ void Init_oci8_describe(void)
79
+ {
80
+ rb_define_method(cOCIDescribe, "describeAny", oci8_describe_any, 3);
81
+ }