Comments (9)
I read about this type it is actually stored as a blob.
Prior to 21c, JSON could be stored as VARCHAR, CLOB, or BLOB types by specifying the AS JSON clause at table creation. At some stage an extra attribute was added so that client apps could differentiate from other VARCHAR, CLOB or BLOBS columns. We only just found this out and added support in eg python-oracledb, see the release notes and ODPI-C commit.
From 21c there is an explicit JSON datatype that can/should be used in preference to the above, older table creation syntax.
from go-ora.
sorry for late I will test the data type and its network representation and update the package
from go-ora.
I find the solution i will add it to next release
thanks to oracle-db python driver
&go_ora.ParameterInfo{Name:"JSON_VAL", TypeName:"", SchemaName:"", DomainSchema:"", DomainName:"", Direction:0, IsNull:false, AllowNull:true, IsJson:true, ColAlias:"", DataType:113, IsXmlType:false, Flag:0x0, Precision:0x0, Scale:0x0, MaxLen:4000, MaxCharLen:0, MaxNoOfArrayElements:0, ContFlag:0, ToID:[]uint8(nil), Version:0, CharsetID:0, CharsetForm:0, BValue:[]uint8(nil), Value:driver.Value(nil), iPrimValue:driver.Value(nil), oPrimValue:driver.Value(nil), OutputVarPtr:interface {}(nil), getDataFromServer:true, oaccollid:0, cusType:(*go_ora.customType)(nil), Annotations:map[string]string(nil)}
&go_ora.ParameterInfo{Name:"BLOB_VAL", TypeName:"", SchemaName:"", DomainSchema:"", DomainName:"", Direction:0, IsNull:false, AllowNull:true, IsJson:false, ColAlias:"", DataType:113, IsXmlType:false, Flag:0x0, Precision:0x0, Scale:0x0, MaxLen:4000, MaxCharLen:0, MaxNoOfArrayElements:0, ContFlag:0, ToID:[]uint8(nil), Version:0, CharsetID:0, CharsetForm:0, BValue:[]uint8(nil), Value:driver.Value(nil), iPrimValue:driver.Value(nil), oPrimValue:driver.Value(nil), OutputVarPtr:interface {}(nil), getDataFromServer:true, oaccollid:0, cusType:(*go_ora.customType)(nil), Annotations:map[string]string(nil)}
from go-ora.
fixed in v2.7.21
you can test json column with field ParameterInfo.IsJson
from go-ora.
I read about this type it is actually stored as a blob. its support started from oracle 21c so you can pass go_ora.Blob parameter
older version of oracle will show its blob origin
create table customers (
id integer not null primary key,
json_data blob check (json_data is json)
);
from go-ora.
Thank you for your attention to this issue.
Unfortunately, our service cannot know the type of the returned field.
We look at DatabaseTypeName() to understand that the field type is json (not original BLOB) and convert json.Unmarshal to a map.
Here is the code that shows that in godror it was possible to understand that the field type is JSON.
package main
import (
"database/sql"
"fmt"
_ "github.com/godror/godror"
go_ora "github.com/sijms/go-ora/v2"
)
func main() {
connOra, err := sql.Open("oracle", go_ora.BuildUrl("127.0.0.1", 1521, "ORCLPDB1", "SYS", "pass", nil))
if err != nil {
panic(err)
}
defer connOra.Close()
run(connOra)
// print
// OCIBlobLocator OCIBlobLocator
connGodror, err := sql.Open("godror", `user="SYS" sysdba="1" password="pass" connectString="127.0.0.1:1521/ORCLPDB1"`)
if err != nil {
panic(err)
}
defer connGodror.Close()
run(connGodror)
// print
// BLOB JSON
}
func run(conn *sql.DB) {
conn.Exec(`GRANT CREATE SESSION TO SYS`)
conn.Exec(`DROP TABLE IF EXISTS types_test`)
conn.Exec(`CREATE TABLE types_test (myblob BLOB NULL, myjson JSON NULL)`)
conn.Exec(`INSERT INTO types_test (myblob, myjson)VALUES(UTL_RAW.CAST_TO_RAW('blobval - not json'), json('{"foo": "bar"}'))`)
rows, err := conn.Query(`SELECT * FROM types_test`)
if err != nil {
panic(err)
}
cTypes, _ := rows.ColumnTypes()
fmt.Println(cTypes[0].DatabaseTypeName(), cTypes[1].DatabaseTypeName())
}
from go-ora.
sorry for late. these days i am so busy but soon i will fix this issue
from go-ora.
till now I check the columns attribs for Blob and Blob with json constraint and I find no difference
&go_ora.ParameterInfo{Name:"JSON_VAL", TypeName:"", Direction:0, IsNull:false, AllowNull:true, ColAlias:"", DataType:113, IsXmlType:false, Flag:0x0, Precision:0x0, Scale:0x0, MaxLen:4000, MaxCharLen:0, MaxNoOfArrayElements:0, ContFlag:0, ToID:[]uint8(nil), Version:0, CharsetID:0, CharsetForm:0, BValue:[]uint8(nil), Value:driver.Value(nil), iPrimValue:driver.Value(nil), oPrimValue:driver.Value(nil), OutputVarPtr:interface {}(nil), getDataFromServer:true, oaccollid:0, cusType:(*go_ora.customType)(nil)}
&go_ora.ParameterInfo{Name:"BLOB_VAL", TypeName:"", Direction:0, IsNull:false, AllowNull:true, ColAlias:"", DataType:113, IsXmlType:false, Flag:0x0, Precision:0x0, Scale:0x0, MaxLen:4000, MaxCharLen:0, MaxNoOfArrayElements:0, ContFlag:0, ToID:[]uint8(nil), Version:0, CharsetID:0, CharsetForm:0, BValue:[]uint8(nil), Value:driver.Value(nil), iPrimValue:driver.Value(nil), oPrimValue:driver.Value(nil), OutputVarPtr:interface {}(nil), getDataFromServer:true, oaccollid:0, cusType:(*go_ora.customType)(nil)}
the information about json column is store in table all_constraints
which can be queried for json constraint
.
May be there are network calls that return more advanced information about the columns where we can find the difference
from go-ora.
I will test the code with oracle server 21c and see the difference
from go-ora.
Related Issues (20)
- go_ora.AddSessionParam(db, k, v) put values to global driver hashmap HOT 2
- An EOF error is reported during ping HOT 2
- Panic in v2 `network.Session.GetInt64`: slice out of bounds HOT 3
- 2.8.8 drop JSON support? ORA-40569: Unimplemented JSON feature. HOT 5
- Insert with returning value using prepared statement hanging HOT 2
- unregister custom type: ANYDATA. call RegisterType first HOT 3
- long type get a error(ORA-03146:invalid buffer length for TTC field) HOT 5
- All data types are cast to string when query results are parsed HOT 5
- Connection error on v2.8.12 HOT 10
- Timestamp with Local Time Zone conversion HOT 8
- 'ORA-03146: invalid buffer length for TTC field' on procedure call with out parameter
- ORA-01013 in v2.8.13 HOT 24
- 'ORA-01009: missing mandatory parameter' during select for CLOB columns on 2.8.13 HOT 2
- Use struct with Select many rows query HOT 3
- The canceling context in version 2.8.14 has a race condition issue. HOT 1
- "panic: runtime error: slice bounds out of range" when output array size is bigger than 245 HOT 4
- Fails on reading empty array with error 'TTC error: received code 3 during response reading' HOT 2
- Can't reuse statement when selecting a blob value HOT 4
- ORA-01483: invalid length for DATE or NUMBER bind variable HOT 8
- Use a custom dialer to create connection with db HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-ora.