FLAT script
A reader, April 15, 2002 - 11:40 am UTC
Tom, I just bought your new book BEGINGING ORACLE Programming
Great book, simple and lucid.
Iam trying to use the flat.sql script. It outputs the contents of a table to the screen. But I want it to spool it to a file.
Can you suggest the changes.
April 16, 2002 - 7:27 am UTC
redirection. It works on all platforms.
FLAT was written to be run from the command line using redirection:
flat scott/tiger EMP > emp.dat
A reader, April 15, 2002 - 11:53 am UTC
Tom, I fixed the above request I had put in the above comment.
Instead what Iwant to know is
in the below two queries what do the below conditions imply, why are they there
1.column_id != (select max(column_id)
from user_tab_columns
where table_name = upper('&1'))
2.column_id = (select max(column_id)
from user_tab_columns
where table_name = upper('&1'))
select lower (column_name)||'||chr(44)||'
from user_tab_columns
where table_name = upper('&1')
and column_id != (select max(column_id)
from user_tab_columns
where table_name = upper('&1'))
/
select lower(column_name)
from user_tab_columns
where table_name = upper('&1')
and column_id = (select max(column_id)
from user_tab_columns
where table_name = upper('&1'))
/
thank you
April 16, 2002 - 7:31 am UTC
Just getting the commas right. Wanted all but the last column -- then wanted the last column.
Yes, there are 50 other ways to implement this query...
Very good script, but...
Tom, April 15, 2002 - 4:57 pm UTC
Tom,
I've tried to run the sqlldr_exp script, but I kept on getting the following error:
$sqlldr_exp username/password@DB EMPLOYEE
LOAD DATA
INFILE *
INTO TABLE eai_lookup
REPLACE
FIELDS TERMINATED BY '|'
(
)
BEGINDATA
from EMPLOYEE
*
ERROR at line 2:
ORA-00936: missing expression
Does anyone have the same problem? Please help.
Thanks,
Tom
April 16, 2002 - 7:38 am UTC
sqlldr_exp just writes sql to /tmp/
modify the script to NOT erase the generated script, check out the SQL and see whats wrong with it.
Thank you, but I think it would have pay attention column order.
OMATA Ken-ichi, April 24, 2002 - 9:36 am UTC
Very very useful. thank you Tom.
But I have looked following case.
...
FIELDS TERMINATED BY '|'
(
,ename
empno
,job
...
So, I think It would be append "order by column_id" phrase.
...
select 'prompt ' || decode(column_id,1,'',',') ||
lower(column_name ) ||
decode(data_type, 'DATE',
' date ''DD-MON-YYYY HH24:MI:SS''', null )
from user_tab_columns
where table_name = upper('$X')
order by column_id << here
/
...
select lower(column_name)||'||chr(124)||'
from user_tab_columns
where table_name = upper('$X') and
column_id != (select max(column_id)
from user_tab_columns where
table_name = upper('$X'))
order by column_id << here
/
...
Tom, it is useful
Ramesh, July 17, 2002 - 6:33 pm UTC
Hey Tom,
I would like to know how to select few columns from the flat file.
There are 9 fields in the following dat file.
123|TEST|1200|12/12/2001|30000|4000|Testing|Valid|Request
Just I want to insert only 4 fields ( f1, f3, f6, f9)
Can you please reply.
Thanks in advance for your kind reply.
RM
July 18, 2002 - 8:20 am UTC
FLAT script
Balvinder Gill, July 15, 2005 - 10:53 am UTC
Tom,
This is a great script! I've been searching for most of the day for this.
Cheers,
Bal
Great
A reader, August 04, 2010 - 4:12 am UTC
How to put a condition on a data in this script like
1)We need to select rows only between 2006 and 2009
2)We need all TEXT data to appear in " "