strings & character validation [message #10356] |
Fri, 16 January 2004 20:14 |
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 |
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 |
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 |
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 |
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.
|
|
|
|
|
THANKS [message #10451 is a reply to message #10400] |
Thu, 22 January 2004 20:51 |
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
|
|
|
|
|