The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to read the data from an excel sheet and use those data as variable in the unix c Anne Grace UNIX for Advanced & Expert Users 1 03-03-2008 04:21 AM
Reading and Writing from Excel using Unix scripting AshishK UNIX and Linux Applications 3 11-08-2007 11:49 PM
script for reading BLOB data shriashishpatil Shell Programming and Scripting 0 04-25-2007 04:11 PM
Need help with complicated script (reading directories, extracting data) Gill Bates Shell Programming and Scripting 3 02-20-2007 04:05 PM
How to launch a Csh shell script using Excel Macro ? Raynon Shell Programming and Scripting 1 11-08-2006 09:22 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 01-05-2008
Registered User
 

Join Date: Nov 2005
Posts: 22
Hi porter
Should I be storing the data from csv file in a variable?

I use sybase

Thanks
Reply With Quote
Forum Sponsor
  #9  
Old 01-05-2008
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by tiger99 View Post
Should I be storing the data from csv file in a variable?
I thought you would be reading the data from the separate columns then generating the "insert" SQL statements.
Reply With Quote
  #10  
Old 01-05-2008
Registered User
 

Join Date: Dec 2005
Location: Madison, WI
Posts: 6
IMHO, If your goal is to select the first column out of your csv/xls file, and then use it in a stored procedure, I would suggest that you use awk to extract out the first column into a flat file, load that file into a temp table and then reference the temp table from your stored procedure.

Not sure how many rows you will have in thie csv/xls file, but the more rows you will have, the tricky it will be to pass it into the stored procedure. Look for a more robust solution.
Reply With Quote
  #11  
Old 01-05-2008
Registered User
 

Join Date: Nov 2005
Posts: 22
Hi porter

sorry, I would not be doing any "insert" SQL statement.

I need to
1. use shell script to read the first column of data in csv file
2. pass the data to a sybase stored procedure using shell script
3. in the stored procedure, I would have a "select" SQL statement (i.e select * from db where id in (1234,2345,....))

1234,2345... are data from the first column of the csv file.

I hope I make my question clear

Thanks
Reply With Quote
  #12  
Old 01-05-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
this is one way how you get your first column data
Code:
# cut -f1 -d"," < csvfile | paste -sd","
1234,2345,3345
you just have to assign the select statement to a variable using the above method
Code:
cmd="select * from table where id in ( `the above command` )"
isql -uUser -Sserver <options> << EOF
 exec procedure $cmd
EOF
Since you are beginner to shell, you can read up some tutorial first. see here for some tutorials
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0