Share on Facebook

Monday, May 7, 2007

Write Log Files - Sybase

Writing Logs - Text Files using Sybase

If you want to write to a Log file using Sybase use the following
code. Here the log file is not overwritten - it is appended with the
existing text. As the existing text is stored in a variable and
rewritten to the file there will be a gradual slowdown in performance

Declare sbuffer long varchar;
Declare sText long varchar;
Declare iRet integer;
Set sbuffer = xp_read_file('c:\temp\sample.sql');
Set sText = '\n';
Set sText = sText || 'Writing Text @ ' || Now(*);
Set iRet = xp_write_file('c:\temp\sample.sql', sbuffer || sText);

1 comment:

August97 said...

I am using Sybase 12.5.4. Are xp_write_file and xp_read_file available on 12.5.4.

I tried to use these in stored procedure, it gave me following error,

'Function xp_write_file not found,....'

I tried running query
sp_help xp_write_file in subsystemprocs. It shows 'Object does not exist in this database'.

Can you help me? Thanks!

Related Posts Plugin for WordPress, Blogger...