DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: insert question

  1. #1
    Join Date
    Oct 2000
    Posts
    90

    Post

    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?

  2. #2
    Join Date
    Aug 2001
    Posts
    75
    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

  3. #3
    Join Date
    Oct 2000
    Posts
    90
    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.

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    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
  •  


Click Here to Expand Forum to Full Width