Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2011
    Posts
    12

    Unanswered: 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

  2. #2
    Join Date
    Mar 2011
    Posts
    12

    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

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Consider using bcp

  4. #4
    Join Date
    Mar 2011
    Posts
    12

    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'

  5. #5
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    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!

  6. #6
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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

  7. #7
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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.)

  8. #8
    Join Date
    Mar 2011
    Posts
    12

    bcp error

    Thanks for the suggestions. However, it errors.

    Here is a screenshot:
    Attached Thumbnails Attached Thumbnails Screenshot-ISQL Error.png  

  9. #9
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    bcp is not a sql command. You need to run it from the operating system command prompt

  10. #10
    Join Date
    Mar 2011
    Posts
    12

    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

  11. #11
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    There is no unload command in Sybase ASE
    Only noticed now you are using Sybase sqlanywhere10
    Thanks for posting your solution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •