Comments (2)
There are three ways. The second and third ones are usually unacceptable.
- Use
OracleType::CLOB
in place ofNone::<String>
and get the CLOB value asClob
. - Use
OracleType::Varchar2(4000)
in place ofNone::<String>
if the maximum size of CLOB data is 4000. - Use
OracleType::Varchar2(32767)
in place ofNone::<String>
and change the Oracle initialization parameterMAX_STRING_SIZE
toEXTENDED
if the maximum size of CLOB data is 32767. (I have not tested this...)
use oracle::sql_type::{Clob, OracleType};
use oracle::Connection;
use std::io::Read; // for clob.read_to_string
const CREATE_TEST_TABLE: &str = "CREATE TABLE test_table (\
text clob
)";
fn repro(conn: Connection) {
let _ = conn.execute("DROP TABLE test_table", &[]);
conn.execute(CREATE_TEST_TABLE, &[]).unwrap();
let mut stmt = conn
.statement("INSERT INTO test_table(text) VALUES (:in1) RETURNING text INTO :out1")
.build()
.unwrap();
let long_text = std::iter::repeat('a').take(4000).collect::<String>();
stmt.execute_named(&[("in1", &long_text), ("out1", &OracleType::CLOB)])
.unwrap();
// https://docs.rs/oracle/latest/oracle/sql_type/struct.Clob.html
let mut clob: Clob = stmt.returned_values("out1").unwrap().remove(0);
let mut s = String::new();
clob.read_to_string(&mut s).unwrap();
assert_eq!(&s, &long_text);
}
from rust-oracle.
Thanks for the fast answer. For context the real code casing this is coming from diesel-oci, so it's much more generic and cannot assume much about the actual fields. Solution 2 will not work there. Solution 1 works for CLOB
columns, but won't work if the user tries to load a VARCHAR
column (diesel-oci does currently not differentiate between these two types). Using the maximal-size variant sounds like it has some negative implications, is that correct?
from rust-oracle.
Related Issues (20)
- use semantic versioning & follow changelog standards HOT 2
- add build matrix to CI with optional features
- Any reason SqlValues are .dup_by_handle()'d on retrieving a row? HOT 3
- VARRAY HOT 2
- Any idea why I'm getting `DPI Error: DPI-1080: connection was closed by ORA-3156` HOT 3
- Usage with asynchronous code problem - how to shut down `.connect()` call that hangs indefinitely HOT 6
- Insert null values HOT 3
- How to change the value of "oracleClientLibDir" in dpiContextCreateParams struct HOT 3
- API to upload file as BLOB without preallocation HOT 3
- Question - async/await stream to many users using just 1 thread HOT 2
- the `?` operator can only be used in a function that returns `Result` or `Option` HOT 1
- QUESTION the trait `ToSql` is not implemented for `SqlValue`
- Question - Calling Oracle Stored Procedures Example HOT 3
- Convert recordset to Vec of Columns HOT 1
- Question - Alter Sessions HOT 1
- A way to set path for oracle instant client HOT 2
- How to extract `Geometry` type. HOT 2
- How can I save ResultSet<'_, oracle::Row> for later access? HOT 6
- `*mut oracle::binding::binding::dpiStmt` cannot be sent between threads safely HOT 2
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 rust-oracle.