Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference between open sql & native sql ?

Answer Posted / sameera

Open SQL
Open SQL allows developers to control SQL statements
directly. Open SQL encapsulates the semantics for statement
execution, parameter binding and results fetching provided
by each database vendor in a vendor- independent interface.
The operations performed with Open SQL translate directly
to the primitive operations provided by each database, yet
the API is consistent across all vendors.

To avoid incompatibilities between different database
tables and also to make ABAP/4 programs independent of the
database system in use, SAP has created a set of separate
SQL statements called Open SQL. Open SQL contains a subset
of standard SQL statements as well as some enhancements
which are specific to SAP.

Open SQL contains the following keywords:

SELECT - Reads data from database tables.
INSERT - Adds lines to database tables.
UPDATE - Changes the contents of lines of database tables.
MODIFY - Inserts lines into database tables or changes the
contents of existing lines.
DELETE - Delete lines from database tables.
OPEN CURSOR, FETCH, CLOSE CURSOR - Reads lines of database
tables using the cursor.
All Open SQL statements fill the following two system
fields with return codes:

SY-SUBRC
After every Open SQL statement, the system field SY-SUBRC
contains 0 if the operation was successful, a value other
than 0 if not.
SY-DBCNT
After an OPEN SQL statement, the system field SY-DBCNT
contains the number of database lines processed.
Open SQL allows you to access all database tables known to
the SAP system, regardless of the database manufacturer.
Sometimes, however, we may want to use database-specific
SQL statements called Native SQL in the ABAP/4 program.

A database interface translates SAP\'s Open SQL statements
into SQL commands specific to the database in use. Native
SQL statements access the database directly.

Native SQL
Native SQL allows you to use database-specific SQL
statements in an ABAP program. This means that you can use
database tables that are not administered by the ABAP
Dictionary, and therefore integrate data that is not part
of the R/3 System.

ABAP Native SQL allows you to include database-specific SQL
statements in an ABAP program. Most ABAP programs
containing database-specific SQL statements do not run with
different databases. If different databases are involved,
use Open SQL. To execute ABAP Native SQL in an ABAP
program, use the statement EXEC. Open SQL (Subset of
standard SQL statements), allows you to access all database
tables available in the R/3 System, regardless of the
manufacturer. To avoid conflicts between database tables
and to keep ABAP programs independent from the database
system used, SAP has generated its own set of SQL
statements known as Open SQL.

If you create a table by using database tools, without ABAP
Dictionary, you are not able to use Open SQL to reach this
table. You just can use Native SQL to do that.

Native SQL statements bypass the R/3 database interface.
There is no table logging, and no synchronization with the
database buffer on the application server. For this reason,
you should, wherever possible, use Open SQL to change
database tables declared in the ABAP Dictionary. In
particular, tables declared in the ABAP Dictionary that
contain log columns with types LCHR and LRAW should only be
addressed using Open SQL, since the columns contain extra,
database-specific length information for the column. Native
SQL does not take this information into account, and may
therefore produce incorrect results. Furthermore, Native
SQL does not support automatic client handling. Instead,
you must treat client fields like any other.

To ensure that transactions in the R/3 System are
consistent, you should not use any transaction control
statements (COMMIT, ROLLBACK WORK), or any statements that
set transaction parameters (isolation level…) using Native
SQL.

Using Native SQL, you can

Transfer values from ABAP fields to the database
Read data from the database and process it in ABAP
programs.
Native SQL works without the administrative data about
database tables stored in the ABAP Dictionary.
Consequently, it cannot perform all of the consistency
check used in Open SQL. This places a larger degree
responsibility on application developers to work with ABAP
fields of the correct type. You should always ensure that
the ABAP data type and the type of database column are
identical.

Native SQL Advantages and Disadvantages - EXEC SQL statement
Advantages

Tables are not declared in ABAP Dictionary can be accessed.
(e.g. Tables belonging to sys or system user of Oracle,
etc.)
To use some of the special features supported by the
database-specific SQL. (e.g. Passing hints to Oracle
optimizer.)
Disadvanteges

No syntax check is performed whatever is written between
EXEC and ENDEXEC.
ABAP program containing database-specific SQL statements
will not run under different database systems.
There is no automatic clien handling for client dependent
tables.
Care has to be taken during migration to higher versions.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between a dialog program and a report?

951


Explain the disadvantage of using exec sql statement in abap?

949


What is the use of the raising exception?

948


How do you write manual bdc session method? : abap bdc

1058


What is the process to enhance the Infotype

3371


What are the two levels in defining a match code ?

1042


How do you process errors in session method ? : abap bdc

1100


Describe data classes? : abap hr

1084


Difference between function group and function module?

1119


Can you delete data element, which is being used by table fields. : abap data dictionary

1106


How would you set the formatting options statically and dynamically within a report?

1038


What are the uses of interactive reporting?

1038


What are logical data bases used in hr module? : abap hr

1240


What’s value table?

1001


How to call transaction in session method without recording?

1970