If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > exporting data to cvs in sybase

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-19-11, 22:14
detox detox is offline
Registered User
 
Join Date: Mar 2011
Posts: 6
exporting data to cvs in sybase

hello all!

quick version,,, I am running Servoy 3.5.12 , sybase asa v 10.1 on centos v 5.5.

I need to run a nightly routine getting data from one table ( 5 - 10 fields) and exporting to csv file. Was told I could not schedule an event that uses OUTPUT command. I can run from interactive sql, but then would have to do it each day.

Tried to run command dbisql -c "DSN = mydatabase" my_daily_script.sql but this errors not finding libdblib10_r.so.

All I need to do is create a text file with data to import into a db used for a phone dialer to remind clients of appts.
I'm stumped.

Any help will be greatly appreciated
Reply With Quote
  #2 (permalink)  
Old 03-19-11, 23:14
detox detox is offline
Registered User
 
Join Date: Mar 2011
Posts: 6
comamnd line to topic?

Have found a possible solution,, but not getting it to work............

here is what i am typing:

[stevek@homeserver scripts]$ /srv/sqlanywhere10/bin32/dbisql -nogui -U DBA -S sql -S servoy_repository -i /home/stevek/Desktop/phone_dialer.sql


and here is the result:

Usage: DBISQL [options] [sqlCommand|commandFileName]
@<data> expands <data> from file <data>


So,,,,,,,,,,,,,,

Am I completely wrong in trying to get a csv file from comamndline? or,,, am I jsut not entering it corrrectly?

Thanks for any help
Reply With Quote
  #3 (permalink)  
Old 03-22-11, 08:56
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Consider using bcp
Reply With Quote
  #4 (permalink)  
Old 03-22-11, 16:15
detox detox is offline
Registered User
 
Join Date: Mar 2011
Posts: 6
use of bcp?

reading about bcp, it appears it is used for a whole table.

I need to do the following in an automated schedule:

SELECT phone_home_client, creationdate, dateformat(creationdate, 'mm/dd/yy'), appt_time, staff_email
FROM outcomes WHERE specifier1 = 'Next TASC Appointment';
OUTPUT TO '/home/stevek/Desktop/test2day.csv'
Reply With Quote
  #5 (permalink)  
Old 03-23-11, 04:00
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
You can create a view with that specifiek selectstatement, and bcp-out the view to '/home/stevek/Desktop/test2day.csv
BCP works with both tables and views.
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
  #6 (permalink)  
Old 03-23-11, 04:02
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Options available:
1) use the init string of bcp to do the select
2) Create a view and bcp out the view
3) select into a tempdb table, bcp out the tempdb table, drop the temp table
Reply With Quote
  #7 (permalink)  
Old 03-23-11, 04:21
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
example using --initstring
Code:
bcp tempdb..#t1 out /tmp/mydata.csv -c -Ume -Pmypw -Smysrv --initstring "select currdate=convert(char(8),getdate(),1) into #t1"

Starting copy...

1 rows copied.
Clock Time (ms.): total = 2  Avg = 2 (500.00 rows per sec.)
Reply With Quote
  #8 (permalink)  
Old 03-30-11, 15:31
detox detox is offline
Registered User
 
Join Date: Mar 2011
Posts: 6
bcp error

Thanks for the suggestions. However, it errors.

Here is a screenshot:
Attached Thumbnails
exporting data to cvs in sybase-screenshot-isql-error.png  
Reply With Quote
  #9 (permalink)  
Old 03-31-11, 03:27
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
bcp is not a sql command. You need to run it from the operating system command prompt
Reply With Quote
  #10 (permalink)  
Old 04-03-11, 18:38
detox detox is offline
Registered User
 
Join Date: Mar 2011
Posts: 6
exporting to cvs in sybase

Hello all!

Thanks so much for the help!

I found the answer. I can schedule a script to export data in sybase by using the UNLOAD command.

it worked great.

Again, thanks for all the suggestions
Reply With Quote
  #11 (permalink)  
Old 04-05-11, 05:12
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
There is no unload command in Sybase ASE
Only noticed now you are using Sybase sqlanywhere10
Thanks for posting your solution
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

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