× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Working:
     select debugout( 'pgmrfillib/what', 'Hello' ) from sysibm/sysdummy1

Not working:
     select debugout( '/tmp/out.txt', 'Hello' ) from sysibm/sysdummy1

How can I get fopen to work with the IFS ?


-Steve More


On Fri, 18 Mar 2005 13:23:15 -0500, Stephen More <stephen.more@xxxxxxxxx> wrote:
> > Have you read the "Stored Procedures, Triggers and User Defined Functions on
> > DB2 Universal Database for iSeries" redbook. Here is a link to downloadable
> > PDF: http://www.redbooks.ibm.com/abstracts/sg246503.html?Open
> 
> No, but thanks for the link.
> 
> > You don't show it, so let me ask, did you compile this module into a service
> > program PGMRPGMLIB/DEBUGOUT?
> 
> I believe I did with:
> 
> CRTSRVPGM SRVPGM(PGMRPGMLIB/DEBUGOUT) EXPORT(*ALL) ACTGRP(*CALLER)
> 
> > Do 'fileName' and 'message' get passed in as struct that has a short 2 byte
> > integer value giving you the length of the data, followed by the data
> > itself?
> 
> Not that I can tell. In the above PDF they have example: (readFileToTable) 
> p513.
> 
> They pass in a VARCHAR(255) which maps to *fileName
> They are accessing it in the same way: fopen(fileName, "r"))
> 
> > Elvis
> >
> >
> > -----Original Message-----
> > From: c400-l-bounces+ebudimlic=centerfieldtechnology.com@xxxxxxxxxxxx
> > [mailto:c400-l-bounces+ebudimlic=centerfieldtechnology.com@xxxxxxxxxxxx] On
> > Behalf Of Stephen More
> > Sent: Friday, March 18, 2005 6:41 AM
> > To: c400-l@xxxxxxxxxxxx
> > Subject: [C400-L] DB2 UDF written in C
> >
> > 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
> > _______________________________________________
> > This is the C programming iSeries / AS400 (C400-L) mailing list
> > To post a message email: C400-L@xxxxxxxxxxxx
> > To subscribe, unsubscribe, or change list options,
> > visit: http://lists.midrange.com/mailman/listinfo/c400-l
> > or email: C400-L-request@xxxxxxxxxxxx
> > Before posting, please take a moment to review the archives
> > at http://archive.midrange.com/c400-l.
> >
> > _______________________________________________
> > This is the C programming iSeries / AS400 (C400-L) mailing list
> > To post a message email: C400-L@xxxxxxxxxxxx
> > To subscribe, unsubscribe, or change list options,
> > visit: http://lists.midrange.com/mailman/listinfo/c400-l
> > or email: C400-L-request@xxxxxxxxxxxx
> > Before posting, please take a moment to review the archives
> > at http://archive.midrange.com/c400-l.
> >
> >
>

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.