I can't check it right now (don't have a compiler right now), but will that query executes ?
select myTable.id_customer, [my_procedure_or_function](myTable.id_customer)
from myTable
group by myTable.id_customer
that procedure/function returns a NUMERIC(18,0) or NULL
to sum up, I need to select distinct id_customer from that table and for that id - get a number/null value currently associated with that id_customer
You cannot call a procedure in a select statement, because it does not return anything.
We can not directly use stored procedures in a SELECT statement.
You can call a stored procedure inside a user-defined function. Consider this example: SQL> create table test_tab (tab_id number); Table created.
Syntactically it will work for a scalar UDF but not a stored procedure.
select myTable.id_customer, mySchema.myFunction(myTable.id_customer) As myAlias
from myTable
group by myTable.id_customer
However dependant upon what the scalar UDF is doing there may be more performant approaches. If it is looking up a value in another table for example it is often best to simply inline this logic into the query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With