I currently have a procedure that reads an XML, and does an update on the fields of the physical_person table based on the values sent by the XML, such as CPF, RG, Name, etc.
Today I read the XML values and insert into the table variable.
pessoa_fisica_w pessoa_fisica%rowtype;
Once this is done, I'll do the following update.
update pessoa_fisica
set row = pessoa_fisica_w
where cd_pessoa_fisica = pessoa_fisica_w.cd_pessoa_fisica;
Today this works.
What I need now is to receive the key field to update the XML. Currently it is fixed cd_people_fisica = person_fisica_w.cd_pessoa_fisica and would need and need to perform a dynamic update.
It would be this query:
Exec_sql_Dinamico('grava_log_01',
'update pessoa_fisica ' ||
'set row =' || pessoa_fisica_w ||
'where ' || c01_w.ds_campo_acao || '= pessoa_fisica_w.'||c01_w.ds_campo_acao||';');
c01_w is the cursor with the values obtained from the XML.
My problem is, as a dynamic query would read the personal_women_w , Today I run into problem PLS-00306: incorrect number of argument types in the call to '||' because of concatenation, and there would also be a problem accessing the personal_wiz_w. '|| c01_w .ds_campo_acao .
Would there be any way to create this generically, or would I have to manually do all fields using case / if and always passing fixed fields of where update, along with values?