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

EXEC SQL and ENDEXEC issues

Former Member
0 Likes
2,274

Hi ALL,

I want ot delete an internal table entries within EXEC SQL and ENDEXEC.

We are tryinign to delete Open Hub Table data records from OH table.

Can you please suggest me the command.

Right now I am using

EXEC SQL.

loop at it_ohtab into wa_ohtab.

Truncate table wa_ohtab-onj_name

endloop.

ENDEXEC.

The above statement is throwing dump saying "The error 102 occurred in the current database connection "DEFAULT"".

Regards,

SD.

12 REPLIES 12
Read only

Former Member
0 Likes
1,579

Hi,

I think you have to bring the loop and end loop outside of EXEC and END EXEC.

Hope it helps.

Thanks

Mani

Read only

0 Likes
1,579

Hi Mani,

i have tried using the loop-endloop before EXEC-ENDEXEC. but it still throwing a dump.

The SQL command TRAUNCATE/DELETE can work on internal table or work area defined by us.

Also, You were right I am collecteing all the table names in Intertable and Deleting table entries of those tables present in Internal table.

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

Also, you might clear contents of the tables with this Open SQL code:

 
loop at it_ohtab into wa_ohtab.

  DELETE FROM (wa_ohtab-onj_name).

endloop.

Edited by: Alexander Ovcharenko on Mar 15, 2010 12:57 PM

Read only

Former Member
0 Likes
1,579

I want ot delete an internal table entries within EXEC SQL and ENDEXEC.

Why? Internal tables are not controlled with SQL, but with Open SQL statements, like loop...endloop. case or if..then...else and Delete...

Read only

0 Likes
1,579

Hi,

I think what SD wants to conver here is that the table names are in the entries of the internal table and wants to delete the tables not the internal table perse.

Thanks

Mani

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

Hi,

try this code

 
DATA: F1 TYPE TABNAME16.

loop at it_ohtab into wa_ohtab.
  F1 = wa_ohtab-onj_name.

  EXEC SQL.
  TRUNCATE TABLE :F1
  ENDEXEC.

endloop.

Read only

0 Likes
1,579

ITS still throwing the same dump. after using your piece of code

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

Can you post here the error from "Database error text" field of dump?

Read only

0 Likes
1,579

The error 102 occurred in the current database connection "DEFAULT"".

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

It's not a "Database error text" field of dump. You can see this error text in ST22 - Select your dump - Press <F9> - Scroll down - Post here lines which begins from "DB = ". These lines are in the end of list.

Read only

ThomasZloch
Active Contributor
0 Likes
1,579

why use native SQL, (carefully) try the function modules in group SDB2, e.g. DB_TRUNCATE_TABLE.

And please do not cross-post, I asked for deletion of the duplicate in "BI General".

Thomas

Read only

Former Member
0 Likes
1,579

I have the same question today, and I solved it by myself afer I read the page.I used sm21 and I found the error message:Incorrect syntax near '.'. So I know that I write a comma at the end of the sql. I deleted it, it is ok now. Maybe help you!