Home » SQL & PL/SQL » SQL & PL/SQL » strings & character validation
strings & character validation [message #10356] Fri, 16 January 2004 20:14 Go to next message
reshmi
Messages: 3
Registered: January 2004
Junior Member
hi all
how can we validate the field contains or entered only strings or character
can any give one example
regards
reshmi
Re: strings & character validation [message #10361 is a reply to message #10356] Sat, 17 January 2004 06:46 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
quote from reshmi:
----------------------------------------------------------------------
hi all
how can we validate the field contains or entered only strings or character
can any give one example
regards
reshmi

----------------------------------------------------------------------
Reshmi,

What do you mean by "only strings or character"?

In this example, I constrain the characters in the table's VARCHAR2 column to spaces and the twenty-six letters of the alphabet:
SQL> CREATE TABLE t (x VARCHAR2(15)
  2                  CHECK (REPLACE(TRANSLATE(UPPER(x)
  3                                 ,         'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
  4                                 ,         'AAAAAAAAAAAAAAAAAAAAAAAAAAA')
  5                         ,       'A') IS NULL));
 
Table created.
 
SQL> INSERT INTO t VALUES ('test');
 
1 row created.
 
SQL> INSERT INTO t VALUES ('TeStInG aGaIn');
 
1 row created.
 
SQL> INSERT INTO t VALUES (RPAD(' ',15));
 
1 row created.
 
SQL> INSERT INTO t VALUES ('+');
INSERT INTO t VALUES ('+')
*
ERROR at line 1:
ORA-02290: check constraint (XXFI.SYS_C00219192) violated
 
 
SQL> INSERT INTO t VALUES ('6 six');
INSERT INTO t VALUES ('6 six')
*
ERROR at line 1:
ORA-02290: check constraint (XXFI.SYS_C00219192) violated
 
 
SQL> INSERT INTO t VALUES ('Oracle FAQ');
 
1 row created.
 
SQL> COMMIT;
 
Commit complete.
 
SQL> SELECT x
  2  FROM   t
  3  /
 
X
---------------
test
TeStInG aGaIn
               
Oracle FAQ
 
SQL>
If you meant something else, Reshmi, please be more specific and supply examples of what you expect the code to do.

Hope this helps,

Art.
Re: strings & character validation [message #10371 is a reply to message #10361] Sun, 18 January 2004 20:41 Go to previous messageGo to next message
ramya
Messages: 87
Registered: August 2002
Member
hi Art
my problem is i am using developing in forms
i have to do validation in user interface .as u told we can do in database level but i have to validate that field in interface
but its not giving any error or any results
pls hlp
ramya
Re: strings & character validation [message #10372 is a reply to message #10361] Sun, 18 January 2004 20:57 Go to previous messageGo to next message
ramya
Messages: 87
Registered: August 2002
Member
hi Art
my problem is i am using developing in forms
i have to do validation in user interface .as u told we can do in database level but i have to validate that field in interface
but its not giving any error or any results
pls hlp
ramya

IF TRIM (TRANSLATE (:block3.txtname,
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
' ')) IS NOT NULL
THEN RAISE Form_Trigger_Failure;
Message('You cannot enter numberic');
END IF;
Re: strings & character validation [message #10377 is a reply to message #10372] Mon, 19 January 2004 03:41 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Why was REPLACE removed from the code? It needs to be in there.

Does this code work?
IF (REPLACE(TRANSLATE(UPPER(TRIM(:block3.txtname))
            ,         'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            ,         'AAAAAAAAAAAAAAAAAAAAAAAAAA')
    ,       'A') IS NOT NULL) THEN
    RAISE Form_Trigger_Failure;
    Message('You cannot enter any numbers; only letters of the alphabet.');
END IF;
A.
Re: strings & character validation [message #10396 is a reply to message #10377] Tue, 20 January 2004 19:54 Go to previous messageGo to next message
ramya
Messages: 87
Registered: August 2002
Member
hi art
the code is not working i
gave in when button pressed and again mouse leave
but no error messages r commin
pls hlp
Re: strings & character validation [message #10400 is a reply to message #10396] Wed, 21 January 2004 04:00 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Ramya,

What does the code do if you temporarily remove the RAISE statement?

Just curious,

Art.
THANKS [message #10451 is a reply to message #10400] Thu, 22 January 2004 20:51 Go to previous messageGo to next message
ramya
Messages: 87
Registered: August 2002
Member
hi Art
its working now very very thanks to ur help.Then i am new to oracle.wE r not accessible net at office that's im giving one day late to reply
devlopment andbefore i ben in micro soft tech but this is good not easy as vb .One more query how can be get back the cursor position to
the desired text filed.

ramya
Re: Get back cursor position [message #10454 is a reply to message #10451] Fri, 23 January 2004 05:15 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Ramya,

You can't go "backwards" through a cursor: you have to reopen it.

See http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064#6969336986834.

A.
Re: strings & character validation [message #11362 is a reply to message #10400] Mon, 22 March 2004 20:54 Go to previous message
richa
Messages: 7
Registered: January 2000
Junior Member
how to validate character using java script
Previous Topic: How can i change the display number in a query result?
Next Topic: Table name which has the maximum columns
Goto Forum:
  


Current Time: Fri Apr 19 12:29:49 CDT 2024