Insert value to ORACLE table from sqlldr log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert value to ORACLE table from sqlldr log
# 8  
Old 02-19-2009
Very simple. Use the below code at the beginning of the script.

Code:
curfile=${0##*/}

HTH, Smilie

Regards,

Praveen
# 9  
Old 02-19-2009
Hammer & Screwdriver

Quote:
Originally Posted by sunpraveen
Very simple. Use the below code at the beginning of the script.

Code:
curfile=${0##*/}

HTH, Smilie

Regards,

Praveen
Wow!! Thank you very much.. Image Image


But would you mind to explain me what does the code actually?

Coz by 1st look, it seems not so meaningful.. ehehe..
# 10  
Old 02-19-2009
Whenever shell scripts are run, "$0" will always be the name of that shell script.

Generally, shell scripts are run by using the ./ prefix. If you use this, then $0 will also show ./. In order to remove this, ##*/ is used.

HTH, Smilie

Regards,

Praveen
# 11  
Old 03-02-2009
Power

Quote:
Originally Posted by sunpraveen
Whenever shell scripts are run, "$0" will always be the name of that shell script.

Generally, shell scripts are run by using the ./ prefix. If you use this, then $0 will also show ./. In order to remove this, ##*/ is used.

HTH, Smilie

Regards,

Praveen
Thank you very much.. Image
# 12  
Old 03-02-2009
I want to extend my question..

I have this variable set

Code:
errors="$(awk '/^ORA-/ {print}' pbsb.cv004.cr260.charnge.log|sort -d|uniq)"

which will produce this as the output:
Code:
ORA-00001: unique constraint (CRISPADM.PK_CHARNGE) violated
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")


The logfile is something like this:
Code:
TOTAL_CHANNEL_STUMP_CTR             69:73     5           CHARACTER
START_LEN_NUM                       74:82     9           CHARACTER
END_LEN_NUM                         83:91     9           CHARACTER

Record 3484: Rejected - Error on table CRISPADM.CHARNGE.
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Record 3485: Rejected - Error on table CRISPADM.CHARNGE.
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Record 4719: Rejected - Error on table CRISPADM.CHARNGE.
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Record 4720: Rejected - Error on table CRISPADM.CHARNGE.
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Record 4721: Rejected - Error on table CRISPADM.CHARNGE.
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Record 4722: Rejected - Error on table CRISPADM.CHARNGE.

My question is that how do I output those
Code:
ORA-00001: unique constraint (CRISPADM.PK_CHARNGE) violated
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

into a single line separated by comma i.e.

Code:
ORA-00001: unique constraint (CRISPADM.PK_CHARNGE) violated, ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID")

Can I?

Thanks for helping.. Image
# 13  
Old 03-02-2009
Code:
errors="$(awk '/^ORA-/ {print}' pbsb.cv004.cr260.charnge.log|sort -d|uniq | sed 's/$/,/')"

# 14  
Old 03-02-2009
Bug

Quote:
Originally Posted by vgersh99
Code:
errors="$(awk '/^ORA-/ {print}' pbsb.cv004.cr260.charnge.log|sort -d|uniq | sed 's/$/,/')"

Thank you very much.. Image Image

But could you please tell me what's the difference between this two:
Code:
awk '/^ORA-/ {print}' pbsb.cv004.cr260.charnge.log|sort -d|uniq | sed 's/$/,/'

would output
Code:
ORA-00001: unique constraint (CRISPADM.PK_CHARNGE) violated,
ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID"),

But if i do this:
Code:
errors="$(awk '/^ORA-/ {print}' pbsb.cv004.cr260.charnge.log|sort -d|uniq | sed 's/$/,/')"

and then issuing
Code:
echo $errors

would display it in one line as desired
Code:
ORA-00001: unique constraint (CRISPADM.PK_CHARNGE) violated, ORA-01400: cannot insert NULL into ("CRISPADM"."CHARNGE"."CODE_SYS_ID"),

And also, is there anyway to trim the last trailing commas in the end? Smilie

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to create the SQLLDR control file from Oracle table.

I need to create the shell script load the few 100 table using the SQLLDR. Need to generate the control file for each table using oracle table. table has "table names" and "column names" using this need create the control file. example table rows below table_nme column_nme DEPT ... (2 Replies)
Discussion started by: pimmit22043
2 Replies

2. UNIX and Linux Applications

Help in copying table structure to another table with constraints in Oracle

hi, i need to copy one table with data into another table, right now am using create table table1 as select * from table2 i want the constraints of table1 to be copied to table2 also , can anyone give me some solution to copy the constraints also, now am using oracle 10.2.0.3.0... (1 Reply)
Discussion started by: senkerth
1 Replies

3. Shell Programming and Scripting

Insert script result into Oracle Table

Hi All, I want to insert STAT and ENDTIME values for each job in joblist into TBL_DAILY_STATUS table. Eg: insert into tbl_daily_status values(STAT,ENDTIME); Please help me on this. #!/bin/ksh joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det" for i in $joblist do... (8 Replies)
Discussion started by: vichuelaa
8 Replies

4. Shell Programming and Scripting

Insert into Oracle table thru UNIX - linux 2.6.9-89

Hi, I am trying to insert a record into a table (say dips_tbl) which resides in Oracle DB through a ksh script. I want to insert records into few of the table columns-not all. I'll give an e.g. for the date column "CREATE_DATE". For that I first execute SQL1="SELECT SYSDATE FROM DUAL" ... (1 Reply)
Discussion started by: dips_ag
1 Replies

5. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

6. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time then Go to sleep mode and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies

7. Shell Programming and Scripting

Check the record count in table (table in oracle)

I have requirement: 1) Check the record count in table (table in oracle) 2) If records exists generate the file for existing records and wait for some time (Go to sleep mode) and Again check the record count after 10 min.......... (Loop this process if record count >0). 3) Generate touch... (1 Reply)
Discussion started by: kamineni
1 Replies

8. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

9. Programming

How can i load or insert a table in oracle from c language thru unix environment

I'm having a oracle server and i'm having a table in that. I'm having a linux server which is in network with the oracle server. I need to write a c program in linux env when on execution loads the table with the text file given as input. Please explain me the flow of process in that and also... (6 Replies)
Discussion started by: rramprasad
6 Replies
Login or Register to Ask a Question