I have a firebird database where I call a procedure to get some data. This procedure needs an ID so I have two php queries, one of them gives me all the ID's and the another one calls the procedure.
$queryP ="SELECT PROVEEDOR_ID FROM PROVEEDORES";
...some code...
while ($RowQ = ibase_fetch_object ($QueryObject))
{
$queryCompras =SELECT SUM(IMPORTE) FROM ORSP_CM_COMPRAS_PROV($RowQ->PROVEEDOR_ID, '2019-01-01', '2019-12-31', 'B', 'P', 'N');
...some code...
I would like to do something like
SELECT SUM(COMPRA_IMPORTE) FROM ORSP_CM_COMPRAS_PROV((SELECT PROVEEDOR_ID FROM PROVEEDORES), '2019-01-01', '2019-12-31', 'B', 'P', 'N');
To avoid doing too many database calls, but I'm getting
Statement failed, SQLSTATE = 21000 multiple rows in singleton select
Is there any way to do this?