oracle apex - Validation to detect text in numeric field -


i'm trying prevent users crashing create new product apex page. on create page have text field:product_name , numeric field: product_quantity.

currently when enter text in product_quantity field , click 'save' following error:

error processing validation.

ora-01722: invalid number

i have investigated error thought in apex, if selected numeric field, detect whether user entered text or numeric characters?

is there method display validation message if user has entered text, shouts, otherwise enables user save new entry?

update

i know why happening dont know how solve it.

i recreated page , worked. added 2 pieces of validation in page processing , when try error in intial post. if disable them works again. validation use not exists find whether entered value exists in table before add it.

if validation kicks in after looking whether numerical value has been entered. stopped validation looking @ associated item, , turned off 'when button pressed' still no joy.

select 1 my_table column_name = :p6_text_field 

is there way run text box validation (checking whether text entered) before validation have created in page processing?

that's thing validations: executed , not short-circuit. can see happening when debug page.
in case of number field, you'd see not pass number validation. not stop validation. second validation run uses submitted value, fail when entered text instance.


there work-arounds that. example, change not-exists validation plsql function returning error message , execute (example):

declare   v_test_nbr number;   v_check_exists number; begin   begin     v_test_nbr := to_number(:p6_text_field);   exception   when others     -- or catch 1722 (invalid number) , 6502 (char number conversion error)     v_test_nbr := null;   end;    if v_test_nbr not null     -- if v_test_nbr not null field should numerically valid   -- if isn't code skipped , validation   -- not throw error.   -- however, previous validation still fail when text entered,    -- shouldn't matter.     begin       select 1       v_check_exists       my_table       column_name = :p6_text_field;     exception      when no_data_found       v_check_exists := 0;     end;      if v_check_exists = 1            return 'a record key exists';           end if;   end if;    return null; end; 

however - in case, want check duplicate entries better option may exist if @ least on version 4.1. if table has correct constraints defined, have unique key defined on field performing not-exists on. means if not have validation on field, ora-00001 dup_val_on_index error.
use error processing provided apex catch error, , produce user-friendly message.
can find example of how use , implement on blog of patrick wolf of apex development team:
apex-4-1-error-handling-improvements-part-1/
apex-4-1-error-handling-improvements-part-2/


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -