0
I’m having a question here that I need to solve with a postgresql database function.
The problem is this, I need to cross a table that’s called stocking with a view called stockpile. In this table stocking are only the codes of the records that had their stock updated, the fields are id_general, command and dt_atz, the view stockpile back all stock table records as per your affiliate and etc.
If I cross the two, comparing the general id_s of both the query takes considerably to bring the records, even if they are few (it takes about 50 seconds to bring 4 records).
So I need to first select all the table records stocking and after that check all records in the view stockpile that are in agreement with what resulted in the first query. Something like what is below:
SELECT * FROM estoque WHERE id_geral IN (001,002,003)
This must be returned along with the value of the table command field stocking.
There is a way for me to do this within a database function so that it is possible for me to just call the function and it returns me all this information?
And the array enters where in this problem or solution?
– rray
It is that I need to make two queries within the function and go through the result of the first in the second... so I know which record of the general id_i will put in clause IN() of the second query.
– Joel Piccoli da Rosa
You can enter the function code?
– rray
There it is, as I do not work directly with bank I have no idea how to set up this function... That’s why I needed help on how to get to this solution.
– Joel Piccoli da Rosa