rana / ora Goto Github PK
View Code? Open in Web Editor NEWAn Oracle database driver in Go.
License: MIT License
An Oracle database driver in Go.
License: MIT License
Hi
I am using:
$ go version
go version go1.5.1 windows/amd64
and "gopkg.in/rana/ora.v3"
I need to call following procedure:
PROCEDURE get_customer(p_result OUT SYS_REFCURSOR,
p_customer_id NUMBER)
AS
BEGIN
OPEN p_result FOR
SELECT FIRST_NAME, LAST_NAME, AGE
FROM customer
WHERE customer_id=p_customer_id;
END get_customer;
I used following go code:
procRset := &ora.Rset{}
stmt, _ := ses.Prep(commandText)
stmt.Exe(procRset, customerID)
fmt.Println(procRset.ColumnNames)
And, in result, we see that procRset.ColumnNames contains following array:
[FIRST_NAMELAST_NAMEAGE LAST_NAMEAGE AGE]
I suppose that this is incorrect array and it should be:
[FIRST_NAME LAST_NAME AGE]
Hi,
I have a SIGTRAP trace every time I close the program which uses rana/ora driver.
How to fix this? What am I doing wrong?
Environment: Oracle XE 11.2 running on CentOS 6.5, OS X El Capitan, Oracle Instant client 11.2, go 1.5.3
Example source code - https://gist.github.com/schmooser/6fa4535475d922652d60
Output:
$ go run *.go
2016/02/27 12:28:05 [debug] ses closed
2016/02/27 12:28:05 [debug] srv closed
2016/02/27 12:28:05 [debug] env closed
2016/02/27 12:28:05 Result: 2016.02.27 12:28:16 <-- I press Ctrl-C here
^CSIGTRAP: trace trap
PC=0x405733d m=0
goroutine 0 [idle]:
runtime.morestack()
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:302 +0x1d
goroutine 5 [syscall]:
runtime.notetsleepg(0x432cdd8, 0x6fc22d851, 0x0)
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/lock_sema.go:264 +0x86 fp=0xc820029f38 sp=0xc820029ef8
runtime.timerproc()
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/time.go:209 +0xde fp=0xc820029fc0 sp=0xc820029f38
runtime.goexit()
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1 fp=0xc820029fc8 sp=0xc820029fc0
created by runtime.addtimerLocked
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/time.go:116 +0x11f
goroutine 1 [sleep]:
time.Sleep(0x6fc23ac00)
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/time.go:59 +0xf9
main.main()
/Users/rbd/Projects/go/src/github.com/schmooser/go-oracle/rana-ora/main.go:95 +0x229
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1
rax 0xc820009a38
rbx 0x432d4a0
rcx 0x432d160
rdx 0x0
rdi 0x2
rsi 0x432d160
rbp 0xc820009a50
rsp 0xc820009a40
r8 0xc820009ee8
r9 0x8a2b60c
r10 0x44cb9fa573a
r11 0x202
r12 0x11e4f14ec0fb4
r13 0x11e4edfa6d630
r14 0x1436c268d4973200
r15 0x8
rip 0x405733d
rflags 0x246
cs 0x2b
fs 0x0
gs 0x0
exit status 2
When using a *time.Time variable to scan a date column, and the value is null on the database, the result is something like this: "-0001-11-30 00:00:00 +0000 +00:00"
I think it would make much more sense if it just returned a nil pointer for null values. Would that be a viable change?
I seem to be getting an error when importing the package:
C:\dev\golang\src\github.com\klauern\ora-things
λ $env:CGO_CFLAGS
-IC:\instantclient_12_1\sdk\include
C:\dev\golang\src\github.com\klauern\ora-things
λ $env:CGO_LDFLAGS
C:\instantclient_12_1\oci.dll
C:\dev\golang\src\github.com\klauern\ora-things
λ go get -u gopkg.in/rana/ora.v3
I'm trying to use this package, but I don't know how to debug this issue I'm seeing. I've tried to simplify this to as small as possible.
package main
import (
_ "gopkg.in/rana/ora.v3"
"fmt"
)
func main() {
fmt.Println("Hi")
}
C:\dev\golang\src\github.com\klauern\ora-things
λ go run .\simple.go
exit status 3221225595
C:\dev\golang\src\github.com\klauern\ora-things
λ go version
go version go1.5.1 windows/amd64
Are there any ways to figure out what could be causing the issue, or even what this exit status means? I'm really confused.
I needed to refresh my go packages and when I refreshed ora, I lost the commits related to the numstring changes recently made by @tgulacsi. I see the code in master branch on github however the version I get from
go get gopkg.in/rana/ora.v3
is older of course. I couldn't manage to get the master branch and I see that the feature branches got cleaned up.
Please add some examples or docs for how to use ora
Sorry, not sure if it is a issue. Compared with go-oci8, the query and fetch performance is very slow.
The following works well with goracle, but I compiled successfully ora and dropped it in:
conn, err := sql.Open("ora", "USERNAME/PASSWORD@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl.xxx.xxx.org)))")
but with ora there and
func init() {
ora.Register(nil)
}
added I get
2015/09/03 15:29:50 Ready to connect
2015/09/03 15:29:52 Env.ociError OCI-22054: underflow error
exit status 1
ideas?
Hi guys need your help. I update to go 1.6 and i cannot update ora.v3 due to below failures.
Thanks.
`user@hostname:/usr/local/share/pkgconfig$ go get -u gopkg.in/rana/ora.v3
/goWorkspace/src/gopkg.in/rana/ora.v3/bndBfile.go:9:17: fatal error: oci.h: No such file or directory
#include <oci.h>
^
compilation terminated.
`
I do love glog, but hate its flag usage, which is hardly avoidable.
But why should my main program
a) manage the creation of flags by importing "ora",
b) forced to use glog, if it'd use some other logging package?
I like gopkg.in/inconshreveable/log15.v2 as it is a well mannered package: for libraries, I can SetHandler(log15.DiscardHandler()), and in tests/main application I can set for other destinations, if wanted.
But I don't want to force anything, especially if you know some trick to disable glog's automatic flag registering.
OS: Win7x64, Go1.5x64, Msys64, oci.dll from instantclient-basiclite-windows.x64-12.1.0.2.0.zip
Remove oci.dll and its stuff from PATH, put only oci.dll into a folder where your application is, call ora.Register(nil). It will panic with the following message:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x4bf7dc]
goroutine 1 [running]:
gopkg.in/rana/ora%2ev3.Register(0xc082008340)
C:/Develop/Go/gopath/src/gopkg.in/rana/ora.v3/ora.go:144 +0xbc
main.init.1()
C:/Develop/Go/gopath/src/db2cvs/db2cvs.go:15 +0x10f
main.init()
C:/Develop/Go/gopath/src/db2cvs/db2cvs.go:54 +0x51
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
c:/go/src/runtime/asm_amd64.s:1696 +0x1
Investigation results:
OpenEnv() returns an error, but its value is ignored, then it's trying to set a value to env.cfg.StmtCfg, but it hasn't been initialized property and we have that memory error...
env, err := OpenEnv(nil)
if err != nil {
errE(err) <-- I guess that it should be panic(errE(err)) or return err or so
}
// database/sql/driver expects binaryFloat to return float64 (not the Rset default of float32)
env.cfg.StmtCfg.Rset.binaryFloat = F64 <---- error: assignment to a nil pointer
OpenEnv error:
OpenEnv Unable to create environment handle (Return code = -1).
getting and error while Get / Exec Issue.
"Ses.Prep.func1 recovered: runtime error: cgo argument has Go pointer to Go pointer"
Not sure what i am doing wrong :(
Running
LC_ALL=C NLS_LANG=AMERICAN_AMERICA.AL32UTF8 go test
After a few hundred records I get
2015/05/21 11:58:27 E2S1S1] Prep: create table t129_1 (c1 interval day to second(9) null)
2015/05/21 11:58:27 E2S1S1S25] Close
2015/05/21 11:58:27 E2S1S1] Prep: insert into t129_1 (c1) values (:c1)
2015/05/21 11:58:27 E2S1S1] Prep: select c1 from t129_1
2015/05/21 11:58:27 E2S1S1S1R0] open
2015/05/21 11:58:27 E2S1S1S1] Close
2015/05/21 11:58:27 E2S1S1S1R0] close
2015/05/21 11:58:27 E2S1S1S25] Close
2015/05/21 11:58:27 E2S1S1] Prep: drop table t129_1
2015/05/21 11:58:27 E2S1S1S1] Close
--- FAIL: TestBindDefine_OraIntervalDS_intervalDSNull_null_session (0.07s)
z_oracle_test.go:754: ora: ORA-01000: maximum open cursors exceeded
How should the char(1) column be read as a bool?
tgulacsi@tgulacsi-Aspire-V3-371:~/src/github.com/ranaian/ora$ go test -run=bool
Read environment variable GO_ORA_DRV_TEST_DB = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=49161)))(CONNECT_DATA=(SERVICE_NAME=xe)))'
Read environment variable GO_ORA_DRV_TEST_USERNAME = 'test'
Read environment variable GO_ORA_DRV_TEST_PASSWORD = 'test'
Read session time zone from database...
Dropping previous tables...
--- FAIL: Test_charC1_bool_true_db (0.12s)
tstlg.go:18: ORA I E1C2] Prepare
tstlg.go:18: ORA I E1S2S1] Prep: create table t3 (c1 char(1 char) not null)
tstlg.go:18: ORA I E1S2S1S1] Exec
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1C2] Prepare
tstlg.go:18: ORA I E1S2S1] Prep: insert into t3 (c1) values (:c1)
tstlg.go:18: ORA I E1S2S1S1] Exec
tstlg.go:18: ORA I E1C2] Prepare
tstlg.go:18: ORA I E1S2S1] Prep: select c1 from t3
tstlg.go:18: ORA I E1S2S1S1] Query
tstlg.go:18: ORA I E1S2S1S1R0] open
z_oracle_test.go:1844: Unable to cast actual value to bool, *bool, ora.Bool. (string, 1): goroutine 8 [running]:
github.com/ranaian/ora.compare(0x6367e0, 0xc208011f00, 0x638160, 0xc2080925a0, 0x19, 0xc2080201b0)
/home/tgulacsi/src/github.com/ranaian/ora/z_oracle_test.go:1211 +0x4a6
github.com/ranaian/ora.testBindDefineDB(0x6367e0, 0xc208011f00, 0xc2080201b0, 0x702e30, 0x15)
/home/tgulacsi/src/github.com/ranaian/ora/z_oracle_test.go:268 +0xa12
github.com/ranaian/ora.Test_charC1_bool_true_db(0xc2080201b0)
/home/tgulacsi/src/github.com/ranaian/ora/z_db_test.go:209 +0x8f
testing.tRunner(0xc2080201b0, 0xa4e970)
/usr/local/go/src/testing/testing.go:454 +0x9b
created by testing.RunTests
/usr/local/go/src/testing/testing.go:562 +0xa3e
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1S2S1S1R0] close
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1C2] Prepare
tstlg.go:18: ORA I E1S2S1] Prep: drop table t3
tstlg.go:18: ORA I E1S2S1S1] Exec
tstlg.go:18: ORA I E1S2S1S1] Close
tstlg.go:18: ORA I E1S2S1S1] Close
--- FAIL: Test_charC1Null_bool_true_db (0.11s)
z_oracle_test.go:1844: Unable to cast actual value to bool, *bool, ora.Bool. (string, 1): goroutine 9 [running]:
github.com/ranaian/ora.compare(0x6367e0, 0xc208092b60, 0x638160, 0xc208093210, 0x19, 0xc208020240)
/home/tgulacsi/src/github.com/ranaian/ora/z_oracle_test.go:1211 +0x4a6
github.com/ranaian/ora.testBindDefineDB(0x6367e0, 0xc208092b60, 0xc208020240, 0x702e70, 0x11)
/home/tgulacsi/src/github.com/ranaian/ora/z_oracle_test.go:268 +0xa12
github.com/ranaian/ora.Test_charC1Null_bool_true_db(0xc208020240)
/home/tgulacsi/src/github.com/ranaian/ora/z_db_test.go:213 +0x81
testing.tRunner(0xc208020240, 0xa4e988)
/usr/local/go/src/testing/testing.go:454 +0x9b
created by testing.RunTests
/usr/local/go/src/testing/testing.go:562 +0xa3e
Hi,
I really like the nice simple but thought-out API of your Oracle lib!
It seems that it is a little bit lacking in LOB side.
For example, why is https://github.com/ranaian/ora/blob/master/defLob.go#L98 not a
copy(value[writeIndex:], buffer[:int(byte_amtp)])
?
If you're willing, I can contribute this small change as a PR.
My other question is about LOBs. The can be huge, and as I see you simply read them fully into memory. To mitigate this problem, we could use mmap'd memory for this, or a streaming API (maybe an OraLOBStream type with Read/ReadAt methods?).
One thing with the streaming API: as I've already burned myself (tgulacsi/goracle#26 (comment)), the underlying cursor must be open while reading/writing the LOB, and QueryRow from database/sql closes it after the first row.
Thanks,
Tamás Gulácsi
Dear,
Great and very cool package.
Your library will support Associative Arrays for store procedures.
In my case, I have many procedures like this:
CREATE OR REPLACE PACKAGE testuser.test_pkg IS
TYPE assoc_array_varchar2_t IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER;
PROCEDURE your_proc(p_parm IN assoc_array_varchar2_t);
END test_pkg;
CREATE OR REPLACE PACKAGE BODY testuser.test_pkg IS
PROCEDURE your_proc(p_parm IN assoc_array_varchar2_t) AS
BEGIN
FOR i IN p_parm.first .. p_parm.last
LOOP
dbms_output.put_line(p_parm(i));
END LOOP;
END;
END test_pkg;
Hi,
In issue #50 @tgulacsi refers to splitting the two pools up to avoid leaking. Is it possilbe to add a sample code of SesPool and SrvPool usage to either the examples or README?
I implemented a pool for goracle, however it was just a quick and dirty fix at the time. I wanted to try rana's pools, just couldn't figure out how to use it.
Greetings,
Was wondering if I could get some help building on Windows 10 64 bit with MinGW-W64? Getting undefined reference. Not sure where the issue is, maybe something because of Windows 10?
versions:
go version go1.5.1 windows/amd64
gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.2.0
instant client 11.2.0.4 64 bit
Path has C:\app\instantclient_11_2_64;C:\app\Go\bin;C:\app\mingw64\bin
Flags:
CGO_CFLAGS=-IC:\app\instantclient_11_2_64\sdk\include
CGO_LDFLAG=-LC:\app\instantclient_11_2_64\sdk\lib\msvc\ -lstdc++ -loci
go install -v test
test/_third_party/github.com/rana/ora
# test/_third_party/github.com/rana/ora
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndBfile.cgo2.o:bndBfile.cgo2.c:(.text+0xc9): undefined reference to `OCIBindByPos'
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndBfile.cgo2.o:bndBfile.cgo2.c:(.text+0x150): undefined reference to `OCIDescriptorAlloc'
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndBfile.cgo2.o:bndBfile.cgo2.c:(.text+0x1ad): undefined reference to `OCIDescriptorFree'
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndBfile.cgo2.o:bndBfile.cgo2.c:(.text+0x24e): undefined reference to `OCILobFileSetName'
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndBinSlice.cgo2.o:bndBinSlice.cgo2.c:(.text+0x5b): undefined reference to `OCIBindArrayOfStruct'
C:\Users\myuser\AppData\Local\Temp\go-build291446222\test\_third_party\github.com\rana\ora\_obj\bndFloat32.cgo2.o:bndFloat32.cgo2.c:(.text+0x45): undefined reference to `OCINumberFromReal'
...
Any thoughts?
Appreciate any help provided.
I was following the installation instructions for the package. I installed the oracle instant client and the sdk and then used the env script to verify that I had set the correct environment variables. When i try to go get the package I'm getting an error
warning: libnnz11.so, needed by /usr/lib/oracle/11.2/client64/lib/libclntsh.so, not found
I'm working on Ubuntu 14.04 and with instant client version 11.2.0.4
I'm using the package to read content from a table where one column is a Blob. According to the documentation I thought i need to use a Lob.
I prepare my query like this
stmtQry, err := ses.Prep(
"SELECT CONTENT FROM TABLENAME WHERE", ora.Bin)
while reading the content if i use fmt.Println(rset.Row[3])
i can print it out. But I wanted to encode the response to Json. I tried to store the value in an ora.Lob field but i'm getting an error:
interface is *ora.lobReader, not ora.String.
It'd be nice to have an example of how to read blobs or handle Lob fields.
Hi!
I need to get cursor with nested cursor from procedure call. Now rset does not support attrs with oci type C.SQLT_RSET. Do you consider the ability to add processing data of this type?
Just in case, here's an example procedure:
create or replace procedure example_proc(p_out_cur out sys_refcursor) is
begin
open p_out_cur for
select m.id,
m.name,
cursor (select a.internal_file_name, q.name
from media_assets a, asset_file_types_dict q
where a.media_id = m.id
and q.id = a.file_type_id) assets_cursor
from media m;
end example_proc;
I am facing issues using SetDrvCfg method. Following example code provided in Readme.md fails to compile,
func init() {
drvCfg := ora.NewDrvCfg()
drvCfg.Env.StmtCfg.FalseRune = 'N'
drvCfg.Env.StmtCfg.TrueRune = 'Y'
drvCfg.Env.StmtCfg.Rset.TrueRune = 'Y'
ora.SetDrvCfg(drvCfg)
}
Please suggest.
Hi!, I am getting exit status 3221225781 just to load the library.
My oracle client is in the PATH, and I am running x64 versions of everything.
Trying to run the application I get
"The program can't start because OCI.dll is missing from your computer. Try reinstalling the program to fix this problem"
CGO_CFLAGS=-IC:\instantclient_12_1\sdk\include
CGO_LDFLAGS=C:\instantclient_12_1\oci.dll
Path=.;C:\instantclient_12_1;C:\Windows\system32;C:\Windows\system32;C:\Windows;C
:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program F
iles (x86)\Microsoft Application Virtualization Client;c:\Program Files (x86)\Mi
crosoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\Too
ls\Binn;c:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x
86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Files\Microsoft SQL Ser
ver\110\Tools\Binn;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\M
anagementStudio;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn;c:
Program Files (x86)\Microsoft SQL Server\110\DTS\Binn;C:\Program Files (x86)\Mi
crosoft SDKs\TypeScript;C:\Program Files (x86)\Windows Kits\8.1\Windows Perform
ance Toolkit;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program F
iles (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files (x86)\WinMerge;C:\Pro
gram Files\TortoiseGit\bin;%TFSPowerToolDir%;%BPADir%;C:\Program Files (x86)\Sky
pe\Phone;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\QuickTime\QTSyst
em;C:\Go\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Tamás,
I was playing more with the updated ora based on issue #33. It is working for me but I can get myself to another underflow error.
If I create a view on the table in the test code with
if _, err := testDb.Exec(
CREATE VIEW test_janus_v AS SELECT * FROM test_janus); err != nil { t.Fatal(err) }
that will PASS the test.,
However, we found that there are views (which seem to be composites from several tables) that do not pass. If we then make a table from this view that fails, that will in fact pass the test (not underflow).
We think we can build a test for you that shows this, but it will take time to build the tables, data and view to do so. I don't know if I can get it done this weekend or not. I will try.
I wanted to start this issue though in case the information on an underflow error from a view was enough for you to start tracking things down like you did that resolved it on the table level.
Thanks.. I will be in touch
The below Oracle sql is just to show that the returning statement for a insert can be just about any type. The below example is using a varchar.
create table TEST1
(
DATA1 number(20) not null,
DATA2 varchar2(50) not null
)
tablespace USERS pctfree 10 nologging;
declare
l_char varchar2(512);
begin
insert into TEST1 (DATA1, DATA2) values (1, 'test1') returning DATA2 into l_char;
commit;
DBMS_OUTPUT.PUT_LINE(l_char);
end;
/
When looking at the Go code, can do the following:
var myId string = "default"
result, err := db.Exec("insert into TEST1 (DATA1, DATA2) values (:1, :2) returning DATA2 into :3", 2, "test2", myId)
if err != nil {
fmt.Println(err)
}
fmt.Println(result2)
And get the error:
DrvStmt.Exec Stmt.exe Env.ociError ORA-01722: invalid number
I am not exactly sure what the goal is of lastInsertId since it is set to be an int64 but seems like the below code in stmt.go is not doing want is wanted:
if strings.Contains(sqlEnd, "RETURNING") {
params[len(params)-1] = &lastInsertId
}
Also to note, if you do set your returning variable to a int64 instead of say a string, the lastInsertId gets changed from a default 0 to a 1 from when the below line is called:
err = stmt.setBindPtrs()
Was not sure exactly why, but I figured it would be easier for you to figure it out if needed.
Could you look into the result.LastInsertId() and see if it doing what is wanted?
I started to see panics like below after starting to use go 1.6. I am not really sure if this is related to some garbage collected pointer that should have been kept. It maybe related to some missing bindings from C code. Please let me know if this doesn't look like a driver issue and I will close it.
The following is the way I create the statement, nothing new but here it is:
stmt, err := rr.DB.PrepareNamed(sqlMatchHeaderCount)
if err != nil {
return 0, err
}
defer stmt.Close()
var count int
err = stmt.Get(&count, map[string]interface{}{"headerID": headerID, "appID": appID})
I am using a library called jmoiron/sqlx, but it is only a wrapper around database/sql for easy scanning of values into structs. It is not responsible for creating or cleaning pointers to statements.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x38 pc=0x530caa]
goroutine 1402 [running]:
panic(0x9360e0, 0xc8200100e0)
/usr/local/go1.6/src/runtime/panic.go:464 +0x3e6
gopkg.in/rana/ora%2ev3.(*DrvStmt).sysName(0xc83d3fc6a8, 0x0, 0x0)
/home/kokteyl/go/src/gopkg.in/rana/ora.v3/drvStmt.go:101 +0xaa
gopkg.in/rana/ora%2ev3.(*DrvStmt).log(0xc83d3fc6a8, 0x40ec01, 0x0, 0x0, 0x0)
/home/kokteyl/go/src/gopkg.in/rana/ora.v3/drvStmt.go:108 +0x50
gopkg.in/rana/ora%2ev3.(*DrvStmt).Close(0xc83d3fc6a8, 0x0, 0x0)
/home/kokteyl/go/src/gopkg.in/rana/ora.v3/drvStmt.go:33 +0x49
database/sql.(*driverConn).finalClose(0xc83d1fc460, 0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:356 +0xc4
database/sql.(finalCloser).(database/sql.finalClose)-fm(0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:449 +0x40
database/sql.(*driverConn).Close(0xc83d1fc460, 0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:349 +0x24b
database/sql.(*DB).putConn(0xc8200c0420, 0xc83d1fc460, 0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:909 +0x27d
database/sql.(*driverConn).releaseConn(0xc83d1fc460, 0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:284 +0x3d
database/sql.(*driverConn).(database/sql.releaseConn)-fm(0x0, 0x0)
/usr/local/go1.6/src/database/sql/sql.go:1078 +0x34
f71fd91 - without announcement, this is a very rude step: all import statements became stale!
If you move, I'd suggest move under a gopkg.in: create a go-ora organisation, and transfer github.com/rana/ora under github.com/go-ora/ora, and use the v1 branch as the main branch. This would allow to use gopkg.in/ora.v1 as a canonical import path.
The default SetChar(ora.B)
feature treats every CHAR(1)
column as a boolean. And not just with ora.Prep
, but with sql.Open
, too!
We use CHAR(1) columns not just for booleans, but for state marks, too (X/Y/Z, B/K ...).
I'd like to turn off this feature (it is a misfeature to me, to be honest), as I've started at master (9b329a8), but first I'd like to ask you for confirmation: is this feature frequently used? Would this change affect a lot of precious code badly?
One of the things that bothers me about Rana is the need to call ora.Register on my program. Goracle and Go-oci8 both call sql.Register inside the driver itself, so whoever is using them doesn't need to. Any reason not to modify Rana to do the same?
There does not appear to be a way to connect with the sysdba privilege (which is available in oci8)
I'm using database/sql, and I have a connection which shall stay opened, and query a view once for every 15 second.
Either conn.Query + defer rows.Close, or conn.Prepare + defer stmt.Close + stmt.Query + defer rows.Close, number of opened cursors just grows, till (after 1000/4 = 250 minutes) it fails with "Too many opened cursors".
I've tried adding rset.autoClose in drvQueryRows.go, without avail (closing in drvStmt.Close caused panics).
I'll try to create a reproduction, but do you have an idea, how to fix this?
Thanks,
Tamás Gulácsi
This is only a feature request and not an issue, since QueryRow can be implemented as the first row of Query. However this causes very ugly code while using database/sql.
I would be glad to work on it if there is no reason this is not implemented.
20,66
0,39
The for rows.Next() break up when a value is => 0,39
The Oracle Data Type is number and the golang Type is float64
20,66 at Example don't make a Problem
The pre-decimal Point makes the error
Hi, I'm trying to understand the memory leak I experience by using ora driver. I see that with every 1k requests I sent concurrent to my app, I have memory increase. The go profiler shows growing number of to ora *Rset, *DrvStmt, etc. I put heap profile over here. The code I execute follows practices I read on Go web site, i.e. I close Rows, I use single *sql.DB, etc. For reference my execute function is here. But I still struggle to understand why memory leaks. I'm new to Go database/sql and obviously may miss something.
Any advise?
Thanks, Valentin
Hi dev team,
This is not an issue but can you provide an example where ora.v3 executes a stored procedure that does not return a SYS_REFCURSOR. Instead, stored procedure executes a simple SELECT statement and the golang app with ora.v3 can retrieve these rows? I am having slow performance using SYS_REFCURSOR for a simple select query. It seems ora.Rset,Next() is slow.
Thanks!
Hi
I try to export blob from an oracle database with this piece of code :
rows, err := db.Query(`select hash, content from "BLOBSTORE"."BLOB" where rownum < 10`)
if err != nil {
log.Fatal(err)
}
defer rows.Close()
for rows.Next() {
//row structure
var hash string
var content []byte
err = rows.Scan(&hash, &content)
checkErr(err)
...
And at the execution, I've got this :
➜ gotothefs ./blober -alsologtostderr=true
connection
query
I0406 10:48:27.675358 40107 util.go:187] [Drv.Open]
I0406 10:48:27.675751 40107 env.go:299] E1 [Env.OpenCon]
I0406 10:48:27.675790 40107 env.go:299] E1 [Env.OpenSrv]
I0406 10:48:27.765079 40107 srv.go:322] E1S1 [Srv.OpenSes]
I0406 10:48:27.849781 40107 ses.go:637] E1S1S1 [Ses.PrepAndQry]
I0406 10:48:27.849821 40107 ses.go:639] E1S1S1 [Ses.Prep] SELECT property_value FROM database_properties WHERE property_name = 'NLS_CHARACTERSET'
I0406 10:48:27.850010 40107 stmt.go:1154] E1S1S1S1 [Stmt.qry]
I0406 10:48:27.850027 40107 stmt.go:1167] E1S1S1S1 [Stmt.bind] Params 0
I0406 10:48:27.868394 40107 rset.go:772] E1S1S1S1R1 [Rset.open]
I0406 10:48:27.868498 40107 rset.go:785] E1S1S1S1R1 [Rset.open] 1. PROPERTY_VALUE/1
I0406 10:48:27.868712 40107 rset.go:785] E1S1S1S1R1 [Rset.open] []ora.def{(*ora.defString)(0xc820071410)}
I0406 10:48:27.868838 40107 conn.go:157] E1S1S1C1 [Con.Prepare]
I0406 10:48:27.868856 40107 ses.go:639] E1S1S1 [Ses.Prep] select hash, content from "BLOBSTORE"."PJ_BLOB" where rownum < 10
I0406 10:48:27.868987 40107 drvStmt.go:108] E1S1S1S2 [DrvStmt.Query]
I0406 10:48:27.869000 40107 stmt.go:1154] E1S1S1S2 [Stmt.qry]
I0406 10:48:27.869009 40107 stmt.go:1167] E1S1S1S2 [Stmt.bind] Params 0
I0406 10:48:27.887039 40107 rset.go:772] E1S1S1S2R2 [Rset.open]
I0406 10:48:27.887122 40107 rset.go:785] E1S1S1S2R2 [Rset.open] 1. HASH/1
I0406 10:48:27.887154 40107 rset.go:785] E1S1S1S2R2 [Rset.open] 2. CONTENT/113
I0406 10:48:27.887201 40107 rset.go:785] E1S1S1S2R2 [Rset.open] []ora.def{(*ora.defString)(0xc820071590), (*ora.defLob)(0xc820071620)}
I0406 10:48:27.948790 40107 drvStmt.go:108] E1S1S1S2 [DrvStmt.Close]
I0406 10:48:27.948823 40107 stmt.go:1154] E1S1S1S2 [Stmt.close]
I0406 10:48:27.948838 40107 rset.go:772] E1S1S1S2R2 [Rset.close]
I0406 10:48:27.966613 40107 conn.go:157] E1S1S1C1 [Con.close]
I0406 10:48:27.966638 40107 ses.go:637] E1S1S1 [Ses.close]
I0406 10:48:27.966648 40107 stmt.go:1154] E1S1S1S1 [Stmt.close]
I0406 10:48:27.966656 40107 rset.go:772] E1S1S1S1R1 [Rset.close]
I0406 10:48:27.985902 40107 srv.go:322] E1S1 [Srv.close]
panic: sql: Scan error on column index 1: unsupported Scan, storing driver.Value type *ora.lobReader into type *[]uint8
goroutine 1 [running]:
panic(0x4228420, 0xc82006f580)
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
main.checkErr(0x8896000, 0xc82006f580)
/Users/nabil/projects/gotothefs/blober.go:126 +0x4b
main.main()
/Users/nabil/projects/gotothefs/blober.go:65 +0x52b
How I can get blob?
panic: error getting description for "SELECT * FROM STG_PERFECTCOMP.REWARD WHERE rownum<1": Ses.Prep.func1 recovered: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
gopkg.in/rana/ora%2ev3.errR(0xc08202b1a8, 0x1, 0x1, 0x0, 0x0)
D:/goworkspace/src/gopkg.in/rana/ora.v3/util.go:231 +0x9e
gopkg.in/rana/ora%2ev3.(_Ses).Prep.func1(0xc08202b650)
D:/goworkspace/src/gopkg.in/rana/ora.v3/ses.go:245 +0xa9
panic(0x671960, 0xc082005440)
D:/go1.6/src/runtime/panic.go:426 +0x4f7
gopkg.in/rana/ora%2ev3._cgoCheckPointer0(0x611540, 0xc0820a8368, 0x0, 0x0, 0x0, 0x3547510)
??:0 +0x54
gopkg.in/rana/ora%2ev3.(_Stmt).attr(0xc0820a8280, 0xc0820a8368, 0x1800000004, 0x0, 0x0)
D:/goworkspace/src/gopkg.in/rana/ora.v3/stmt.go:1152 +0xcb
gopkg.in/rana/ora%2ev3.(_Ses).Prep(0xc08202ca80, 0x737cc0, 0x34b, 0x0, 0x0, 0x0, 0xc0820a8280, 0x0, 0x0)
D:/goworkspace/src/gopkg.in/rana/ora.v3/ses.go:291 +0x90b
gopkg.in/rana/ora%2ev3.(Con).Prepare(0xc0820bb480, 0x737cc0, 0x34b, 0x0, 0x0, 0x0, 0x0)
D:/goworkspace/src/gopkg.in/rana/ora.v3/conn.go:117 +0x106
database/sql.(DB).exec(0xc08208b290, 0x737cc0, 0x34b, 0xc0820bb360, 0x2, 0x2, 0xc082004d01, 0x0, 0x0, 0x0, ...)
D:/go1.6/src/database/sql/sql.go:1046 +0x3dd
database/sql.(DB).Exec(0xc08208b290, 0x737cc0, 0x34b, 0xc0820bb360, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
D:/go1.6/src/database/sql/sql.go:1009 +0xc5
github.com/tgulacsi/go/orahlp.DescribeQuery(0x11744d0, 0xc08208b290, 0xc082008ec0, 0x34, 0x0, 0x0, 0x0, 0x0, 0x0)
D:/goworkspace/src/github.com/tgulacsi/go/orahlp/orahlp.go:74 +0x24e
main.GetColumns(0xc08208b290, 0xc082008ec0, 0x34, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Users/your/IdeaProjects/dataCleaner/main.go:243 +0xb5
main.generate(0x6bebf0, 0x6)
C:/Users/your/IdeaProjects/dataCleaner/main.go:226 +0x174
main.main()
C:/Users/your/IdeaProjects/dataCleaner/main.go:323 +0x253
goroutine 1 [running]:
panic(0x6a02e0, 0xc08200ddb0)
D:/go1.6/src/runtime/panic.go:464 +0x3f4
main.checkErr(0x1174250, 0xc08200ddb0)
C:/Users/your_/IdeaProjects/dataCleaner/main.go:79 +0x52
main.generate(0x6bebf0, 0x6)
C:/Users/your_/IdeaProjects/dataCleaner/main.go:227 +0x1c3
main.main()
C:/Users/your_/IdeaProjects/dataCleaner/main.go:323 +0x253
Hi
When i used version 3.0 I received value with NUMBER type. And it was possible to convert to int64 GO type.
For example:
CREATE TABLE BRANCH.ACTIVITY (
ACTIVITY_ID NUMBER NOT NULL
)
id := rset.Row[0].(int64)
In 3.0 it is worked. But in 3.1 it throws the error:
interface conversion: interface is float64, not int64
Is this a bug or planned change?
Hi Dev team,
I've been developing my Go application using below setup. I use Linux for dev\testing without any build\compile issue, but I need to build a windows executable for production. When I perform "env GOOS=windows GOARCH=386 go build" under the project directory I get this error message:
gopkg.in/rana/ora.v2
../gopkg.in/rana/ora.v2/conn.go:52: undefined: Env
../gopkg.in/rana/ora.v2/conn.go:53: undefined: Srv
../gopkg.in/rana/ora.v2/conn.go:54: undefined: Ses
OS: Linux Mint
GO env:
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/myHome/Projects/goWorkspace"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
I need to write jpeg files to blob field through stored procedure.
When I try to insert more then 32767 bytes I get "DrvStmt.Exec Stmt.exe Env.ociError ORA-01460: unimplemented or unreasonable conversion requested" as if my []byte is converted into varchar2 somewhere.
Schema and plsql function:
create table "INTEGR"."PHOTO"
(
"PHOTO_ID" number(11,0) not null enable,
"VEHICLE_UUID" NVARCHAR2(50) not null enable,
"PHOTO" BLOB,
"DHMS_MESSAGE" date not null enable,
"TO_TREAT" number(2,0) default 1 not null enable,
constraint "PHOTO_ID_PK" primary key ("PHOTO_ID")
);
create sequence "INTEGR"."PHOTO_SEQ";
create or replace function integr.add_photo(p_vehicle_uuid photo.vehicle_uuid%type,
p_photo photo.photo%type,
p_dhms_message photo.dhms_message%type,
p_to_treat photo.to_treat%type)
return photo.photo_id%type as
v_id photo.photo_id%type;
begin
if nvl(dbms_lob.getlength(p_photo),0) = 0 then
return null;
end if;
insert into integr.photo(photo_id,
vehicle_uuid,
photo,
dhms_message,
to_treat)
values(0,
p_vehicle_uuid,
p_photo,
p_dhms_message,
p_to_treat)
returning photo_id into v_id;
return v_id;
end;
Code:
package main
import(
"fmt"
"database/sql"
"gopkg.in/rana/ora.v3"
)
func main(){
ora.Register(nil);
db, err := sql.Open("ora", "integr/integr@localhost:49161/xe")
if err != nil {
fmt.Println(err)
}
a := make([]byte,32767+1)
//This inserts succsessfuly:
//sql := "insert into photo values(photo_seq.nextval,'asdas',:1,sysdate,1)"
//And this fails with "DrvStmt.Exec Stmt.exe Env.ociError ORA-01460: unimplemented or unreasonable conversion requested"
sql := "declare v integer; begin v:=integr.add_photo('asdas',:1,sysdate,1); end;"
r, err := db.Exec(sql, a)
if err != nil {
fmt.Println(err)
}
}
Hi Dev team,
I developed a golang middle app to call an Oracle SP and generate XML from an ora,Rset returned.
So far the app is running fine. One thing I noticed is that the first call to Rset.Next() is taking too long and is the only part of the process that is causing the application to not return fast. Example code below. Please advise. Thanks.
for refCursor.Next() {
res := &result{}
res.EChannel, _ = refCursor.Row[0].(string)
.........
Please considered in your roadmap the support of Connection Pooling in Ora driver.
The "database/sql" works but in real cases for applications 7x24, I have random behavior for keep connections alive.
I refer to Oracle Connection Pooling done by OCI.
Thank's,
JM
Connection pooling is the use of a group (the pool) of reusable physical connections by several sessions, in order to balance loads. The management of the pool is done by OCI, not the application. Applications that can use connection pooling include middle-tier applications for Web application servers and e-mail servers.
Session pooling means that the application will create and maintain a group of stateless sessions to the database. These sessions will be handed over to thin clients as requested. If no sessions are available, a new one may be created. When the client is done with the session, the client will release it to the pool. Thus, the number of sessions in the pool can increase dynamically.
Hello
I encountered some issue, while following the installation guide.
I started with setting my environment variables.
CGO_CFLAGS and CGO_LDFLAGS to correct paths within my oracle installation.
I then continued by executing the go get github.com/rana/ora
However, I got a warning that I need to get gopkg.in/rana/ora.v2
So I executed the command go get gopkg.in/rana/ora.v2
After a little while, I got an error (I guess it is the compilation error)
I am not sure what to make of this.
OS: Windows 7 64 bit.
Go version: go1.4.2 windows/amd64
Gcc version: (tdm64-1) 4.9.2
Oracle version: 11.2.0 client
Hi team,
Not really an issue, but anyone tried building windows executable statically linking required oracle dll or libs? To put simply, build an executable that runs without the required dlls.
Thanks!
Hi,
I'm testing my stored-procedure-as-a-ws-generator, and if I have a PL/SQL ARRAY IN bind, then the *int32 OUT bind (the bnd.value!) becomes nil after PrepAndExe
Look for value=, value( for the pointer values:
integration_test.go:552: "/tmp/oracall-integration_test225462907" [-connect=bruno/bruno@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=p520.unosoft.local)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=cigf.unosoft.local))) TST_oracall.simple_nums_count {"nums":[1,2,3,4.4]}]:
{"p_cnt":0,"p_txt":"4=4:1","ret":0}
2015/07/28 15:27:00 fun to be called is %!s(main.FunctionCaller=0x40eec0)
2015/07/28 15:27:00 calling TST_oracall.simple_nums_count(&main.Tst_oracall__simple_nums_count__input{XMLName:xml.Name{Space:"", Local:""}, Nums:[]ora.Float64{ora.Float64{IsNull:false, Value:1}, ora.Float64{IsNull:false, Value:2}, ora.Float64{IsNull:false, Value:3}, ora.Float64{IsNull:false, Value:4.4}}})
ORA I 2015/07/28 15:27:00.351734 util.go:196: [gopkg.in/rana/ora%2ev2.OpenEnv]
ORA I 2015/07/28 15:27:00.354469 env.go:305: E1 [Env.OpenSrv]
ORA I 2015/07/28 15:27:00.601460 srv.go:349: E1S1 [Srv.OpenSes]
2015/07/28 15:27:00 calling TST_oracall.simple_nums_count(nums=>v001,
p_cnt=>:p_cnt,
p_txt=>:p_txt)
with [[{%!s(bool=false) %!s(float64=1)} {%!s(bool=false) %!s(float64=2)} {%!s(bool=false) %!s(float64=3)} {%!s(bool=false) %!s(float64=4.4)}] %!s(*int32=0xc820011410) %!s(*int32=0xc8200113f0) %!s(*string=0xc820011400)]
ORA I 2015/07/28 15:27:00.941142 ses.go:575: E1S1S1 [Ses.PrepAndExe]
ORA I 2015/07/28 15:27:00.941189 ses.go:577: E1S1S1 [Ses.Prep] DECLARE
i1 PLS_INTEGER;
i2 PLS_INTEGER;
TYPE NUMBER_tab_typ IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
nums NUMBER_tab_typ := :1;
v001 BRUNO.TST_ORACALL.NUM_TAB_TYP;
BEGIN
v001.DELETE;
i1 := nums.FIRST;
WHILE i1 IS NOT NULL LOOP
v001(i1) := nums(i1);
i1 := nums.NEXT(i1);
END LOOP;
:2 := TST_oracall.simple_nums_count(nums=>v001,
p_cnt=>:3,
p_txt=>:4);
END;
ORA I 2015/07/28 15:27:00.941445 stmt.go:1114: E1S1S1S1 [Stmt.exe]
ORA I 2015/07/28 15:27:00.941473 stmt.go:1127: E1S1S1S1 [Stmt.bind] Params 4
ORA I 2015/07/28 15:27:00.941554 stmt.go:1127: E1S1S1S1 [bndFloat64Slice.bind] Float64Slice.bind(1) cap=4 len=4 curlen=4 curlenp=0xc8200ba370
ORA I 2015/07/28 15:27:00.941637 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.bind] 0xc820019980 pos=2 value(0xc820011410)=0 => number=ora._Ctype_struct_OCINumber{OCINumberPart:[22]ora._Ctype_ub1{0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
ORA I 2015/07/28 15:27:00.941696 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.bind] 0xc8200199e0 pos=3 value(0xc8200113f0)=0 => number=ora._Ctype_struct_OCINumber{OCINumberPart:[22]ora._Ctype_ub1{0x1, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
ORA I 2015/07/28 15:27:00.941731 stmt.go:1127: E1S1S1S1 [bndStringPtr.bind] StringPtr.bind(4) cap=1000 len=1 alen=0
ORA I 2015/07/28 15:27:00.967120 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.setPtr] 0xc820019980 value=0x0 isNull=-32767 number=ora._Ctype_struct_OCINumber{OCINumberPart:[22]ora._Ctype_ub1{0x2, 0xc1, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
ORA I 2015/07/28 15:27:00.967197 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.setPtr] 0xc8200199e0 value=0x0 isNull=-32767 number=ora._Ctype_struct_OCINumber{OCINumberPart:[22]ora._Ctype_ub1{0x2, 0xc1, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
ORA I 2015/07/28 15:27:00.967232 stmt.go:1127: E1S1S1S1 [bndStringPtr.setPtr] StringPtr.setPtr isNull=0 alen=5
ORA I 2015/07/28 15:27:00.967265 stmt.go:1114: E1S1S1S1 [Stmt.close]
ORA I 2015/07/28 15:27:00.967294 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.close] Int32Ptr.close value=0x0
ORA I 2015/07/28 15:27:00.967357 stmt.go:1127: E1S1S1S1 [bndInt32Ptr.close] Int32Ptr.close value=0x0
2015/07/28 15:27:00 result params: [[{%!s(bool=false) %!s(float64=1)} {%!s(bool=false) %!s(float64=2)} {%!s(bool=false) %!s(float64=3)} {%!s(bool=false) %!s(float64=4.4)}] %!s(*int32=0xc820011410) %!s(*int32=0xc8200113f0) %!s(*string=0xc820011400)]
ORA I 2015/07/28 15:27:00.967606 ses.go:575: E1S1S1 [Ses.close]
ORA I 2015/07/28 15:27:00.971806 srv.go:349: E1S1 [Srv.close]
ORA I 2015/07/28 15:27:00.972078 env.go:305: E1 [Env.Close]
integration_test.go:105: 10. awaited
{"ret":4,"p_cnt":4,"p_txt":"4=4:1"}
got (distance=0)
{"p_cnt":0,"p_txt":"4=4:1","ret":0}
The code:
// TST_oracall.simple_nums_count input
type Tst_oracall__simple_nums_count__input struct {
XMLName xml.Name `json:"-" xml:"tst_oracall__simple_nums_count__input"`
Nums []ora.Float64 `json:"nums" xml:"nums"`
}
func (s *Tst_oracall__simple_nums_count__input) FromJSON(data []byte) error {
return json.Unmarshal(data, s)
}
// Check checks input bounds for Tst_oracall__simple_nums_count__input
func (s Tst_oracall__simple_nums_count__input) Check() error {
return nil
}
// TST_oracall.simple_nums_count output
type Tst_oracall__simple_nums_count__output struct {
XMLName xml.Name `json:"-" xml:"tst_oracall__simple_nums_count__output"`
P_cnt *int32 `json:"p_cnt" xml:"p_cnt"`
P_txt *string `json:"p_txt" xml:"p_txt"`
Ret *int32 `json:"ret" xml:"ret"`
}
const Tst_oracall__simple_nums_count__plsql = `DECLARE
i1 PLS_INTEGER;
i2 PLS_INTEGER;
TYPE NUMBER_tab_typ IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
nums NUMBER_tab_typ := :1;
v001 BRUNO.TST_ORACALL.NUM_TAB_TYP;
BEGIN
v001.DELETE;
i1 := nums.FIRST;
WHILE i1 IS NOT NULL LOOP
v001(i1) := nums(i1);
i1 := nums.NEXT(i1);
END LOOP;
:2 := TST_oracall.simple_nums_count(nums=>v001,
p_cnt=>:3,
p_txt=>:4);
END;
`
func Call_TST_oracall__simple_nums_count(ses *ora.Ses, input Tst_oracall__simple_nums_count__input) (output Tst_oracall__simple_nums_count__output, err error) {
if err = input.Check(); err != nil {
return
}
params := make([]interface{}, 4)
var x, v interface{}
_, _ = x, v
params[0] = input.Nums
output.P_cnt = new(int32)
params[2] = output.P_cnt
output.P_txt = new(string)
params[3] = output.P_txt
output.Ret = new(int32)
params[1] = output.Ret
if true || DebugLevel > 0 {
log.Printf(`calling TST_oracall.simple_nums_count(nums=>v001,
p_cnt=>:p_cnt,
p_txt=>:p_txt)
with %s`, params)
}
if _, err = ses.PrepAndExe(Tst_oracall__simple_nums_count__plsql, params...); err != nil {
return
}
if true || DebugLevel > 0 {
log.Printf(`result params: %s`, params)
}
return
}
This runs on the "slice" branch.
Thanks in advance,
Tamás Gulácsi
Trying to just connect to an Oracle db. Nothing fancy. Can you all give and example of a DSN for the ora driver?
Here is what I'm using:
sql.Open("ora",
"user/[email protected]:1521/SID")
Just seems to terminate without doing anything. Not even an error message.
I use _"gopkg.in/rana/ora.v3" to import the package.
Dear,
I have an table with field of varchar2(1024) , with valid spaces ASCII 32 to rigth.
When I fetch records , the field value has loss trailing spaces?
Exists an option for disable this one?
Thanks,
JM
fragment code:
stmtQry, err := testSes.Prep("SELECT field1 FROM table", ora.OraS )
stmtQry.Cfg().Rset.SetVarchar(ora.OraS)
...
rset, err := stmtQry.Qry()
......
for rset.Next() {
fmt.Println( len(rset.Row[0].(ora.String).Value) )
msgStream <- rset.Row[0].(ora.String).Value
}
Please, could you explain why NUMBER Oracle type converts to string?
Hi,
getting following error in go get
C:/Go/bin/go.exe get -v . [D:/Workspace/Go-Ide/GOPATH/src/tutorial]
gopkg.in/rana/ora.v3
# gopkg.in/rana/ora.v3
cc1.exe: fatal error: C:/instantclient-sdk-win64-10.2.0.5/instantclient_10_2/sdk/include/: Permission denied
compilation terminated.
..\gopkg.in\rana\ora.v3\bndBfile.go:8:17: fatal error: oci.h: No such file or directory
compilation terminated.
Here is my machine information
TDM-GCC-64
Windows Server 2208 R2-SP1
go version go1.3.1 windows/amd64
Any help would be appreciated.
Greetings,
Trying to run a PL/SQL function and get the value back but it does not seem to be working. Trying to call something like:
begin :1 = MY_FUNC(); end;
The bind variable passed does not get updated with the value from the PL/SQL function. For testing, made the PL/SQL simpler ran the following Go:
...
var int1 int64
var pInt1 *int64
int1 = 5
pInt1 = &int1
_, err = db.Exec("begin select 10 into :1 from dual; end;", pInt1)
...
fmt.Println(int1)
fmt.Println(pInt1)
fmt.Println(*pInt1)
The output was still 5, instead of the wanted 10.
So I did some digging and found that "database/sql" does a convert of values before passing them to the ora driver. Here are a couple of notes if you want to did into the database/sql" code. In convert.go, driverArgs gets called, which for each arg, calls driver.DefaultParameterConverter.ConvertValue which is in types.go. That in turn does a rv := reflect.ValueOf(v) and then calls defaultConverter{}.ConvertValue(rv.Elem().Interface()). So basically returns the interface of the pointer. The short version is it converts any pointers into non-pointers. For example a *int64 into int64.
So on to the ora code. Looking at stmt.go there is a huge switch statement that for each params does switch value := params[n].(type). The issue is that the pointer types will never get called because the params have been converted to non-pointers. So for example, the case *int64: will never get called. The solution there might be to use reflect type of and get the kind, which will still be equal to reflect.Ptr. Then you can make to sets of switch value := params[n].(type) statements, one for pointers and one for other. That seems pretty easy and straight forward, however was not sure if doing that would break other code. Plus would still need to covert the non-pointer back to a pointer.
I did some testing (hack job) in bndInt64.go and found if you passed C.OCINumberToInt a valid pointer, it did return the wanted 10. So the good news is it seems quite fixable and one do not have to mess with the C code.
Hope that provided enough information to fix it. Happy to help more if I can.
Best regards,
Michael
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.