2005 Aug 09 7:31 AM
Hi
I try to update a database tabel, but I got an error SQL 170:
LOOP AT g_import_tab.
EXEC SQL.
UPDATE MYTABLE
flag =: g_import_tab-flag,
lgnum =: g_import_tab-lgnum,
tanum =: g_import_tab-tanum,
tapos =: g_import_tab-tapos,
squit =: g_import_tab-squit,
lenum =: g_import_tab-lenum,
quknz =: g_import_tab-quknz
where lgnum = g_import_tab-lgnum
and tanum = g_import_tab-tanum
ENDEXEC.
ENDLOOP.
Can you see in the code, what I do wrong?
2005 Aug 09 7:35 AM
Hi,
Try this.
LOOP AT g_import_tab.
EXEC SQL.
UPDATE MYTABLE <b>SET</b>
flag =: g_import_tab-flag,
lgnum =: g_import_tab-lgnum,
tanum =: g_import_tab-tanum,
tapos =: g_import_tab-tapos,
squit =: g_import_tab-squit,
lenum =: g_import_tab-lenum,
quknz =: g_import_tab-quknz
where lgnum = g_import_tab-lgnum
and tanum = g_import_tab-tanum<b>;</b>
ENDEXEC.
ENDLOOP.
But I don't think to update database inside loop.
Kindly reward points if you find it as useful by clciking the star on the left of reply.
Message was edited by: Jayanthi Jayaraman
2005 Aug 09 7:35 AM
Hi,
Try this.
LOOP AT g_import_tab.
EXEC SQL.
UPDATE MYTABLE <b>SET</b>
flag =: g_import_tab-flag,
lgnum =: g_import_tab-lgnum,
tanum =: g_import_tab-tanum,
tapos =: g_import_tab-tapos,
squit =: g_import_tab-squit,
lenum =: g_import_tab-lenum,
quknz =: g_import_tab-quknz
where lgnum = g_import_tab-lgnum
and tanum = g_import_tab-tanum<b>;</b>
ENDEXEC.
ENDLOOP.
But I don't think to update database inside loop.
Kindly reward points if you find it as useful by clciking the star on the left of reply.
Message was edited by: Jayanthi Jayaraman
2005 Aug 09 7:51 AM
Hi
It didn't solved the problem
I have now changed my code, so it isn't inside a loop, and made some hardcode.
My code is now like this:
EXEC SQL.
UPDATE e1ltco SET
flag =: '1',
where lgnum = '100'
and tanum = '0001322808'
and tapos = '0001'
and squit = 'X'
and lenum = '00357096784019929423'
and quknz = 'X'
ENDEXEC.
And I still get the SQL error 170
2005 Aug 09 7:58 AM
Hi,
Semicolon is necessary.Remove the comma.
EXEC SQL.
UPDATE e1ltco SET <b>flag = '1'</b>
where lgnum = '100'
and tanum = '0001322808'
and tapos = '0001'
and squit = 'X'
and lenum = '00357096784019929423'
and quknz = 'X' <b>;</b>
ENDEXEC.
If this is not working,
check this.
EXEC SQL.
UPDATE <b>table</b> e1ltco SET <b>flag = '1'</b> where lgnum = '100'
and tanum = '0001322808'
and tapos = '0001'
and squit = 'X'
and lenum = '00357096784019929423'
and quknz = 'X' <b>;</b> ENDEXEC.
2005 Aug 09 7:56 AM
Hi, don't update the DB in a loop.
As my recommandation, if possbile, try to achieve it in a
Update from TABLE XXXX
That will be fine on the performance.
Thanks