dbTalk Databases Forums  

Writing to a file from SP

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Writing to a file from SP in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alex Naumenko
 
Posts: n/a

Default Writing to a file from SP - 04-13-2006 , 03:23 PM






Hi,

Does ASA 9.0.2 has a standard way (like some command or internal stored
procedure) to write to a file (append to existing one) from the code in
stored procedure or trigger?
Or the only way is to write DLL and call it from SP or trigger?

Thanks,
Alex.



Reply With Quote
  #2  
Old   
Pavel Karady
 
Posts: n/a

Default Re: Writing to a file from SP - 04-13-2006 , 03:30 PM






"Alex Naumenko" <alexn (AT) esna (DOT) com> wrote

Quote:
Hi,

Does ASA 9.0.2 has a standard way (like some command or internal stored
procedure) to write to a file (append to existing one) from the code in
stored procedure or trigger?
Or the only way is to write DLL and call it from SP or trigger?

Thanks,
Alex.

Hello, please take a look at the xp_write_file procedure (I use it
requently). But please note that DBA authority is required. Also, this
procedure saves onto the disk, where the database's dbsrv9.exe is running
from (that means, if you are connected to database server with a client from
a remote machine, the procedure will save on the server's disk).

There's almost no way to append to a file from within a stored procedure.
OUTPUT statement is permitted. There are several workarounds though:
1. You could load the entire file (for example using xp_read_file), add
something and write it again
2. You can smartly use the UNLOAD SELECT statement to append something to a
file

Hope that helped.
Pavel




Reply With Quote
  #3  
Old   
Sybase newsgroups
 
Posts: n/a

Default Re: Writing to a file from SP - 04-13-2006 , 03:46 PM



In article <443eb502$1@forums-1-dub>, pavel_ns.ns_karady (AT) ns_kogerusa (DOT) com
says...

....

Quote:
2. You can smartly use the UNLOAD SELECT statement to append something to a
file
That's what I do, and it works well with both data SELECTed from the
database, and for literal strings (UNLOAD SELECT 'This string will be
written to the file' TO ...)


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).


Reply With Quote
Reply




Thread Tools
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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.