‎2010 Mar 15 11:20 AM
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.
‎2010 Mar 15 11:35 AM
Hi,
I think you have to bring the loop and end loop outside of EXEC and END EXEC.
Hope it helps.
Thanks
Mani
‎2010 Mar 15 11:49 AM
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.
‎2010 Mar 15 11:57 AM
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
‎2010 Mar 15 11:38 AM
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...
‎2010 Mar 15 11:42 AM
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
‎2010 Mar 15 11:47 AM
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.
‎2010 Mar 15 11:57 AM
ITS still throwing the same dump. after using your piece of code
‎2010 Mar 15 12:06 PM
Can you post here the error from "Database error text" field of dump?
‎2010 Mar 15 12:27 PM
The error 102 occurred in the current database connection "DEFAULT"".
‎2010 Mar 15 12:37 PM
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.
‎2010 Mar 15 12:43 PM
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
‎2012 Nov 30 6:45 AM
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!