Sqlldr flat file to external table using shell scripts
Hi,
Has anyone done this before? Please give me a hand.
Thanks!
Thanks Justin.
When do I need to create the external table EMP_STAGING ?
These are my steps so far:
- shell script to crate the flat file (but I need to change the table name to EMP_STAGING)
- use a script to call sqlldr to load the flat file into the external table
- then the script will call the MERGE sql script to merge the data from the external table into the database table
Am I on the right track?
In which stage should I create and drop the external table?
Thanks!
Similar Messages
-
Can we cleanse and transform data at flat file or external table level?
Hi,
I have some data that I want to cleanse and transform. I don't want to cleanse it after i populate the external table, I want to get done with it at flat file level or while populating the external table. Can we cleanse and transform data at flat file or external table level through Oracle or OWB 11.2? Is it possible to run a conditional load (i.e. having a where clause or if-else-then) for an external table? Can we call oracle functions for an external table at the time of creation?
Thanks in advance.
Regards,
Ann.Hi Oleg,
Thanks a lot for the clarification. :)
So is there a way that I can clease the data within the text file through Oracle or OWB? I have datatype mismatches in the data and most of my data is getting rejected because of that. The way I can think of, for solving this problem, is to create the external table with all fields with datatype varchar and then cleansing the data. But it doesn't seem very effecient plus it will get very complicated because I have almost 80-90 fields.
Any help?
Thanks and regards,
Ann. -
Map FLAT file to oracle table using 9.04 version - PLS HELP!!!!
Hello all
I am having a problem with mapping a flat file to oracle table. The validation is successful, when I go to Project/Deployment manager. Try to deploy the mapping itself and the target table. It said succesful, and the last step is another "Deploy", this one is fail. Saying could not locate the file (which is a flat file) , but it is there on the server.
I have read all the help on line and follow what they show me, but still not work
Any ideas? Please provide detail answer if you know it.
Thank in advanceHallo,
just give a rights on connector
Variant 1
1. connect to user sys
2. grant read,write on directory <connector_name> to <target_schema>;
or
Variant 2
1. as user sys or system give CREATE_ANY_DIRECTORY to <target_schema>
2. manualy make CREATE DIRECTORY <connector_name> as '<full_path_to_directory>';
and enjoy :)
PS: <connector_name> you can take from script CREATE_TABLE wisch in Generation phase was created!
Kirill -
Unable to read chinese characters in a flat file to external table
Hi All,
We have a flat file containing data in chinese. We are using external table to read data in files. When i do select <coulmn-name> from <table> it displays box for the chinese characters. The column is of type varchar2.
The NLS_LANGUAGE is AMERICAN and NLS_CHARACTERSET is AL32UTF8.
The character set is mentioed as UTF8 in external table defnition.
Is the external table not reading these charcters properly? Should any patch be installed or some settings should be changed for sql developer to to display chinese character?The NLS_LANG environment variable/registry string variable (You are just one of the 1000s of 'anonymous' users refusing to post platform and version), so NOT NLS_LANGUAGE, on the server hosting the file, should be set to anything ending in .AL32UTF8
Sybrand Bakker
Senior Oracle DBA -
hi everyone,
I have a problems :
I have created a flat file through flat file module from a text file.
i've done it successfully,
then i create an external table through external table module for the same
flat file , went successfully,
then velidation went successfull,
and i carried out deployement for the same, that also done successfully.
but when i tried to check the database through SQL-Plus :
i came across with the following error :
SQL> CONNECT TARGET_SCHEMA/TARGET_SCHEMA
Connected.
SQL> SELECT * FROM CUMMINS_EXT;
SELECT * FROM CUMMINS_EXT
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file Cumminsparts.txt in TARGET_LOC_CUMMINS_LOC not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
ORA-06512: at line 1
Please someone guide me to resolve this prob.
Thanking you,Thanks to you all,
I had created a new file location in OWB to create
a flat file module but I dont know somewhere
i missed something while creating the new file location
that is why it was not loading data inspite of deploy successed ,
but when i put the same file to one of existing file location
and i deployed it and i got the data.
now i am exploring the existing file location for what was that
i missed during creation of new location.
Guys i am new to OWB so i dont know how to go about , if you have any
easy way to get hands on OWB, please let me know
Once again thanks everybody. -
Loading from multiple flat files to same table using SQL Loader
Hi Gurus,
Can anyone please brief me the pros and cons of kicking of multiple sql loader sessions that reads multiple flat files but inserting it into just one table.
The table is not partitioned. Avg record counts for each flat file is about 5-6 million.
Oracle 11g,
OS: Linux
Regards
Cherrish VaidiyanVaidiyan wrote:
Hi Gurus,
Can anyone please brief me the pros and cons of kicking of multiple sql loader sessions that reads multiple flat files but inserting it into just one table.Cherrish,
Pros -> Faster loading of more data
Cons -> Potential performance degradation
Test to see how much resource consuming this task would be and do a priority comparison of that multi-multi load task with other stuff that will be happening in the database in the multi-multi load time so you could decide how to share resources in that time. -
Generating Text file from table using Shell script
I am using KSH for generating and FTPing a text file from a table.
While generating Text file I am not getting my Column names in orderly manner.
q2="select COLUMN1||' '||COLUMN2||' '||COLUMN3 from table1;"
set pagesize 0
set head off
set trimspool on
set trimout on
set colsep ' '
set linesize 1500
set trimspool on
spool /ss/app11/oastss/reports/$file2
select 'COLUMN1'||' '||'COLUMN2'||' '||'COLUMN3' from dual;
$q2
spool off;
EOF
I am getting the result some what like below in text file
COLUMN1 COLUMN2 COLUMN3
MALLIK_ACCT 17-SEP-11 908030482
MALLIK_ACCT 17-SEP-11 908266967
MALLIK_ACCT 17-SEP-11 909570766
I want the format like below
COLUMN1........ COLUMN2 .... COLUMN3
MALLIK_ACCT ...17-SEP-11 .... 908030482
MALLIK_ACCT ...17-SEP-11 .... 908266967
MALLIK_ACCT ...17-SEP-11 .... 909570766
I put dots(.) for illustration purpose.
column data length may icrease some times . it shoudl automatically adjust column and data so that they are in alignment. thanks in advance.Mallik wrote:
Hi my question is to format the headers so that they will be in alignment with column data and readable.So you want to output a query as a fixed width format data file? How about this (rather than using scripts)...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 2 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 12 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := v_finaltxt||rpad(nvl(v_v_val,' '),rec_tab(j).col_max_len,' ');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_n_val,'fm99999999999999999999999999999999999999'),' '),rec_tab(j).col_max_len,' ');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),' '),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.csv file contains:
empno ename job mgr hiredate sal comm deptno
7369 SMITH CLERK 7902 17/12/1980 00:00:00800 20
7499 ALLEN SALESMAN 7698 20/02/1981 00:00:001600 300 30
7521 WARD SALESMAN 7698 22/02/1981 00:00:001250 500 30
7566 JONES MANAGER 7839 02/04/1981 00:00:002975 20
7654 MARTIN SALESMAN 7698 28/09/1981 00:00:001250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 00:00:002850 30
7782 CLARK MANAGER 7839 09/06/1981 00:00:002450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:003000 20
7839 KING PRESIDENT 17/11/1981 00:00:005000 10
7844 TURNER SALESMAN 7698 08/09/1981 00:00:001500 0 30
7876 ADAMS CLERK 7788 23/05/1987 00:00:001100 20
7900 JAMES CLERK 7698 03/12/1981 00:00:00950 30
7902 FORD ANALYST 7566 03/12/1981 00:00:003000 20
7934 MILLER CLERK 7782 23/01/1982 00:00:001300 10
The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required (this is currently coded for VARCHAR2, NUMBER and DATE) -
Is the syntax correct to export tables using shell script
can you please tell me the syntax to plaxce the exp utility in shelle script.
Appreciate your help
Is the syntax correct for export.
It is throwing errors
vi test.sh
echo migrating data...
echo Exporting ADDRESS_COUNTRY_CODE ...
exp userid=scott/tiger@orcl file=address_country_code log=exp_address_country_code tables=ADDRESS_COUNTRY_CODE compress=n indexes=n constraints=n grants=n triggers=n statistics=none consistent=y query='where org_grp_i in ( 66 )' > /dev/null
echo Exporting ASSUMPTION_DETAIL_SUMMARY ...
exp userid=scott/tiger@orcl file=assumption_detail_summary log=exp_assumption_detail_summary tables=ASSUMPTION_DETAIL_SUMMARY compress=n indexes=n constraints=n grants=n triggers=n statistics=none consistent=y query='where org_grp_i in ( 66 )' > /dev/nullJust follow the notes and the example in the utilities guide
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96652/ch01.htm#1005843
exp scott/tiger TABLES=emp QUERY=\"WHERE job=\'SALESMAN\' and sal \<1600\" -
OWB - Flat file to oracle table
Second message, please read.
OS- Microsoft windows 2000 5.00.2195 Service Pack 2
OWB client---9.0.3.33.0
OWB Repository--9.0.3.0.1
Database--oracle 9i Enterprise Edition 9.0.1.3.1 with the partioning option Jserver Release9.0.1.3.0
OEM--9.0.1.0.0
I have created mapping between the source(flat file)and target(oracle)using Oracle Warehouse Builder. Mapping was validated, configured and it successfully generated without errors. The ‘Deploy’ button and the ‘Run’ button are disabled. How can I run/deploy this mapping ?
The above OWB copy was downloaded from the Oracle corp website. Is this version an evaluation copy? Alternatively Is this a beta copy ?
Please help.Dear All,
I have a problem with loading flat files to oracle tables using OWB 9.2
i created a map with my flat file as a source and my oracle table as a target,and i created a connector between the target location and the flat file location.And i deployed the connector and registered the flat file location using my PC information and the path of the files on my pc.
I generated the map and saved the .ctl file and deployed the map,and hence trying to load the ctl file using the sql loader as the following:
C:\Documents and Settings\CORAL 2000>sqlldr owb_rt_rep/owb_rt_rep@ofsa
control = D:\oracle2\ofsa\owb\codegen\BM_DEBIT_CARDS_DAT_MAP.ctl
---where owb_rt_rep is my runtime repository user.
I got the following error:
SQL*Loader-350: Syntax error at line 18.
Expecting "(", found ".".
INTO TABLE "{{TRG_LOC1.Schema}}"."BM_DEBIT_CARDS_DAT"
--where trg_loc1 is my target location and bm_debit_cards_dat is my target table.
I tried to grant from the target schema the privelages to the runtime user incase its the problem,but still it didn't work.
Any ideas??
Dina Nagia
Message was edited by:
Dina Nagia -
Flat files data comma separated using SSIS.
Hi,
I have multiple flat files which come in comma separated columns. See example below :
Customer Data
CustID,FName,LName,Disease,Email,Phone
12345,Xyz,Smit,Bronchitis, Asthma and fever,[email protected],80000000
12346,Abc,Doe,fever Headache,[email protected],90000000
12347,Klu,joe,Sugar, cough and fever,[email protected],12345678
Please look at the ID's 12345 and 12347. The disease column has a internal comma space between. How do i remove the comma spaces in the disease column, so that it can be loaded from flat file to sql table using SSIS. ?
Please help !
ThanksHere is a full solution base on my post above (first option)
1. create temp table (Give it a unique name):
create table #T (Txt NVARCHAR(MAX))
GO
2. Insert all the data into temporary table. Each line in the text file, is a value for one column in a row in the table.
-- I will jump to the table and use simple insert.
-- If you have problem with step 1 then please inform us (this is simple bulk insert basically)
insert #T (Txt) values
('1234435,Xyz,Stemit,Brfsdonchitis, Asthma and fever,[email protected],80000000'),
('12346,Agjdfjbc,Doge,fevhhhher Headsxdshhache,[email protected],90000000'),
('123447,Klu,joe,Sugar, cough and fever,[email protected],12345678')
GO
the result should be like this:
Txt
1234435,Xyz,Stemit,Brfsdonchitis, Asthma and fever,[email protected],80000000
12346,Agjdfjbc,Doge,fevhhhher Headsxdshhache,[email protected],90000000
123447,Klu,joe,Sugar, cough and fever,[email protected],12345678
I use a SPLIT Function named Split_CLR_Fn. This is a CLR Split function that get input <string to split> and <string as delimiter,> and it return table with 2 columns ID, SplitData
For example if you use: SELECT * from Split_CLR_Fn('text1,text2,text3,',') then you get result:
ID SplitData
1 Text1
2 Text2
3 Text3
** You can find in the internet several good functions, I HIGHLY RECOMMENDED NOT TO USE T-SQL FUNCTIONS but CLR FUNCTION. Check thi link to understand why:
http://sqlperformance.com/2012/07/t-sql-queries/split-strings
** This is the best function that I know about and I use it, but I change the code a bit to return 2 columns and not just the SplitData as in this blog: http://sqlblog.com/blogs/adam_machanic/archive/2009/04/28/sqlclr-string-splitting-part-2-even-faster-even-more-scalable.aspx
That's it :-) we are ready for the solution which is very simple
Solution 1 (BAD solution but easy to write):
select
(select SplitData from Split_CLR_Fn(Txt,',') where ID = 1) CustID,
(select SplitData from Split_CLR_Fn(Txt,',') where ID = 2) FName,
(select SplitData from Split_CLR_Fn(Txt,',') where ID = 3) LName,
STUFF((select ',' + SplitData from Split_CLR_Fn(Txt,',') where ID > 3 and ID < (select MAX(ID) from Split_CLR_Fn(Txt,',')) - 1 for XML path('')), 1 , 1,'') Disease,
(select SplitData from Split_CLR_Fn(Txt,',') where ID = (select MAX(ID) from Split_CLR_Fn(Txt,',')) - 1) Email,
(select SplitData from Split_CLR_Fn(Txt,',') where ID = (select MAX(ID) from Split_CLR_Fn(Txt,','))) Phone
from #T
GO
Solution 2: better in this case since the format is constant (this is the solution I wrote about above)
;With MyCTE as (
select
Txt,
SUBSTRING(Txt, 1, CHARINDEX(',', Txt, 1) - 1) as CustID
, SUBSTRING(
Txt
,CHARINDEX(',', Txt, 1) + 1 -- I start from the end of preview len
, CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)- CHARINDEX(',', Txt, 1) - 1
) as FName
, SUBSTRING(
Txt
,CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)+1 -- I start from the end of preview len
, CHARINDEX(',', Txt, CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1)+1) - CHARINDEX(',', Txt, CHARINDEX(',', Txt, 1)+1) - 1
) as LName
, RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1) as Phone
, RIGHT(LEFT(Txt, Len(Txt) - Len(RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1)) - 1), CHARINDEX(',', REVERSE(LEFT(Txt, Len(Txt) - Len(RIGHT(Txt, CHARINDEX(',', REVERSE(Txt), 1) - 1)) - 1)), 1) - 1) as Email
from #T
select CustID,FName,LName, Phone, Email, SUBSTRING(Txt, Len(CustID) + Len(FName) + Len(LName) + 4, Len(Txt) - Len(Email) - LEN(Phone) - Len(CustID) - Len(FName) - Len(LName) - 5) as Disease
from MyCTE
I hope that this is useful :-)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
How to get ORA errors in alertlog file using shell script.
Hi,
Can anyone tell me how to get all ORA errors between two particular times in an alertlog file using shell script.
ThanksHi,
You can define the alert log as an external table, and extract messages with SQL, very cool:
http://www.dba-oracle.com/t_oracle_alert_log_sql_external_tables.htm
If you want to write a shell script to scan the alert log, see here:
http://www.rampant-books.com/book_2007_1_shell_scripting.htm
#!/bin/ksh
# log monitoring script
# report all errors (and specific warnings) in the alert log
# which have occurred since the date
# and time in last_alerttime_$ORACLE_SID.txt
# parameters:
# 1) ORACLE_SID
# 2) optional alert exclusion file [default = alert_logmon.excl]
# exclude file format:
# error_number error_number
# error_number ...
# i.e. a string of numbers with the ORA- and any leading zeroes that appear
# e.g. (NB the examples are NOT normally excluded)
# ORA-07552 ORA-08006 ORA-12819
# ORA-01555 ORA-07553
BASEDIR=$(dirname $0)
if [ $# -lt 1 ]; then
echo "usage: $(basename) ORACLE_SID [exclude file]"
exit -1
fi
export ORACLE_SID=$1
if [ ! -z "$2" ]; then
EXCLFILE=$2
else
EXCLFILE=$BASEDIR/alert_logmon.excl
fi
LASTALERT=$BASEDIR/last_alerttime_$ORACLE_SID.txt
if [ ! -f $EXCLFILE ]; then
echo "alert exclusion ($EXCLFILE) file not found!"
exit -1
fi
# establish alert file location
export ORAENV_ASK=NO
export PATH=$PATH:/usr/local/bin
. oraenv
DPATH=`sqlplus -s "/ as sysdba" <<!EOF
set pages 0
set lines 160
set verify off
set feedback off
select replace(value,'?','$ORACLE_HOME')
from v\\\$parameter
where name = 'background_dump_dest';
!EOF
`
if [ ! -d "$DPATH" ]; then
echo "Script Error - bdump path found as $DPATH"
exit -1
fi
ALOG=${DPATH}/alert_${ORACLE_SID}.log
# now create awk file
cat > $BASEDIR/awkfile.awk<<!EOF
BEGIN {
# first get excluded error list
excldata="";
while (getline < "$EXCLFILE" > 0)
{ excldata=excldata " " \$0; }
print excldata
# get time of last error
if (getline < "$LASTALERT" < 1)
{ olddate = "00000000 00:00:00" }
else
{ olddate=\$0; }
errct = 0; errfound = 0;
{ if ( \$0 ~ /Sun/ || /Mon/ || /Tue/ || /Wed/ || /Thu/ || /Fri/ || /Sat/ )
{ if (dtconv(\$3, \$2, \$5, \$4) <= olddate)
{ # get next record from file
next; # get next record from file
# here we are now processing errors
OLDLINE=\$0; # store date, possibly of error, or else to be discarded
while (getline > 0)
{ if (\$0 ~ /Sun/ || /Mon/ || /Tue/ || /Wed/ || /Thu/ || /Fri/ || /Sat/ )
{ if (errfound > 0)
{ printf ("%s<BR>",OLDLINE); }
OLDLINE = \$0; # no error, clear and start again
errfound = 0;
# save the date for next run
olddate = dtconv(\$3, \$2, \$5, \$4);
continue;
OLDLINE = sprintf("%s<BR>%s",OLDLINE,\$0);
if ( \$0 ~ /ORA-/ || /[Ff]uzzy/ )
{ # extract the error
errloc=index(\$0,"ORA-")
if (errloc > 0)
{ oraerr=substr(\$0,errloc);
if (index(oraerr,":") < 1)
{ oraloc2=index(oraerr," ") }
else
{ oraloc2=index(oraerr,":") }
oraloc2=oraloc2-1;
oraerr=substr(oraerr,1,oraloc2);
if (index(excldata,oraerr) < 1)
{ errfound = errfound +1; }
else # treat fuzzy as errors
{ errfound = errfound +1; }
END {
if (errfound > 0)
{ printf ("%s<BR>",OLDLINE); }
print olddate > "$LASTALERT";
function dtconv (dd, mon, yyyy, tim, sortdate) {
mth=index("JanFebMarAprMayJunJulAugSepOctNovDec",mon);
if (mth < 1)
{ return "00000000 00:00:00" };
# now get month number - make to complete multiple of three and divide
mth=(mth+2)/3;
sortdate=sprintf("%04d%02d%02d %s",yyyy,mth,dd,tim);
return sortdate;
!EOF
ERRMESS=$(nawk -f $BASEDIR/awkfile.awk $ALOG)
ERRCT=$(echo $ERRMESS|awk 'BEGIN {RS="<BR>"} END {print NR}')
rm $LASTALERT
if [ $ERRCT -gt 1 ]; then
echo "$ERRCT Errors Found \n"
echo "$ERRMESS"|nawk 'BEGIN {FS="<BR>"}{for (i=1;NF>=i;i++) {print $i}}'
exit 2
fi -
Conversion of fixed length flat files to oracle table
hello friends
Please help me getting the code for conversion of fixed length flat files to oracle table
Should the tables be pre-defined ?????
In this case the de-limiters are variable length spaces and not commas.Please help me with the same
Regards,
-MaheshYou can use SQL*Loader to load fixed-width files into Oracle. Instructions on writing appropriate control files are in the Oracle Utilities manual
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch03.htm#1004687
You can also use external tables, assuming you're using 9i or later (the syntax for external table definitions is nearly identical to the syntax for SQL*Loader control files).
You'll need to create a table definition in Oracle. You can either create a "normal" table and use SQL*Loader to populate it or you can create an external table definition.
Justin -
Flat file to target table map in 11G
Hi,
I am havin many problem with my 10G R1 map that have been migrated to 11G.
all that my 10G map has is mapping from flat file to stage table. It also had one constant operator. i am getting error coz of this constant that i am setting up in the map.
when i validate this constant variable i get error mess:
API8534:Validation no supported for language SQLLOADER,property Expression for SAASD_MAP
-- Generator Version : 11.1.0.7.0
-- Created Date : Mon May 11 21:16:25 CDT 2009
-- Modified Date : Mon May 11 21:16:25 CDT 2009
-- Created By : OWB_WUSER
-- Modified By : OWB_WUSER
-- Generated Object Type : SQL*Loader Control File
-- Generated Object Name : "SADAD_MAP"
-- Copyright © 2000, 2007, Oracle. All rights reserved.
OPTIONS (BINDSIZE=50000,ERRORS=50,ROWS=200,READSIZE=65536)
LOAD DATA
CHARACTERSET WE8MSWIN1252
INFILE '{{ETL_FILE_LOC.RootPath}}{{}}dgp.dat'
BADFILE '{{ETL_FILE_LOC.RootPath}}{{}}dgp.bad'
DISCARDFILE '{{ETL_FILE_LOC.RootPath}}{{}}dgp.dis'
CONCATENATE 1
INTO TABLE "STAGING"."DGP_STAGG"
APPEND
REENABLE DISABLED_CONSTRAINTS
WHEN (1:2) = 'EM'
"PHONE_COUNTRY" CONSTANT ''Asia'',
"MRI" POSITION(1:2) CHAR(2) ,
if you note 11G some how does not allow me to have constant operator in flat file maps. and the constant for PHONE_COUNTRY column is enclosed in double quotes insted of single quotes.[should be 'Asia' and not ''Asia'']
can any one tell me why this is heppening?...i also have problem with the READ BUFFER property. which in 10G used to be defulted to '4' but ignored which generating the .ctl but in 11G this property creates READ BUFFERS statement in .ctl....any help in this will be grt.
Edited by: user591315 on May 12, 2009 7:39 AMif you note 11G some how does not allow me to have constant operator in flat file maps. and the constant for >PHONE_COUNTRY column is enclosed in double quotes insted of single quotes.Hi
Please open the same mapping in 10g R2 its same .
It use Double code around the column name.
By the way execute the mapping and then check are you getting desired result. -
How to write CLOB parameter in a file or XML using shell script?
I executed a oracle stored procedure using shell script. How can i get the OUT parameter of the procedure(CLOB) and write it in a file or XML in UNIX environment using shell script?
Edit/Delete MessageSQL> var c clob
SQL>
SQL> begin
2 select
3 DBMS_XMLGEN.getXML(
4 'select rownum, object_type, object_name from user_objects where rownum <= 5'
5 ) into :c
6 from dual;
7 end;
8 /
PL/SQL procedure successfully completed.
SQL>
SQL> set long 999999
SQL> set heading off
SQL> set pages 0
SQL> set feedback off
SQL> set termout off
SQL> set trimspool on
// following in the script is not echo'ed to screen
set echo off
spool /tmp/x.xml
select :c from dual;
spool off
SQL>
SQL> --// file size
SQL> !ls -l /tmp/x.xml
-rw-rw-r-- 1 billy billy 583 2011-12-22 13:35 /tmp/x.xml
SQL> --// file content
SQL> !cat /tmp/x.xml
<?xml version="1.0"?>
<ROWSET>
<ROW>
<ROWNUM>1</ROWNUM>
<OBJECT_TYPE>TABLE</OBJECT_TYPE>
<OBJECT_NAME>BONUS</OBJECT_NAME>
</ROW>
<ROW>
<ROWNUM>2</ROWNUM>
<OBJECT_TYPE>PROCEDURE</OBJECT_TYPE>
<OBJECT_NAME>CLOSEREFCURSOR</OBJECT_NAME>
</ROW>
<ROW>
<ROWNUM>3</ROWNUM>
<OBJECT_TYPE>TABLE</OBJECT_TYPE>
<OBJECT_NAME>DEPT</OBJECT_NAME>
</ROW>
<ROW>
<ROWNUM>4</ROWNUM>
<OBJECT_TYPE>TABLE</OBJECT_TYPE>
<OBJECT_NAME>EMP</OBJECT_NAME>
</ROW>
<ROW>
<ROWNUM>5</ROWNUM>
<OBJECT_TYPE>TABLE</OBJECT_TYPE>
<OBJECT_NAME>EMPTAB</OBJECT_NAME>
</ROW>
</ROWSET>
SQL> -
How to overwrite a log and bad file in external table in oracle 10g
Hi,
I have used external table in oracle 10g.whenever use select query in external table orace internally create one log file in specified directory,
but this log file is growing.How can i overwrite the log file(old to replace with new).I need overwrite a log and bad file in external table.
kindly give the solutions.
By
SivaI don't believe that is possible with the LOGFILE clause, but it may be with the BADFILE clause. Here is an excerpt from the documentation :
The LOGFILE clause names the file that contains messages generated by the external tables utility while it was accessing data in the datafile. If a log file already exists by the same name, the access driver reopens that log file and appends new log information to the end. This is different from bad files and discard files, which overwrite any existing file. NOLOGFILE is used to prevent creation of a log file.
If you specify LOGFILE, you must specify a filename or you will receive an error.
If neither LOGFILE nor NOLOGFILE is specified, the default is to create a log file. The name of the file will be the table name followed by _%p and it will have an extension of .log.
Maybe you are looking for
-
BAPI_PO_CHANGE Sub-contracting PO
Hello experts, we are using BAPI_PO_CHANGE to change the Item Category of a material in a purchase order to L (sub-contracting) when we do we receive the error message in the BAPI u201CNot possible to determine any componentsu201D due to the fact the
-
Hi everyone. I am trying to run a rather large script to configure a database for testing. I cannot get this script to run in SQLDeveloper though. When I attempt to run the script I get the following errors: line 1: SQLPLUS Command Skipped: set serve
-
How do I interact with a loaded swf?
Hi, I have a "lesson" that I'm building that will display a series of "pages" based on an XML file. I have simple navigation buttons that work to page through the XML file. but I'd like to use load an external SWF file with buttons to use as my navig
-
My phone keeps saying "No Service", why?
I just got it today and did all i need to do. Since I'm using my old sim, i apparently had to call my carrier and tell them my IMEI # and stuff. I just did a while ago, told them the correct IMEI #, and they said they activated it or something. But t
-
Getting error message with javah -jni
Hi, I am trying to generate .h file using javah -jni command. I am executing the prompt>javah -jni C:\proj\HelloWorld But it's giving the error Error: Class HelloWorld could not be found. But the class file is there in that folder. Could you please t