Enhance PreparedStatement for Parameter Simplification #154
Replies: 2 comments 4 replies
-
Hi Otavio, Thanks for the suggestion. Perhaps I'm missing something but the only one of the products mentioned that has a way to set unindexed parameters looks like Cassandra. Oracle NoSQL supports both named and positional bind parameters. Named are set using (name, value) pairs. Positional are bound using (index, value) pairs where the index is the position of the "?" bind parameter in the query. It appears Cassandra allows you to do using something like (value1, value2, ... valueN) in a list where the index of the value is implied by the position in the bind call. That seems handy. If any of the products mentioned have a way of inferring the variable from only the type of the parameter please point me to that. I don't see how it's possible in a general case or when "?" is used vs named/typed variables. Again, thanks for the conversation! |
Beta Was this translation helpful? Give feedback.
-
Let me provide an example because I need clarification on what you expect- the desired behavior. The SqlBuilder class (custom class - not in the API) automatically generates my table
In this case, my SqlBuilder internally handles the translation to the appropriate type. It generates the following query (see the
Of course, the following request generates the same queries, but you don't want to use
QuestionSo, for you, is Additional Information:In fact, to do it, I am executing
So instead of
I am using MapValue to obtain a LongValue, StringValue , .... depending on the Java Primitive Data Type of my variable
@gmfeinberg Documentation:https://oracle.github.io/nosql-java-sdk/oracle/nosql/driver/values/MapValue.html
|
Beta Was this translation helpful? Give feedback.
-
In the Oracle NoSQL Database, when using a PreparedStatement, users must define the FieldValue for each parameter, necessitating knowledge of the specific type for each parameter in the query. For example:
This approach can become cumbersome and error-prone when dealing with more complex queries, as users need to translate their values to the appropriate FieldTypes.
Desired Behavior:
We suggest enhancing the PreparedStatement in Oracle NoSQL Database to simplify parameter binding by allowing users to set parameters using a generic method, such as
setParameter(Object field)
. It would make the PreparedStatement more intuitive and user-friendly, similar to how it is implemented in other NoSQL databases like MongoDB, Cassandra, and Neo4J.Use Case:
A more user-friendly PreparedStatement would make it easier for developers to work with Oracle NoSQL Database, especially for complex queries where the internal database field types are not immediately apparent or relevant to the user.
References:
Proposed Implementation:
Introduce a new method,
setParameter(Object field)
, in the PreparedStatement API, which would accept an object and internally handle the translation to the appropriate FieldType, similar to how other NoSQL databases simplify parameter binding.Additional Information:
This enhancement would improve the usability of Oracle NoSQL Database and align it with industry standards for parameter binding in prepared statements. It would also reduce the cognitive load on developers by abstracting away the internal details of field types.
Beta Was this translation helpful? Give feedback.
All reactions