How can define the format mask [message #232718] |
Mon, 23 April 2007 01:43 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
habib.khan
Messages: 20 Registered: March 2007 Location: Islamabad
|
Junior Member |
|
|
Hello everybody,
i am using oracle 10g.i have a field name cnic number with data type is 'char'.i want to define the format mask in this field .i have been try like this '99999-9999999-9' but oracle display an error message 'wrong format mask for this data type'. How can i solve this problem.
if anyone can help me,please send the format mask instruction.
thanks in advance.
habib khan
|
|
|
|
Re: How can define the format mask [message #232892 is a reply to message #232718] |
Mon, 23 April 2007 19:10 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
From the Oracle SQL Reference Manual | A format model is a character literal that describes the format of DATE or NUMBER data stored in a character string. You can use a format model as an argument of the TO_CHAR or TO_DATE function for these purposes:
|
Bascially, it does not work on a character field but during the transformation INTO a character field.
You have a database field 'cnic' which is on type 'char'. To use formatting you need to work with it as a number.
In your form do NOT display your character 'cnic' field, create a non-database field ('cnic_num') of type number with the format you desire, in the Post-Query trigger populate 'cnic_num' from 'cnic' and in the When-Validate-Item trigger of 'cnic_num' populate 'cnic'.
If you wish to STORE the number WITH the hyphens ('-') then you will have to use that format in the 'to_number' and 'to_char' that you have in the two triggers.
David
|
|
|