Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > reading from csv file and use the data in stored procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-08, 01:42
tiger66 tiger66 is offline
Registered User
 
Join Date: Dec 2007
Posts: 24
reading from csv file and use the data in stored procedure

Hi All
I am trying to accomplish the following tasks

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.

Can someone give me some example/advice on how to go about solving this problem?

Thanks in advance for your help
Reply With Quote
  #2 (permalink)  
Old 01-06-08, 11:40
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 371
You are better off googling for such stuff or look at existing programs. Theres a wealth of info on scripting.

Anyways... something to start with for you. Hope it helps.

for myvar in `cat my.txt` | cut -f1 -d','`
do
finallist=`echo $finallist','$myvar
done

#The above will take all the first fields in the csv related file and concatenate it to finallist.

isql -U...... << EOF
exec myproc $finallist
go
EOF
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On