I always try to declare a sql statement, a constant, etc just once and then use it.
So, in a form there is a value which remains specific and stable(a constant).
In order to be used this constant in some places (record groups, form triggers), it is declared in a form packaged spec as :
a_constant constant varchar2(20) :='0006260000';
In order to be used in record group, this constant is copied to a form parameter, in the WHEN-NEW-FORM-INSTANCE form trigger, as:
:parameter.p_a_constant := my_package.a_constant;
There is a need this constant to be used in a query data source name of a block as follows:
tbl1 dra,
(select col1, col2, col3
from tbl2 vmo
where vmo.col5 = '0006260000'
union all
select col1, col2, col3
from tbl3 su
where su.col6 = '0') vmo
The above written in the query data source name runs successfully. But i'd rather write it as:
tbl1 dra,
(select col1, col2, col3
from tbl2 vmo
where vmo.col5 = :parameter.p_a_constant
union all
select col1, col2, col3
from tbl3 su
where tbl3.col6 = '0') vmo
But when used this construct the error message 'Error occured executing query' appears.
The Oracle Forms translates the submitted sql query (last query of the block) as:
select col1, col2
from tbl1 dra,
(select col1, col2, col3
from tbl2 vmo
where vmo.col5 = :parameter.p_a_constant
union all
select col1, col2, col3
from tbl3 su
where tbl3.col6 = '0') vmo
where dra.col1 = 12300 and
dra.col2 = vmo.col1(+)
In other words, the :parameter.p_a_constant IS NOT REPLACED BY THE VALUE this parameter does have at that moment. That's why it fails...
Is there any way to overcome the use of this static value (i mean the use of the value '0006260000') and use the
parameter value?
Thanks,
Sim
Note:
I use Oracle Forms10g
Db 11g v.2