Class: ODPI::Dpi::Stmt

Inherits:
Object
  • Object
show all
Defined in:
ext/odpi_ext/rbdpi-stmt.c

Instance Method Summary collapse

Constructor Details

#initializeObject


41
42
43
44
45
# File 'ext/odpi_ext/rbdpi.c', line 41

VALUE rbdpi_initialize_error(VALUE self)
{
    rb_raise(rb_eRuntimeError, "could not initialize by %s::new", rb_obj_classname(self));
    return Qnil;
}

Instance Method Details

#batch_errorsObject


212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'ext/odpi_ext/rbdpi-stmt.c', line 212

static VALUE stmt_get_batch_errors(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t idx, count;
    dpiErrorInfo *errors;
    VALUE ary;

    CHK(dpiStmt_getBatchErrorCount(stmt->handle, &count));
    if (count == 0) {
        return rb_ary_new();
    }
    errors = ALLOCA_N(dpiErrorInfo, count);
    CHK(dpiStmt_getBatchErrors(stmt->handle, count, errors));
    ary = rb_ary_new_capa(count);
    for (idx = 0; idx < count; idx++) {
        rb_ary_push(ary, rbdpi_from_dpiErrorInfo(&errors[idx]));
    }
    return ary;
}

#bind_by_name(name, var) ⇒ Object


124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'ext/odpi_ext/rbdpi-stmt.c', line 124

static VALUE stmt_bind_by_name(VALUE self, VALUE name, VALUE var)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    if (SYMBOL_P(name)) {
        name = rb_sym2str(name);
    }
    CHK_STR_ENC(name, stmt->enc.enc);
    CHK(dpiStmt_bindByName(stmt->handle, RSTRING_PTR(name),
                           RSTRING_LEN(name), rbdpi_to_var(var)->handle));
    RB_GC_GUARD(name);
    return self;
}

#bind_by_pos(pos, var) ⇒ Object


138
139
140
141
142
143
144
# File 'ext/odpi_ext/rbdpi-stmt.c', line 138

static VALUE stmt_bind_by_pos(VALUE self, VALUE pos, VALUE var)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    CHK(dpiStmt_bindByPos(stmt->handle, NUM2UINT(pos), rbdpi_to_var(var)->handle));
    return self;
}

#bind_namesObject


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'ext/odpi_ext/rbdpi-stmt.c', line 232

static VALUE stmt_get_bind_names(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t idx, count;
    const char **names;
    uint32_t *lengths;
    VALUE ary;

    CHK(dpiStmt_getBindCount(stmt->handle, &count));
    names = ALLOCA_N(const char*, count);
    lengths = ALLOCA_N(uint32_t, count);
    CHK(dpiStmt_getBindNames(stmt->handle, &count, names, lengths));
    ary = rb_ary_new_capa(count);
    for (idx = 0; idx < count; idx++) {
        rb_ary_push(ary, rb_external_str_new_with_enc(names[idx], lengths[idx], stmt->enc.enc));
    }
    return ary;
}

#close(tag) ⇒ Object


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'ext/odpi_ext/rbdpi-stmt.c', line 146

static VALUE stmt_close(VALUE self, VALUE tag)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    const char *tagptr = NULL;
    uint32_t taglen = 0;

    if (!NIL_P(tag)) {
        CHK_STR_ENC(tag, stmt->enc.enc);
        tagptr = RSTRING_PTR(tag);
        taglen = RSTRING_LEN(tag);
    }
    CHK(dpiStmt_close(stmt->handle, tagptr, taglen));
    RB_GC_GUARD(tag);
    return self;
}

#ddl?Boolean

Returns:

  • (Boolean)

96
97
98
99
100
101
# File 'ext/odpi_ext/rbdpi-stmt.c', line 96

static VALUE stmt_is_ddl_p(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return stmt->info.isDDL ? Qtrue : Qfalse;
}

#define(pos, var) ⇒ Object


162
163
164
165
166
167
168
# File 'ext/odpi_ext/rbdpi-stmt.c', line 162

static VALUE stmt_define(VALUE self, VALUE pos, VALUE var)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    CHK(dpiStmt_define(stmt->handle, NUM2UINT(pos), rbdpi_to_var(var)->handle));
    return self;
}

#dml?Boolean

Returns:

  • (Boolean)

103
104
105
106
107
108
# File 'ext/odpi_ext/rbdpi-stmt.c', line 103

static VALUE stmt_is_dml_p(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return stmt->info.isDML ? Qtrue : Qfalse;
}

#execute(mode) ⇒ Object


170
171
172
173
174
175
176
177
# File 'ext/odpi_ext/rbdpi-stmt.c', line 170

static VALUE stmt_execute(VALUE self, VALUE mode)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t num_cols;

    CHK(dpiStmt_execute(stmt->handle, rbdpi_to_dpiExecMode(mode), &num_cols));
    return UINT2NUM(num_cols);
}

#execute_many(mode, num_iters) ⇒ Object


179
180
181
182
183
184
185
# File 'ext/odpi_ext/rbdpi-stmt.c', line 179

static VALUE stmt_execute_many(VALUE self, VALUE mode, VALUE num_iters)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    CHK(dpiStmt_executeMany(stmt->handle, rbdpi_to_dpiExecMode(mode), NUM2UINT(num_iters)));
    return Qnil;
}

#fetchObject


187
188
189
190
191
192
193
194
195
# File 'ext/odpi_ext/rbdpi-stmt.c', line 187

static VALUE stmt_fetch(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    int found;
    uint32_t index;

    CHK(dpiStmt_fetch(stmt->handle, &found, &index));
    return found ? UINT2NUM(index) : Qnil;
}

#fetch_array_sizeObject


251
252
253
254
255
256
257
258
# File 'ext/odpi_ext/rbdpi-stmt.c', line 251

static VALUE stmt_get_fetch_array_size(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t size;

    CHK(dpiStmt_getFetchArraySize(stmt->handle, &size));
    return UINT2NUM(size);
}

#fetch_array_size=(val) ⇒ Object


341
342
343
344
345
346
347
# File 'ext/odpi_ext/rbdpi-stmt.c', line 341

static VALUE stmt_set_fetch_array_size(VALUE self, VALUE val)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    CHK(dpiStmt_setFetchArraySize(stmt->handle, NUM2UINT(val)));
    return val;
}

#fetch_rows(max_rows) ⇒ Object


197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'ext/odpi_ext/rbdpi-stmt.c', line 197

static VALUE stmt_fetch_rows(VALUE self, VALUE max_rows)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t index;
    uint32_t rows;
    int more_rows;

    CHK(dpiStmt_fetchRows(stmt->handle, NUM2UINT(max_rows), &index, &rows, &more_rows));
    if (rows) {
        return rb_ary_new_from_args(3, UINT2NUM(index), UINT2NUM(rows), more_rows ? Qtrue : Qfalse);
    } else {
        return Qnil;
    }
}

#implicit_resultObject


260
261
262
263
264
265
266
267
268
269
270
271
# File 'ext/odpi_ext/rbdpi-stmt.c', line 260

static VALUE stmt_get_implicit_result(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    dpiStmt *result;

    CHK(dpiStmt_getImplicitResult(stmt->handle, &result));
    if (result != NULL) {
        return rbdpi_from_stmt(result, &stmt->enc);
    } else {
        return Qnil;
    }
}

#initialize_copy(other) ⇒ Object


71
72
73
74
75
76
77
78
79
80
# File 'ext/odpi_ext/rbdpi-stmt.c', line 71

static VALUE stmt_initialize_copy(VALUE self, VALUE other)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    *stmt = *rbdpi_to_stmt(other);
    if (stmt->handle != NULL) {
        CHK(dpiStmt_addRef(stmt->handle));
    }
    return self;
}

#plsql?Boolean

Returns:

  • (Boolean)

89
90
91
92
93
94
# File 'ext/odpi_ext/rbdpi-stmt.c', line 89

static VALUE stmt_is_plsql_p(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return stmt->info.isPLSQL ? Qtrue : Qfalse;
}

#query?Boolean

Returns:

  • (Boolean)

82
83
84
85
86
87
# File 'ext/odpi_ext/rbdpi-stmt.c', line 82

static VALUE stmt_is_query_p(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return stmt->info.isQuery ? Qtrue : Qfalse;
}

#query_columnsObject


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'ext/odpi_ext/rbdpi-stmt.c', line 273

static VALUE stmt_get_query_columns(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t num;

    if (stmt->query_columns_cache != Qfalse) {
        return stmt->query_columns_cache;
    }
    CHK(dpiStmt_getNumQueryColumns(stmt->handle, &num));
    if (num != 0) {
        VALUE ary = rb_ary_new_capa(num);
        uint32_t idx;

        for (idx = 1; idx <= num; idx++) {
            dpiQueryInfo info;

            CHK(dpiStmt_getQueryInfo(stmt->handle, idx, &info));
            rb_ary_push(ary, rbdpi_from_dpiQueryInfo(&info, &stmt->enc));
        }
        OBJ_FREEZE(ary);
        stmt->query_columns_cache = ary;
    } else {
        stmt->query_columns_cache = Qnil;
    }
    return stmt->query_columns_cache;
}

#returning?Boolean

Returns:

  • (Boolean)

117
118
119
120
121
122
# File 'ext/odpi_ext/rbdpi-stmt.c', line 117

static VALUE stmt_is_returning_p(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return stmt->info.isReturning ? Qtrue : Qfalse;
}

#row_countObject


300
301
302
303
304
305
306
307
# File 'ext/odpi_ext/rbdpi-stmt.c', line 300

static VALUE stmt_get_row_count(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint64_t count;

    CHK(dpiStmt_getRowCount(stmt->handle, &count));
    return ULL2NUM(count);
}

#row_countsObject


309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'ext/odpi_ext/rbdpi-stmt.c', line 309

static VALUE stmt_get_row_counts(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint32_t idx, numRowCounts;
    uint64_t *rowCounts;
    VALUE ary;

    CHK(dpiStmt_getRowCounts(stmt->handle, &numRowCounts, &rowCounts));
    ary = rb_ary_new_capa(numRowCounts);
    for (idx = 0; idx < numRowCounts; idx++) {
        rb_ary_store(ary, idx, ULL2NUM(rowCounts[idx]));
    }
    return ary;
}

#scroll(mode, offset, row_count_offset) ⇒ Object


333
334
335
336
337
338
339
# File 'ext/odpi_ext/rbdpi-stmt.c', line 333

static VALUE stmt_scroll(VALUE self, VALUE mode, VALUE offset, VALUE row_count_offset)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    CHK(dpiStmt_scroll(stmt->handle, rbdpi_to_dpiFetchMode(mode), NUM2INT(offset), NUM2INT(row_count_offset)));
    return self;
}

#statement_typeObject


110
111
112
113
114
115
# File 'ext/odpi_ext/rbdpi-stmt.c', line 110

static VALUE stmt_get_statement_type(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);

    return rbdpi_from_dpiStatementType(stmt->info.statementType);
}

#subscr_query_idObject


324
325
326
327
328
329
330
331
# File 'ext/odpi_ext/rbdpi-stmt.c', line 324

static VALUE stmt_get_subscr_query_id(VALUE self)
{
    stmt_t *stmt = rbdpi_to_stmt(self);
    uint64_t query_id;

    CHK(dpiStmt_getSubscrQueryId(stmt->handle, &query_id));
    return ULL2NUM(query_id);
}