I dont know what to search for so I dont know if question has already been answered :-)
I have an Oracle function returning an ID, I want to use this function multiple times in a SQL select statement.
Excample:
select
custname,
custid,
salesorderid,
getIdFromSalesOrder(salesorderid),
qty,
getPriceFromID(getIdFromSalesOrder(salesorderid)),
getXFromID(getIdFromSalesOrder(salesorderid)),
getYFromID(getIdFromSalesOrder(salesorderid)),
getZFromID(getIdFromSalesOrder(salesorderid))
from
tableX,
tableY
where
.......
is there any way to use a local variable so I avoid calling getIdFromSalesOrder again and again?
Mayby something like this?
id_ number(10,0);
select
custname,
custid,
salesorderid,
getIdFromSalesOrder(salesorderid) into id_,
qty,
getPriceFromID(id_),
getXFromID(id_),
getYFromID(id_),
getZFromID(id_)
from
tableX,
tableY
where
.......
SQL select statement will return 3-4.000 rows so in some way the variable will need to be pr. row?
Best regards Anders