I've been looking at the OTL (Oracle, Odbc and DB2-CLI Template Library) for C++ database access. I'm unsure of whether the query I pass in is converted to a parameterized query for the underlying database, or if it's basically just concatenating all the arguments into one big string and passing the query to the database that way. I see that the query you pass in to it can include type information for the arguments, but what happens between then and the query hitting the database, I can't tell.
Is C++ OTL SQL database library using parameterized queries under the hood, or string concat?
4k Views Asked by Brett Rossier At
2
There are 2 best solutions below
6
Ken Bloom
On
The documentation talks all about bind variables. I assume that the library is rewriting your query, but it's probably just changing the format of the bind variables into the format your DBMS expects, and then binding the values to the bind variables.
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in SQL
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
- How to create nested selects with sql?
- Pull and push data from and into sql databases using Excel VBA without pasting the data in Excel sheets
- Best Practice for adding columns to a Table in Oracle database
- SQL FIFO STACK using two tables
- SQL Query - Order by String (which contains number and chars)
Related Questions in PARAMETERIZED
- Creating a parametrized field name for a SELECT clause
- Jenkins build parameterized with a choice of versions of a Nexus artifact (all GAVs)
- Parameterized query error, parameter is supplied but says it wasn't
- How to mock 0 or 1 invocation with jmockit
- Loadrunner : Extract text from between two html tags using web_reg_save_param or similar
- Parameterised Test Execution in JUnit Jupiter(JUnit5)
- Assert that certain parameterized vectors will throw an exception in JUnit?
- JUnit Parameterized Tests Processing
- Issue with creating an object from a parameterized constructor with an array as a parameter
- Junit : Runlistener overriden method (testFinished) not called when running a Parameterized test
- JComboBox is a raw type. References to generic type JComboBox<E> should be parameterized
- How do I write an ant script for parameterized jUnit test cases?
- Parameterized method runs twice
- Doing Multiple build in Jenkins using SVN as SCM
- Help with Parameterized Query (using Delphi 7 and BDE)
Related Questions in OTL
- When use Change Notification interface, the ORA-24912: Listener thread failed. Listen failed error occur?
- On MainForm closure OTL threads do not close
- Insert data into mysql table from c++ program using OTL library
- C++ MySQL OTL Getting Started. ODBC Configuration & Errors
- When passing gmock object as reference the setup expectations doesnt match
- Trouble getting OTL connecting to MySQL
- OTL library - SQL Server - C++ - Performance
- Cannot resolve Symbol otl_connect (otl_connect class not including)
- Differences between OTL and SOCI
- Delphi - OTL - Communicating between ThreadPool and Worker thread
- Creating NewTask in a For Loop using Omnithread Library
- Is there any methods to use "try,catch,throw in C++" in the Chromium Project Code
- Inserting binary data into Varchar2 with OTL (OCCI, OCI)
- Using OTL library (c++) to INSERT without binding parameters
- How to connect C++ to MySQL with OTL ODBC driver?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
OTL author's response to my e-mail:
OTL passes queries with placeholders into the DB API layers. The naming conventions for actual bind variables are different for different DB types. Say, for Oracle,
will be translated into:
plus a bunch of host variable bind calls.
For MS SQL Server, or DB2, the same SELECT would look like this:
It's described in the manual that you can't have a placeholder with the same name more than once for MS SQL, DB2. SQL statements with placeholder / bind variables are relatively expensive to create, so if you instantiate an parameterized SQL via an otl_stream, it makes sense to reuse the stream as much as you can.
If you have more questions, or suggestions on how I can improve the OTL manual, feel free to email me.
Cheers, Sergei
pheadbaq wrote:
Hi, I've been evaluating C++ DB libraries recently to use as a base for an ORM library I wish to build, and have been gravitating more and more towards the OTL. It looks very nice by the way, and seems like it would meet most of the needs I have. I just have one lingering question that I can't seem to clarify by reading the docs. Does OTL pass a parameterized query on to the underlying DBMS, or is it concatenating the arguments and query I pass to the OTL stream into a single string and hand that to the DBMS?
In other words, if I hand OTL this MSSQL query, along with with the string "Bob" as the bind variable:
Does the OTL parser produce this:
Or this:
along with my string as a parameter
I've posted this same question to StackOverflow.com if you care to respond there: Is C++ OTL SQL database library using parameterized queries under the hood, or string concat?
Thank you for your time