Loading text file into table


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Loading text file into table
# 15  
Old 02-23-2014
Hi Ahamed,

I am giving auto commit like below

Code:
while read filename
do
awk '/ n /{print "insert into lastlogon values(" q$1q, q$3q, q$4q, $5, q$6q ");"
}' q=\' OFS=", " userreport.txt
SET AUTOCOMMIT ON;
done<userreport.txt

but getting below error when I compile

Code:
insert into lastlogon values(se3aa', 'Wed', 'Jun', 30, '2010');
insert into lastlogon values('34s34', 'Tue', 'Mar', 15, '2011');
insert into lastlogon values('34saw', 'Mon', 'Feb', 3, '2014');
+ SET AUTOCOMMIT ON
loaddata1.ksh[14]: SET:  not found
+ read filename

# 16  
Old 02-23-2014
You need to echo it out...
Code:
...
echo "SET AUTOCOMMIT ON;"
...

I assume after running the script, you feed the output into the DB.
If that doesn't work, I am not an sql expert, but why dont you try one record at a time with normal commit?

--ahamed

---------- Post updated at 07:11 PM ---------- Previous update was at 07:09 PM ----------

Just noticed, why are you using the while loop on the same file again? The awk alone is enough to get you the insert statements from userreport.txt!

--ahamed

---------- Post updated at 07:13 PM ---------- Previous update was at 07:11 PM ----------

Also, not sure if its a typo, but you are missing a single quote in the first data of the first record.

--ahamed
# 17  
Old 02-24-2014
Also,
  • What Ingres command line utility are you using to feed the data into the Ingres database?
  • Could you post that command here, exactly like you are using it?
  • How do you feed your awk output into that command? With a file, a pipe, a here document?

Last edited by Scrutinizer; 02-24-2014 at 02:32 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make a table from a text file

Hi, I have a pipe separated text file. Can some someone tell me how to convert it to a table? Text File contents. |Activities|Status1|Status2|Status3| ||NA|$io_running2|$io_running3| |Replication Status|NA|$running2|$running3| ||NA|$master2|$master3|... (1 Reply)
Discussion started by: rocky88
1 Replies

2. Shell Programming and Scripting

Bash shell script that inserts a text data file into an HTML table

hi , i need to create a bash shell script that insert a text data file into an html made table, this table output has to mailed.I am new to shell scripting and have a very minimum idea of shell scripting. please help. (9 Replies)
Discussion started by: intern123
9 Replies

3. Shell Programming and Scripting

Help in script - Getting table name from a text file

hhhhhhhhhh (5 Replies)
Discussion started by: sams
5 Replies

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

5. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

6. Shell Programming and Scripting

loading the data to the partitioned table using procedure

Hi one help, I need one procedure to load data from flat file to table. Table name as input parameter for the procedure. can anyone help me Thanks, Raj, (1 Reply)
Discussion started by: easterraj
1 Replies

7. Shell Programming and Scripting

how can I bcp out a table into a text file including the header row in the text file

Hi All, I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers. I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err Regards,... (0 Replies)
Discussion started by: shilpa_acc
0 Replies

8. Shell Programming and Scripting

shellscript.query Oracle table..populate in a text file

Hi Guys, I'm new to this forum as well as to UNIX shell scripting. I'm looking for a shellscript to query an Oracle database table and populate the result set of the query in a text file. Could you someone help me out with a sample code? Thanks, Bhagat (7 Replies)
Discussion started by: bhagat.singh-j
7 Replies

9. Shell Programming and Scripting

load a data from text file into a oracle table

Hi all, I have a data like, 0,R001,2,D this wants to be loaded into a oracle database table. Pl let me know how this has to be done. Thanks in advance (2 Replies)
Discussion started by: raji35
2 Replies

10. Shell Programming and Scripting

shell script to read data from text file and to load it into a table in TOAD

Hi....can you guys help me out in this script?? Below is a portion text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (1 Reply)
Discussion started by: pallavishetty
1 Replies
Login or Register to Ask a Question