|
I am trying to a create a DB2 function that writes output to a file. I am close, but it does not seem to work. Does anyone know what the problem could be ? /* This method will be called from DB2 */ #include <stdio.h> #include <time.h> void DEBUGOUT( char* fileName, char* message, int* ValRet, short* inind, short* outind, char* sqlstate, char* funcname, char* specname, char* msgtext ) { FILE *fp; char *fileType; time_t now; struct tm *ptr; char buf1[20]; if( ( fp = fopen( fileName, "a" )) != NULL ) { time( &now ); ptr = localtime( &now ); strftime(buf1, 80, "%m/%d/%y %H:%M:%S %p", ptr); *ValRet = fprintf( fp, "%s %s\n", buf1, message ); fclose( fp ); } else { *ValRet = 0; *outind = 0; } } CRTCMOD MODULE(PGMRPGMLIB/DEBUGOUT) SRCFILE(PGMRSRCLIB/CSRC) DBGVIEW(*SOURCE) CRTSRVPGM SRVPGM(PGMRPGMLIB/DEBUGOUT) EXPORT(*ALL) ACTGRP(*CALLER) CREATE FUNCTION PGMRPGMLIB/DEBUGOUT( VARCHAR(50), VARCHAR(50) ) RETURNS INTEGER EXTERNAL NAME 'PGMRPGMLIB/DEBUGOUT(DEBUGOUT)' LANGUAGE C NO SQL PARAMETER STYLE SQL DETERMINISTIC; select ( '/tmp/out.txt', 'Hello' ) from sysibm/sysdummy1 I am only getting back 0. -Thanks Steve More
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.