Received: from isidoro2.unileon.es (isidoro2.unileon.es [193.146.96.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8JAjpe22624 for ; Wed, 19 Sep 2001 06:45:53 -0400 (EDT) (envelope-from iafmgc@unileon.es) Received: from intergraph (n104111.unileon.es [193.146.104.111]) by isidoro2.unileon.es (8.9.3/8.9.1) with SMTP id MAA05391; Wed, 19 Sep 2001 12:45:20 +0200 (MET DST) Message-ID: <002701c140f7$9d75d710$1301a8c0@uimagen> From: =?iso-8859-1?Q?Miguel_Gonz=E1lez?= To: "Haller Christoph" Cc: References: <200109190824.KAA23466@rodos> Subject: Re: Registring a C function in PostgreSQL Date: Wed, 19 Sep 2001 12:41:12 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200109/145 X-Sequence-Number: 4823 Many thanks for your answers. The thing that in the Bruce´s book doesnt explain how to compile this kind of functions, anyway I found how to compile it. Now, I am still having problems. I want to create a function to send an email. I pass to the function two arguments: the email to send, and the text to send. First, I tried with pointers to char. It worked when I just create a function called "sendemail()" with no arguments and set inside the text and the email arguments. When I read some more documentation about how to use strings in PostgreSQL, I discovered that I have to use the text type in my C program I just try it but although it worked before, now I doesnt work. This is what I have tried: #include #include "postgres.h" int sendemail(text *email,text *message) { char string_tosend [300]; sprintf(string_tosend,"echo \"%s\" >/tmp/mailtmp.txt \n",VARDATA(message)); system(string_tosend); sprintf(string_tosend,"mail -s \"message from PostgreSQL\" %s To: "Miguel González" Cc: Sent: Wednesday, September 19, 2001 12:24 PM Subject: Re: [SQL] Registring a C function in PostgreSQL > Did you use the compiler option for generating > position independent code (PIC) for use in building > shared libraries. > Did you use the linker option for creating > a shared library - I think you did, the file > suffix .so looks that way. > I did it several times successfully using commands > like > CREATE FUNCTION byteatostr(bytea) RETURNS text > AS './byteatostr.sl' LANGUAGE 'c'; > and it worked. > Maybe you should add some more information about > what you did in detail. > Regards, Christoph >