Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sql statement

Former Member
0 Likes
1,135

Hi Experts,

EXEC SQL.

select APID_SEQ.NEXTVAL INTO :v_apid FROM DUAL

ENDEXEC.

I could not understand that pgm!

How is prepared for it?

Plz reply me soon,

Thx,

S.Suresh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,043

EXEC SQL [PERFORMING subr].

...

ENDEXEC.

These statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:

Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.

You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately. These SAP-specific language elements are::

EXCEC SQL PERFORMING subr.

SELECT ... INTO :wa1 :wa2 ...

ENDEXEC.

Effect

If the PERFORMING addition that is forbidden in classes is specified after EXEC SQL, the native SQL interface performs an implicit cusor edit.

Only a SELECT statement can be used as a native SQL statement. The native SQL interface starts a cursor for the SELECT statement and reads the appropriate data, row by row. After each successful read of a row, the subr subroutine is called. The subr subroutine must be defined in the same ABAP program and must not have any parameter interface.

When the host variables specified in the SELECT statement after INTO are global data objects of the ABAP program, they can be evaluated in the subroutine. In the subroutine, sy-dbcnt gets the number of rows read so far and sy-subrc is set to the value 0. After the ENDEXEC statement, sy-dbcnt contains the number of rows read altogether so far and sy-subrc is set to value 4 since no more lines could be read using the implicit cursor.

11 REPLIES 11
Read only

bpawanchand
Active Contributor
0 Likes
1,043

Hi

To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:

EXEC SQL PERFORMING <form>

<Native SQL statement>

ENDEXEC.

check out this link it helps you a lot

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

Regards

Pavan

Edited by: Pavan Bhamidipati on Jul 8, 2008 7:34 AM

Read only

Former Member
0 Likes
1,043

hi,

Here you are placing the next value of APID_SEQ into v_apid.

FROM DUAL is for using DUAL table which to provide a table for joining in internal views.

To read more about Dual Tables refer to this link.

[http://en.wikipedia.org/wiki/DUAL_table]

Hope this will Help.

Regards

Sumit Agarwal

Read only

0 Likes
1,043

Hi Sumit Agarwal,

I could not get output that program!!

Plz how is change configure that?

Reply me soon,

S.Suresh.

Read only

0 Likes
1,043
Read only

Former Member
0 Likes
1,043

Hello suresh,

The given code is a combination of native sql & dual table concept in sap .Check this out for that.

NATIVE SQL

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

DUAL TABLES

ftp://mirrors.ircam.fr/pub/mysql/doc/maxdb/en/10/a80342ed386824e10000000a1550b0/content.htm

Regards,

Bhumika

Read only

Former Member
0 Likes
1,043
Read only

Former Member
0 Likes
1,043

HI,

chk this link out..

Regards.

Read only

Former Member
0 Likes
1,044

EXEC SQL [PERFORMING subr].

...

ENDEXEC.

These statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:

Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.

You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately. These SAP-specific language elements are::

EXCEC SQL PERFORMING subr.

SELECT ... INTO :wa1 :wa2 ...

ENDEXEC.

Effect

If the PERFORMING addition that is forbidden in classes is specified after EXEC SQL, the native SQL interface performs an implicit cusor edit.

Only a SELECT statement can be used as a native SQL statement. The native SQL interface starts a cursor for the SELECT statement and reads the appropriate data, row by row. After each successful read of a row, the subr subroutine is called. The subr subroutine must be defined in the same ABAP program and must not have any parameter interface.

When the host variables specified in the SELECT statement after INTO are global data objects of the ABAP program, they can be evaluated in the subroutine. In the subroutine, sy-dbcnt gets the number of rows read so far and sy-subrc is set to the value 0. After the ENDEXEC statement, sy-dbcnt contains the number of rows read altogether so far and sy-subrc is set to value 4 since no more lines could be read using the implicit cursor.

Read only

Former Member
0 Likes
1,043

hi,

what error r u getting.

regards

Sumit Agarwal

Read only

0 Likes
1,043

hi,

plz send me ur mail ID.

i will send u with that file.

Regards,

S.Suresh.

Read only

Former Member
0 Likes
1,043

Hi,

We can retrieve data from Database using OPEN SQL and NATIVE SQL .

Generally the SQL statements which we use in our ABAP programs are OPEN SQL statements.

If you want to use NATIVE SQL statements then write between

EXEC SQL. and ENDEXEC.

Database understands only SQL commands. But what ever we write in OPEN SQL are internally SQL statements only.

The DATABASE UTILITY is the interface between the ABAP Dictionary and the relational database underlying the R/3 System.

Regards,

Rajitha.

Edited by: Rajitha Muthineni on Jul 8, 2008 11:37 AM