1. This will insert the records into db table by reading from ta csv file


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers 1. This will insert the records into db table by reading from ta csv file
# 1  
Old 03-19-2019
1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected.

Code:
LOAD DATA
  infile   '  '     #specifies the name of a datafile containing data that you want to load
  BADFILE ' '                              #specifies the name of a file into which rejected records are placed
  BADFILE ' '                              #specifies the name of a file into which discarded records are placed
  APPEND      #to insert data in a nonempty table
  INSERT      #to enter the data into an empty table
  INTO TABLE ts_item_loc_stage_data
  FIELDS TERMINATED BY "|" optionally enclosed by '"'
  TRAILING NULLCOLS 
  (
   Seq_no                    NUMBER(10 ),
   Item                      CHAR(25),
   Loc         			     NUMBER(10),
   Mail_id   		         CHAR(100),
   Status    		         CHAR(1),
   Error_message			 CHAR(255),
   Mail_ind			         CHAR(1)
  );

--- Post updated at 08:01 AM ---

can anyone help me with the query
Moderator's Comments:
Mod Comment Please DO NOT ask updates on posts, bumping up posts is NOT allowed. Kindly go through rules for forums once too.

Last edited by RavinderSingh13; 03-19-2019 at 05:10 AM..
# 2  
Old 03-21-2019
Hello raka123,

I have a few to questions pose in response first:-
  • What variations have you tried so far and what output do you get?
  • What database and version are you trying to load into? Oracle, Informix, DB2, MySQL/MariaDB?
  • What OS and version are you using?
  • Have you read the syntax pages for your database?

There may be an IGNORE, REPLACE or REPORT type option, but these depend on the database you are trying to load to.

We're all here to learn and getting the relevant information will help us all.


Kind regards,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Intelligent Script to Insert Records in Database Table

Hello All Members, I am new to this forum and to the shell scripting. I want to write a shell script to do the following: Scenario: I have a pipe delimited .txt file with multiple fields in it. The very first row of the file contains the name of the column which resembles the name of the... (18 Replies)
Discussion started by: chetanojha
18 Replies

2. Shell Programming and Scripting

Reading from a CSV and writing in same CSV file

Hi, I am tryng to read from a csv file and based on some grep command output I will modify one of the column in the same csv. Example:- Input CSV:- 20120829001415,noneAA,google.com 20120829001415,dfsafds,google.com 20120829001415,noneAA,google.com Intermediate Step:- If 2nd column of... (3 Replies)
Discussion started by: kmajumder
3 Replies

3. Web Development

INSERT data to a Database Table from a text file

If you have a text file and if you want to Insert data to your Database Table, You can do it with these queries LOAD DATA LOCAL INFILE '/path/yourTextFile.txt' INTO TABLE yourTableName FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (0 Replies)
Discussion started by: sitex
0 Replies

4. 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

5. UNIX for Advanced & Expert Users

Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise. Example: File1: 1|AAA|25|2 5|qqe|20|7 4|wer|31|81 I need to create a second file in which data can be inserted in a columnwise manner i.e. File2: AAA|25|1|2 qqe|20|5|7 wer|31|4|81 The order of columns in... (1 Reply)
Discussion started by: abhijeet1409
1 Replies

6. Shell Programming and Scripting

Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise. Example: File1: 1|AAA|25|2 5|qqe|20|7 4|wer|31|81 I need to create a second file in which data can be inserted in a columnwise manner i.e. File2: AAA|25|1|2 qqe|20|5|7 wer|31|4|81 The order of columns in... (1 Reply)
Discussion started by: abhijeet1409
1 Replies

7. Shell Programming and Scripting

How do I load records from table to a flat file!

Hi All, I need to load records from oracle table XYZ to a flat file say ABC.dat. could any one tell me how do i do this in UNXI, Regards Ann (1 Reply)
Discussion started by: Haque123
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. Shell Programming and Scripting

reading specifiec records from a file!!

I want to read all numeric records that start with the line id and write them to a new file. input: ==== blah blah blah blah id 10 11 12 13 14 15 blah blah blah blah id 16 17 18 19 20 21 output: 10 11 12 13 14 15 (10 Replies)
Discussion started by: andy2000
10 Replies

10. Shell Programming and Scripting

Inserting records from flat file to db table

I have 20000 numbers present in a file in each line like 25663, 65465, 74579, 56446, .. .. I have created a table in db with single number column in it. create table testhari (no number(9)); I want to insert all these numbers into that table. how can i do it? can anybody please... (4 Replies)
Discussion started by: Hara
4 Replies
Login or Register to Ask a Question