Using constants [message #642534] |
Mon, 14 September 2015 02:35 |
|
phiroc
Messages: 10 Registered: September 2015
|
Junior Member |
|
|
Hello,
I have created a PL/SQL function that contains the below code.
What's the best way to store string constants, such as 'vat_registration,' in PL/SQL?
Should I store them in a table and replace
CASE WHEN (computation_type = 'vat_registration'
by something like
-- create varray containing all values in constant-string-table
CASE WHEN (computation_type = varray(2)
where varray(2) contains 'vat_registration' type
... or is there a better way?
Many thanks.
Phiroc
FUNCTION compute_tax_fn ( vendor_form_id_in IN vendor_form.id%TYPE, computation_type IN vendor_form_tax_comp_types.name%TYPE )
RETURN VARCHAR2 AS
political_union VARCHAR2(10);
country_abbreviation VARCHAR2(3);
returned_string VARCHAR2(20);
BEGIN
political_union := vendor_form_political_union_fn(vendor_form_id_in);
IF (political_union) = 'EU' THEN
CASE WHEN (computation_type = 'vat_registration'
OR computation_type = 'vat_reporting_country') THEN
returned_string := 'FRA';
WHEN (computation_type = 'vat_default') THEN
returned_string := 'VAT reporting FRA';
...
|
|
|
|
|
Re: Using constants [message #642566 is a reply to message #642565] |
Mon, 14 September 2015 08:12 |
|
Michel Cadot
Messages: 68648 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
You have to take care of the scope you want for your variable value.
If the value is private to a session, it is better to have a package variable.
If the value must be transactional and must see the value changed by other sessions when commited then it is better to have a parameter table.
If the value must be transactional but must not changed during your own transaction then you must change your transaction isolation level.
...
[Updated on: Mon, 14 September 2015 10:15] Report message to a moderator
|
|
|
|
|