Solved

the compliting of SQL

Posted on 2009-05-18
4
341 Views
Last Modified: 2013-11-12
If you compile C++code that depends on some sort of SQL library, how does SQL change under the hood?  Is all code changed into some form of optimal abstract data types to store the info?

Looking for a general answer as well as good resource that talks about this - thanks!
0
Comment
Question by:figmit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 400 total points
ID: 24421918
The question is a bit vague, can you qualify "some sort of SQL library", otherwise it is hard to answer specifically.

A "SQL library" could range from hardcoded SQL as in const character strings that cannot be changed (easily) at runtime, to a data file of stored SQL queries that _could_ be modified at runtime.

C++ uses a database specific library to both bind the SQL statement to a set of parameters as well as execute the SQL against the database, so at runtime you can generate dynamic SQL statements, as long as they are legal and the bind variables are of the correct type for parameters in the statement.

Since you use the term "abstract data types", I assume you mean how is inline SQL handled. Typically it is stored the same way as other constant character strings in a C++ program, as string data. It is not parsed at compile time, per se, except to pre-process from embedded SQL syntax to low level API syntax, but it is still stored as a SQL string.





0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 400 total points
ID: 24422009
The only compiling I am aware of, except in the case of Microsoft's new LINQ, is the pre-processing of embedded SQL syntax; this is sort of a standard that lets you mix SQL with the host language (C, C++, etc.) by saying:

char name[100]; // C++ variable

EXEC SQL SELECT NAME INTO :name FROM CUSTOMER;


The pre-processor will convert this to low-level C++ code

Statement * statement = connection->createStatement("SELECT NAME INTO :1 FROM CUSTOMER");
statement->setString(1, name);
ResultSet * result = statement->executeQuery();

As you can see it really doesn't compile the SQL but just translates to expliciti API usage.
0
 
LVL 3

Assisted Solution

by:Akumas
Akumas earned 100 total points
ID: 24557495
generally, SQL lib such as OCI or sybase DBLibrary always map DB data type to basic c data type, like char*, long, int
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
user database (login sql or login windows) 3 52
Oracle Mulit-site configuration 28 73
Need to trim my database size 9 53
Archiving/Deleting Old E-Mail boxes 4 53
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question