Hello Guys,
I'm trying to do this in Oracle Forms and am having some mistakes. I'm recording a clean field in the database, without masks, only numbers, however, beyond that field being a PK, it was created as VARCHAR2. I tried several ways to present the field with mask for the user and save it without the mask, but without success. Remember that use the same field for both CPF and for CNPJ, costing me a check box, which says it is checked individual, if unchecked, says it is a legal entity. Am I using the right triggers? Follows the problem:
1-To display the formatted field when I bring it on the screen, I'm encoding the trigger "When-New-Record-Instance" block-level.
Select all
IF :VIEW_CLI_ISAIAS.CLI_TIPO_ID = 'F' THEN
l_prc_alerta('Entrou como CPF');
/*SELECT Decode(:VIEW_CLI_ISAIAS.CLI_ID, NULL, NULL,
Translate(To_Char(:VIEW_CLI_ISAIAS.CLI_ID/100,
'000,000,000.00'), ',.', '.-'))
into :VIEW_CLI_ISAIAS.CLI_ID
from dual;*/
/* SELECT DECODE(LENGTH(:VIEW_CLI_ISAIAS.cli_id),14, SUBSTR(:VIEW_CLI_ISAIAS.cli_id,1,2)||'.'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,3,3)||'.'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,5,3)||'/'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,8,4)||'-'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,12,2)
,0)
into :VIEW_CLI_ISAIAS.CLI_ID
from dual;*/
SET_ITEM_PROPERTY('CLI_ID', FORMAT_MASK, '000"."000"."000"-"00');
ELSIF :VIEW_CLI_ISAIAS.CLI_TIPO_ID = 'J' THEN
l_prc_alerta('Entrou como CNPJ');
/* SELECT DECODE(LENGTH(:VIEW_CLI_ISAIAS.cli_id),14, SUBSTR(:VIEW_CLI_ISAIAS.cli_id,1,2)||'.'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,3,3)||'.'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,5,3)||'/'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,8,4)||'-'||
SUBSTR(:VIEW_CLI_ISAIAS.cli_id,12,2)
,0)
into :VIEW_CLI_ISAIAS.CLI_ID
from dual;*/
set_item_property('CLI_ID', FORMAT_MASK, '00"."000"."000"/"0000"-"00');
END IF;
Error presented:
FRM-40105: UNABLE TO SOLVE REFERENCE TO ITEM 45704205836 <------ (This is a CPF)
] 2-shot mask for recording on trigger "Pre-Insert" and "Pre-Update" also block-level (this're working!).
Select all
IF :VIEW_CLI_ISAIAS.CLI_TIPO_ID = 'F' THEN
SELECT REPLACE(Translate(:VIEW_CLI_ISAIAS.CLI_ID,'.-',' '),' ')
INTO :VIEW_CLI_ISAIAS.CLI_ID
FROM dual;
ELSIF :VIEW_CLI_ISAIAS.CLI_TIPO_ID = 'J' THEN
SELECT REPLACE(Translate(:VIEW_CLI_ISAIAS.CLI_ID,'./-',' '),' ')
INTO :VIEW_CLI_ISAIAS.CLI_ID
FROM dual;
END IF;
3-To present a field that is being inserted or updated to the user, encoding the mask on the "When-validate_item" trigger of the item in question.
Error presented:
FRM-40735: When-validate-item Trigger Raised Unhandled Exception Ora-01722
Realize that I tried in several ways in none of them can succeed as the reported errors!
Help me please it!