0
Currently I have a precedent that reads an XML, and updates the table fields personal based on the values sent by XML, such as CPF, RG, Name, etc.
Today I read the XML values and insert in the table variable.
pessoa_fisica_w pessoa_fisica%rowtype;
Once done, I do the following update.
update pessoa_fisica
set row = pessoa_fisica_w
where cd_pessoa_fisica = pessoa_fisica_w.cd_pessoa_fisica;
Today it works.
What I need now is to receive the key field to update XML. It is currently fixed cd_person = person and would need and need to perform a dynamic update.
Would that 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 XML.
My problem is, how would a dynamic query read the personal, Today I run into trouble PLS-00306: incorrect number of argument types in the call to '||' because of concatenation, and there would also be a problem in accessing the pesoa_fisica_w. '||c01_w.ds_campo_acao.
There would be some way to create this generically, or would have to manually make all fields using case/if and always passing fixed the fields of Where update, along with the values?
The fields are char ?
– Motta
Field types vary between varchar2 and number only.
– Jonathan Cani
The fields varchar2 and char need to come between parentheses in the UPDATE command. Concate quotes for this, I think syntax is something like'''|field||''''
– Motta
The problem is that person_fisica_w is a rowtype, not a varchar2, occurs invalid type.
– Jonathan Cani
Row was an attempt to set all columns of the table ?
– Motta
That’s right, therefore, the columns are in constant changes, so I used to set all the columns. I also used it because it is easier to manipulate the values when transferred from xml cursor to Row.
– Jonathan Cani
You would have to mount an sql by reading the metadata table dba_tab_columns
– Motta
Okay, a problem would solve it, but the problem of dynamically taking the value of a field from inside a rowtype, would there be like, something like people_fisica_w.field('field')?
– Jonathan Cani
Yes that would be it. When I’m on a PC I try to mount a response.
– Motta
I am waiting, because I had to put this problem aside and check others, since I could not find a solution.
– Jonathan Cani