Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK and SQL DB Informix Lookup

Status
Not open for further replies.

taylor5pak

Programmer
Oct 9, 2001
23
0
0
US
Hello, is it possible to do a database lookup within an awk script to verify a value exist and then if so insert values from the record being read into the database?

Ex. I have a huge file and in it contains an invoice data, first I want to see if the invoice already exists in the database, if it does I am going to write these records out to a file, If not I am going to write these records out to another file.. I am going to then process all records that were not in the database and at this point I would like to make another call to the database and insert...
 
And what have you so far ?
You may consider to build some sql scripts on the fly launched by dbaccess.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Please diregard we have decided not to go this route...
But for future reference, I gave you the details.. All I needed was where to place the call to dbaccess.. It is very time consuming to write the details...

awk '
if ($1 == value)
call to db to verify
evaluate value if is found
writes to file a else writes to file b..

I would then just pipe out file b to the next awk script

awk '
populate variables
call to db to insert new values
'
 
Hi PH

Please excuse the quick answers.. My appologies to you as you still are the man (my appologies I do not know if you are male or female), and I am just plain old rude.. I was being hounded to get an answer to my problem asap and was very angered by it... I know this is feasible but needed to verify if certain thing could happen within the awk itself and that is why I was trying to be short and sweet about it...

Again my appologies to you and I hope you have a wonderful day!
 
Most of things can be done from within awk with the system and/or getline builtin functions.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top