func (def *defRowid) define(position int, rset *Rset) error { def.rset = rset // using a character host variable of width between 19 // (18 bytes plus the null-terminator) and 4001 as the // host bind variable for universal ROWID. if len(def.buf) < 4001 { def.buf = make([]byte, 4001) } r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.buf[0]), //void *valuep, C.LENGTH_TYPE(len(def.buf)), //sb8 value_sz, C.SQLT_STR, //ub2 dty, nil, //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defBool) define(position int, columnSize int, isNullable bool, rset *Rset) error { def.rset = rset def.isNullable = isNullable if cap(def.buf) < columnSize { def.buf = make([]byte, columnSize) } //Log.Infof("defBool.define(position=%d, columnSize=%d)", position, columnSize) // Create oci define handle r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.buf[0]), //void *valuep, C.LENGTH_TYPE(columnSize), //sb8 value_sz, C.SQLT_AFC, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defBfile) define(position int, rset *Rset) error { def.rset = rset r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.ociLobLocator), //void *valuep, C.LENGTH_TYPE(unsafe.Sizeof(def.ociLobLocator)), //sb8 value_sz, C.SQLT_FILE, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub4 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defUint64) define(position int, isNullable bool, rset *Rset) error { def.rset = rset def.isNullable = isNullable r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.ociNumber), //void *valuep, C.LENGTH_TYPE(C.sizeof_OCINumber), //sb8 value_sz, C.SQLT_VNU, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defString) define(position int, columnSize int, isNullable bool, rset *Rset) error { def.rset = rset def.isNullable = isNullable //Log.Infof("defString position=%d columnSize=%d", position, columnSize) n := columnSize // AL32UTF8: one db "char" can be 4 bytes on wire, esp. if the database's // character set is not AL32UTF8 (e.g. some 8bit fixed width charset), and // the column is VARCHAR2 with byte semantics. // // For example when the db's charset is EE8ISO8859P2, then a VARCHAR2(1) can // contain an "ű", which is 2 bytes AL32UTF8. if !rset.stmt.ses.srv.dbIsUTF8 { n *= 2 } if n == 0 { n = 2 } if n%2 != 0 { n++ } if def.buf == nil || cap(def.buf) < n { def.buf = make([]byte, n) } // Create oci define handle r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.buf[0]), //void *valuep, C.LENGTH_TYPE(n), //sb8 value_sz, C.SQLT_CHR, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defLongRaw) define(position int, bufSize uint32, isNullable bool, rset *Rset) error { def.rset = rset def.isNullable = isNullable def.buf = make([]byte, int(bufSize)) //logF(true, "position %v, def.buf %v", position, len(def.buf)) r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.buf[0]), //void *valuep, C.LENGTH_TYPE(len(def.buf)), //sb8 value_sz, C.SQLT_LBI, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, &def.returnLength, //ub4 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r == C.OCI_ERROR { return def.rset.stmt.ses.srv.env.ociError() } return nil }
func (def *defLob) define(position int, charsetForm C.ub1, sqlt C.ub2, gct GoColumnType, rset *Rset) error { def.rset = rset def.gct = gct def.sqlt = sqlt def.charsetForm = charsetForm def.ociLobLocator = nil r := C.OCIDEFINEBYPOS( def.rset.ocistmt, //OCIStmt *stmtp, &def.ocidef, //OCIDefine **defnpp, def.rset.stmt.ses.srv.env.ocierr, //OCIError *errhp, C.ub4(position), //ub4 position, unsafe.Pointer(&def.ociLobLocator), //void *valuep, C.LENGTH_TYPE(unsafe.Sizeof(def.ociLobLocator)), //sb8 value_sz, sqlt, //ub2 dty, unsafe.Pointer(&def.null), //void *indp, nil, //ub2 *rlenp, nil, //ub2 *rcodep, C.OCI_DEFAULT) //ub4 mode ); if r != C.OCI_SUCCESS { return def.rset.stmt.ses.srv.env.ociError() } prefetchLength := C.boolean(C.TRUE) return def.rset.stmt.ses.srv.env.setAttr(unsafe.Pointer(def.ocidef), C.OCI_HTYPE_DEFINE, unsafe.Pointer(&prefetchLength), 0, C.OCI_ATTR_LOBPREFETCH_LENGTH) }