-
I have a column (ORDER_NUM) in one of my tables (table name is RENT) that has a numeric data type of 10
desc RENT
Name Null? Type
----------------------------------------- -------- ----------
RENTER VARCHAR2(50)
ORDER_NUM NOT NULL NUMBER(10)
I have to insert 111 into the ORDER_NUM column. But I would like
to left pad Zeros before inserting the 111.
Is this possible? Can any one give me the syntax to do this?
-
If you would like to pad zero's, first thing, you have to do is instead of Number datatype, you have to use Varchar2 datatype for Order_Num column and then you can use LPAD sql function.
Why would you like to pad ? If you want to display the Order_Num data with zero pad values, you can use LPAD function in the select statments.
Thanks
Sanjay
OCP 8i
-
Okay assuming I have changed it the data type for the column to be varchar2, can you give the syntax for the LPAD function to do this insert?
I'm only farmiliar with using the LPAD function in a select statement not and not in an insert like I want.
-
Code:
SQL> insert into xyz values ( lpad(20, 10,'0')) ;
1 row created.
SQL> commit;
Commit complete.
SQL> select * from xyz;
X
--------------------
0000000020
SQL> desc xyz
Name Null? Type
----------------------------------------- -------- --------------------
X VARCHAR2(20)
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|