![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I'm hitting the old problem that I need to spool data into a text file, but SQL*Plus insists on padding the fields to the length of the column definition. |
#3
| |||
| |||
|
|
I'm hitting the old problem that I need to spool data into a text file, but SQL*Plus insists on padding the fields to the length of the column definition. There is a way which I've used to make the dbms_metadata.get_ddl package spool out a decent usable (as DDL SQL) piece of code, this might help you. Look for the put_line PL./SQL procedure which has a "compress" 2nd argument to squeeze out the irritating space-to-EOL chars. I got this from http://adp-gmbh.ch/ora/misc/oru_10028.html It's all clean readable code. You can modify this package, then select your stuff into a varchar2, then put_line(that varchar2, boolean) where boolean is TRUE for that "compression", which you can readily fix to your taste. Does require some PL/SQLing but that's Just Another Language really :-) |
#4
| |||
| |||
|
|
What I'm basically doing is: snip spool output.txt SELECT column1,column2, column3 FROM my_table; spool off Is there any way to remove the trailing spaces in the column values? |
#5
| |||
| |||
|
|
spool output.txt SELECT column1,column2, column3 FROM my_table; spool off Is there any way to remove the trailing spaces in the column values? cheap and ugly select trim(column1),trim(column2) .... |
#6
| |||
| |||
|
|
Hello, I'm hitting the old problem that I need to spool data into a text file, but SQL*Plus insists on padding the fields to the length of the column definition. The problem is that I cannot concatenate the columns as I get an "ORA-01489: result of string concatenation is too long" when doing so. What I want is a file that has the following format value1|value2|value3 but what I get is: value1 |value2 |value3 The columns are all VARCHAR2(2000) What I'm basically doing is: set term off set echo off set feedback off set heading off set define off set timing off set linesize 32767 set pagesize 0 set colsep '|' set newpage none set trimspool on spool output.txt SELECT column1,column2, column3 FROM my_table; spool off Is there any way to remove the trailing spaces in the column values? I'm using Oracle 8.1.7.4.0 on HP/UX Any input is greatly appreciated!! Cheers Thomas |
#7
| |||
| |||
|
|
SELECT column1||'|'||column2 etc... Get rid of SET COLSEP |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
Alan wrote on 08.12.2004 20:22: SELECT column1||'|'||column2 etc... Get rid of SET COLSEP As I have already pointed out in my original post: I get the following error when doing so: "ORA-01489: result of string concatenation is too long" Thanks Thomas |
#10
| |||
| |||
|
|
Alan wrote on 08.12.2004 20:22: SELECT column1||'|'||column2 etc... Get rid of SET COLSEP As I have already pointed out in my original post: I get the following error when doing so: "ORA-01489: result of string concatenation is too long" Thanks Thomas |
![]() |
| Thread Tools | |
| Display Modes | |
| |