Get the above error when the execute immediate is called in a loop
Update CustomersPriceGroups set 1AO00=:disc Where cuno=:cuno
Parameters: disc=66 cuno=000974
Update CustomersPriceGroups set 1AP00=:disc Where cuno=:cuno
Parameters: disc=70.5 cuno=000974
Update CustomersPriceGroups set 1AQ00=:disc Where cuno=:cuno
Parameters: disc=66 cuno=000974
Update CustomersPriceGroups set 1ZA00=:disc Where cuno=:cuno
Parameters: disc=60 cuno=000974
What does this mean ?
Here is the code fragment
c:=PriceWorx.frcPriceListCustomers('020','221');
LOOP
fetch c into comno,cuno,nama,cpls;
exit when c%notfound;
dbms_output.put_Line(cuno);
g:=priceWorx.frcPriceListItemGroups('020','221');
d:=priceworx.frcCustomerDiscounts('020','221',cuno);
loop
fetch g into comno,cpgs,n;
fetch d into comno,cpls,cuno,cpgs,stdt,tdat,qanp,disc,src;
--dbms_output.put(chr(9)||cpgs);
sQ:='Update saap.CustomersPriceGroups set "'|| trim(cpgs)||'"=:disc '
|| ' Where cuno=:cuno';
execute immediate sQ using disc,cuno;
commit;
dbms_output.put_line( sQ );
dbms_output.put_line( chr(9)||'Parameters: disc='|| disc||' cuno='||cuno);
exit when g%notfound;
end loop;
close g;
close d;
end loop;
Unquoted identifiers must begin with an alphabetic character (see rule 6 here). You’re trying to assign a value to a column with a name starting with a number
1AO00,1AP00etc.Without seeing the table definition for
CustomersPriceGroupswe don’t know if it has columns with those names. If it does then they must have been created as quoted identifiers. If so you’ll have to refer to them (everywhere) with quotes, which is not ideal – makes the code a bit harder to read, makes it easy to make a mistake like this, and can be hard to spot what’s wrong. Even Oracle say, on the same page:In you code you appear to be using quotes when you assign
sQ, but the output you show doesn’t; but it doesn’t have thesaap.schema identifier either. That may be because you’re not running the version of the code you think, but might just have beenlost if you retyped the data instead of pasting it – you’re not showing the earlier output of
c.cunoeither. But it’s also possible you have, say, the case of the column name wrong.If the
executeis throwing the error, you won’t see the command being executed that time around the loop because the debug comes after it – you’re seeing the successful values, not the one that’s breaking. You need to check all the values being returned by the functions; I suspect thatgis returning a value forcpgsthat actually isn’t a valid column name.As @ninesided says, showing more information, particularly the full exception message, will help identify what’s wrong.