Spool a file with a fixed length
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Spool a file with a fixed length

  1. #1
    Join Date
    Dec 2001
    Posts
    6
    Hi,

    I'd like to have a file with fixed length (length of the field) ?

    e.a. :

    field 1 varchar2(5) , field 2 varchar2(2)

    OK t1
    Loos t2
    looset3

    Thx in advance

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    my understanding is that u need to output fixed length string to a file. if i am correct, u can use LPAD or RPAD function to achieve the same. for eg:
    SELECT LPAD(empno, 5) || RPAD(ename, 20) FROM emp;
    the above query will output the empno padded on the left with spaces appended with ename padded on the right with spaces.
    hope this helps.
    Cheers!
    OraKid.

  3. #3
    Join Date
    Dec 2001
    Posts
    5
    According to your Example The total Record Length is 5+2

    field 1 varchar2(5) , field 2 varchar2(2)

    Set the following Settings

    SET LINE SIZE 7
    SPOOL C:\TEST.TXT
    SELECT FIELD1,FIELD 2 FROM YOURTABLE;
    SPOOL OFF

    Now check u will get the fixed length record in the file.


    All the best


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