Hello,
I would need the result of this Expression Rule in cod_provincia show me only the code of the provincia to which the municipio belongs. However, it is returning all the codes from my provincias table.
What am I doing wrong?
Thanks in advance.
Discussion posts and replies are publicly visible
Your code is doing exactly what you're asking it to do, which is setting the value of cod_provincia to ALL the values you retrieved into your 'query2' local variable. If you are wanting to basically perform a "lookup" of the cod_proivincia based upon the value of the cod_municipio then you need to perform a fn!wherecontains() on the value of query2 based upon the value of the cod_municipio in the current iteration of your loop. But wihtout seeing the data you've retrieved into 'query' or 'query2' or the exact definitions of the relationships between those datasets it's hard to be precise.
Thanks for your answer.
But, could you put an example to make the fn whereContains?In 'query' I am collecting all the municipios and in 'query2' all the provincias.These tables are related, with provincias being the parent table and municipios being the child.The foreign key is cod_provincia.
You'll have to provide a bit more detail about what the result should be. For a given Municipios what value(s) should be appearing in the 'cod_provincia' attribute of the TIE_Municipios datatype?
The first two digits of the cod_municipality should appear as a value in the cod_provincia
If the first two digits of the cod_municipality is the cod_provincia then you can eliminate query2 and just use the left(cod_municipality, 2) function.
The better solution though would likely be using a view in the database though.