Comments (9)
I think LastInsertID is just undefined for Oracle, so the existing code is just a hack.
I'd delete it and document the undefinedness of LastInsertID and the usage of the "RETURNING" statement.
(We could use ROWID as LastInsertID, iff that'd fit in int64, but it's 10 bytes (http://www.orafaq.com/wiki/ROWID), so this temptation can be resisted :))
from ora.
Cool, thank you :)
from ora.
I'll wait for an amen from Rana Ian...
from ora.
Hi Michael, Tamás,
The design of the &lastInsertId is to intentionally support the Go Result interface method LastInsertId() in the database/sql package.
The LastInsertId() (int64, error) method returns an int64. So the driver supports the interface with &lastInsertId. Some compromises needed to be made to bridge the Oracle database and Go libraries. This was one such compromise.
You are correct that Oracle SQL syntax allows returning multiple variables of any type and that the current driver doesn't support it. It wasn't clear to me that anyone uses that feature. I think the majority of use cases is to support a numeric identity column updated with an Oracle sequence. The driver does have Oracle-only features in the driver which are not accessible from the database/sql package. I'm fine with adding this feature while still supporting the existing functionality.
What do you think?
Thank you,
Rana
from ora.
Sounds good to me. I am not using it at the moment, just thought you should know. Thank you for your help. :)
Just to note it does not seem like the LastInsertId is working as of now.
from ora.
@rana see https://github.com/mattn/go-oci8/blob/master/oci8.go#L1103 and https://github.com/go-goracle/goracle/blob/v1/driver.go#L198 : they're just return an error for LastInsertID, as it is impossible to implement it without severe flaws.
I'm suggesting you to do the same, and remove this functionality - add some documentation and return an errors.New("not implemented - use RETURNING statement") or sth like that.
from ora.
@tgulacsi please, leave it as it is :)
We can not use returning statement through database/sql, and as far as I know, this hack is the only way to get last inserted Id now! (except not using database/sql)
from ora.
Maybe some clarification in the docs, and marking the value for LastInsertID as such:
if strings.Contains(sqlEnd, "RETURNING") && strings.Contains(sqlEnd, "lastInsertID") {
params[len(params)-1] = &lastInsertId
}
So iff "RETURNING xx lastInsertID" will treat the last param as the lastInsertId.
This way if you want lastInsertID, you can have it, but this won't interfere with other RETURNING use cases.
?
from ora.
Go for it, if you can reach the functionality in an improved way, or
document it that's fine
On Thu, Dec 17, 2015, 2:35 AM Tamás Gulácsi [email protected]
wrote:
Maybe some clarification in the docs, and marking the value for
LastInsertID as such:if strings.Contains(sqlEnd, "RETURNING") && strings.Contains(sqlEnd,
"lastInsertID") {
params[len(params)-1] = &lastInsertId
}So iff "RETURNING xx lastInsertID" will treat the last param as the
lastInsertId.This way if you want lastInsertID, you can have it, but this won't
interfere with other RETURNING use cases.
?—
Reply to this email directly or view it on GitHub
https://github.com/rana/ora/issues/43#issuecomment-165414294.
from ora.
Related Issues (20)
- How to get the result of a function HOT 5
- Package 'oci8' has no Name: field HOT 4
- LastInsertId is returning 0, when using database/sql package with oracle driver
- exemple
- Getting error in the.Next() method HOT 5
- sql db.Exec fail to insert "" to blob,runtime error: index out of range HOT 2
- Dependencies HOT 3
- When run the program get That can not find bind point of OCIBindByPos2 in the dynamic link library HOT 8
- My code makes de select and prints <nil> for each row HOT 5
- Build in Bitbucket Pipelines HOT 2
- Stmt.exeC Env.ociError ORA-03135: connection lost contact\nProcess ID: 61366\nSession ID: 2867 Serial number: 6006 HOT 3
- Error during go get HOT 6
- Cannot build with instaclient 11.1 HOT 3
- Data Cartridge Development support HOT 3
- Support AQ HOT 1
- time.Time shows <nil> even if the value is present in the DB HOT 7
- remove lock on break HOT 1
- I am geting BLOB fields with extra content HOT 1
- v4.1.15 Data chaos bug HOT 1
- MAC OS ARM64
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 ora.