Sponsored Content
Top Forums Shell Programming and Scripting Execute stored procedure through script in sybase database and store the output in a .csv file Post 302435535 by fpmurphy on Wednesday 7th of July 2010 03:15:30 PM
Old 07-07-2010
Sybase does not have build-in support for outputting queries in CSV format. BCP has support for CSV but you probably do not want to down that route.

Here is one way of outputting the result of your query in CSV format. I will use the Sybase pubs2 example as the database. (the pubs2 example comes with all versions of Sybase).

Here is the contents of my shell script
Code:
isql -Uname -Ppassword -Sserver -Dpubs2 -b -h -w200  <<EOF | sed -e 's/ //g'
select '"',au_id,'","',au_fname,'","',au_lname,'","',phone,'"' from authors
go
EOF

Here is the output generated by the shell script
Code:
"172-32-1176","Johnson","White","408496-7223"
"213-46-8915","Marjorie","Green","415986-7020"
"238-95-7766","Cheryl","Carson","415548-7723"
"267-41-2394","Michael","O'Leary","408286-2428"
"274-80-9391","Dick","Straight","415834-2919"
"341-22-1782","Meander","Smith","913843-0462"
"409-56-7008","Abraham","Bennet","415658-9932"
"427-17-2319","Ann","Dull","415836-7128"
"472-27-2349","Burt","Gringlesby","707938-6445"
"486-29-1786","Chastity","Locksley","415585-4620"
"527-72-3246","Morningstar","Greene","615297-2723"
"648-92-1872","Reginald","Blotchet-Halls","503745-6402"
"672-71-3249","Akiko","Yokomoto","415935-4228"
"712-45-1867","Innes","delCastillo","615996-8275"
"722-51-5454","Michel","DeFrance","219547-9982"
"724-08-9931","Dirk","Stringer","415843-2991"
"724-80-9391","Stearns","MacFeather","415354-7128"
"756-30-7391","Livia","Karsen","415534-9219"
"807-91-6654","Sylvia","Panteley","301946-8853"
"846-92-7186","Sheryl","Hunter","415836-7128"
"893-72-1158","Heather","McBadden","707448-4982"
"899-46-2035","Anne","Ringer","801826-0752"
"998-72-3567","Albert","Ringer","801826-0752"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute an Oracle stored procedure from a shell scrip

Here is a snippet of my code: if then echo "\n Deleting all reports older than 24 hours. \n" >> $logfile ls -l $FileName >> $logfile ... (1 Reply)
Discussion started by: mh53j_fe
1 Replies

2. UNIX for Dummies Questions & Answers

execute store procedure

Hi, can someone point out the tutorial or syntax for how to execute store procedure through shell scripting . thanks. (7 Replies)
Discussion started by: epall
7 Replies

3. Shell Programming and Scripting

How to compile a stored procedure that is there with in a script file(.sql) in unix

Hi, How can i compile the procedure code that is there in a script file (.sql) in unix. (0 Replies)
Discussion started by: krishna_gnv
0 Replies

4. Shell Programming and Scripting

how to store the return values of stored procedure in unix shell script.

hi i am calling a oracle stored procedure(in the database) from unix shell scripting (a.sh). the called stored procedure returns some values through OUT variables i want to assign the return values of stored procedure in to unix shell script variable. can you provide me the code. ... (1 Reply)
Discussion started by: barani75
1 Replies

5. Shell Programming and Scripting

Call and redirect output of Oracle stored procedure from unix script

Hi, Can you assist me in how to redirect the output of oracle stored procedure from unix script? Something similar to what i did for sybase isql -U$MYDBLOG -D$MYDBNAME -S$MYDBSVR -P$MYDBPWD -o$MYFILE<< %% proc_my_test 8 go %% Thanks in advance - jak (0 Replies)
Discussion started by: jakSun8
0 Replies

6. Shell Programming and Scripting

How to execute the stored procedure from shell script

How to execute the stored procedure from shell script and is there any possibility to print the dbms output in a log file. (2 Replies)
Discussion started by: dineshmurs
2 Replies

7. Shell Programming and Scripting

Shell Linux to connect to a database and execute store procedure

HI, i want to write a script (Linux) that: 1) connect to a database oracle 2) execute some store procedure. Can anybody help me, please? Thanks a lot Andrew (3 Replies)
Discussion started by: manichino74
3 Replies

8. Shell Programming and Scripting

Unable to execute Stored Procedure from CRON

Hi, I am very new to this environment - I hope this is the right platform to discuss my issue: I created a CRON job to run a Stored Procedure from our database - Sybase. Within the Stored Procedure there is a TRUNCATE table and CREATE table function. the CRON job fails to run with... (2 Replies)
Discussion started by: pizzazzz
2 Replies

9. Shell Programming and Scripting

ksh and Oracle stored procedure output in logfile

Friends, I pass some runtime arguments (date, number) through ksh script to Oracle procedure, use input value and pass it on to procedure. Oracle procedure gets input value, run query and logs everything in the logfile. I'm facing with couple of challenges 1. Even though I pass all... (5 Replies)
Discussion started by: homer4all
5 Replies

10. How to Post in the The UNIX and Linux Forums

Calling a Sybase Stored procedure from a UNIX Script

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File.somehow i try to find a solution but whwn i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies
INGRES_FETCH_PROC_RETURN(3)						 1					       INGRES_FETCH_PROC_RETURN(3)

ingres_fetch_proc_return - Get the return value from a procedure call

SYNOPSIS
int ingres_fetch_proc_return (resource $result) DESCRIPTION
This function is used to retrieve the return value following the execution of an Ingres database procedure (stored procedure). Note If used with a row-producing procedure, this function should be called after all the rows from the procedure have been fetched using ingres_fetch_array(3), ingres_fetch_object(3) or ingres_fetch_row(3). This function will eliminate any rows yet to be fetched should there be any left over. PARAMETERS
o $result - The result identifier for a query RETURN VALUES
Returns an integer if there is a return value otherwise it will return NULL. EXAMPLES
Example #1 Get the return value from a procedure call <?php $link = ingres_connect($database); if ( ingres_errno() != 0 ) { $error_text = ingres_error(); die($error_text); } $result = ingres_query($link, "execute procedure php_proc (value = 1000)"); if ( ingres_errno() != 0 ) { $error_text = ingres_error(); die($error_text); } echo "return value - " . ingres_fetch_proc_return($result) . " "; ingres_close($link); ?> SEE ALSO
ingres_query(3), ingres_fetch_array(3), ingres_fetch_object(3), ingres_fetch_row(3). PHP Documentation Group INGRES_FETCH_PROC_RETURN(3)
All times are GMT -4. The time now is 08:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy