Thread: Compile of Pgmail function fails

Compile of Pgmail function fails

From
indu ss
Date:
Hello,

I want to send  mail on update of a field in a table.
I'm using pgmail() function (from sourceforge) . I'm
calling this function from another function which is
called by trigger on update of the field.
On executing the update statement i get error

CONTEXT:  compile of PL/pgSQL function "pgmail" near
line 1
PL/pgSQL function "test" line 10 at assignment

The line 10 corresponds to the line where pgmail
function is called.

   pos := pgmail(p1,p2,p3,p4);


Can anyone help me? I'm using postgres 7.4.7 version.

Thanks


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Compile of Pgmail function fails

From
Robert Treat
Date:
On Monday 06 February 2006 01:12, indu ss wrote:
> Hello,
>
> I want to send  mail on update of a field in a table.
> I'm using pgmail() function (from sourceforge) . I'm
> calling this function from another function which is
> called by trigger on update of the field.
> On executing the update statement i get error
>
> CONTEXT:  compile of PL/pgSQL function "pgmail" near
> line 1
> PL/pgSQL function "test" line 10 at assignment
>
> The line 10 corresponds to the line where pgmail
> function is called.
>
>    pos := pgmail(p1,p2,p3,p4);
>
>
> Can anyone help me? I'm using postgres 7.4.7 version.

Try to run pgmail by itself with those values and see what error that gives
you.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

Re: Compile of Pgmail function fails

From
indu ss
Date:
I'm using the pgmail function bundled in
pgMail-1.1.tar.

Tried

select
pgmail('<ind1_us@yahoo.com>','<ind1_us@yahoo.com>','Test
pgmail','Test message ');

Still i get this error
 ERROR:  syntax error at or near "set"
CONTEXT:  compile of PL/pgSQL function "pgmail" near
line 1


 I have specified proper  MAILSERVER  and
DATABASESERVER data in this function and function was
created .

create function pgmail(text, text, text, text) returns
int4 as '
set mailfrom $1
set mailto $2
set mailsubject $3
set mailmessage $4
set myHost "<ENTER YOUR MAILSERVER HERE>"
set myPort 25
set mySock [socket $myHost $myPort]
set toemailaddress_start [string first "<" $mailto]
if {$toemailaddress_start != -1} {
    set toemailaddress_finish [string first ">" $mailto]
    set toemailaddress_start [expr $toemailaddress_start
+ 1]
    set toemailaddress_finish [expr
$toemailaddress_finish - 1]
    set toemailaddress [string range $mailto
$toemailaddress_start $toemailaddress_finish]
} else {
    set toemailaddress $mailto
}
set fromemailaddress_start [string first "<"
$mailfrom]
if {$fromemailaddress_start != -1} {
    set fromemailaddress_finish [string first ">"
$mailfrom]
    set fromemailaddress_start [expr
$fromemailaddress_start + 1]
    set fromemailaddress_finish [expr
$fromemailaddress_finish - 1]
    set fromemailaddress [string range $mailfrom
$fromemailaddress_start $fromemailaddress_finish]
} else {
    set fromemailaddress $mailfrom
}
fileevent $mySock writable [list svcHandler $mySock]
fconfigure $mySock -buffering none
puts $mySock "helo <ENTER YOUR DATABASESERVER HERE>"
gets $mySock name
puts $mySock "mail from: $fromemailaddress"
gets $mySock name
puts $mySock "rcpt to: $toemailaddress"
gets $mySock name
puts $mySock "data"
gets $mySock name
puts $mySock "To: $mailto"
puts $mySock "From: $mailfrom"
puts $mySock "Subject: $mailsubject"
puts $mySock ""
puts $mySock "$mailmessage"
puts $mySock "."
gets $mySock name
close $mySock
return 1'
language 'pltclu';



Regards



--- Robert Treat <xzilla@users.sourceforge.net> wrote:

> On Monday 06 February 2006 01:12, indu ss wrote:
> > Hello,
> >
> > I want to send  mail on update of a field in a
> table.
> > I'm using pgmail() function (from sourceforge) .
> I'm
> > calling this function from another function which
> is
> > called by trigger on update of the field.
> > On executing the update statement i get error
> >
> > CONTEXT:  compile of PL/pgSQL function "pgmail"
> near
> > line 1
> > PL/pgSQL function "test" line 10 at assignment
> >
> > The line 10 corresponds to the line where pgmail
> > function is called.
> >
> >    pos := pgmail(p1,p2,p3,p4);
> >
> >
> > Can anyone help me? I'm using postgres 7.4.7
> version.
>
> Try to run pgmail by itself with those values and
> see what error that gives
> you.
>
> --
> Robert Treat
> Build A Brighter Lamp :: Linux Apache {middleware}
> PostgreSQL
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Re: Compile of Pgmail function fails

From
Tom Lane
Date:
indu ss <ind1_us@yahoo.com> writes:
> Still i get this error
>  ERROR:  syntax error at or near "set"
> CONTEXT:  compile of PL/pgSQL function "pgmail" near
> line 1

Somehow, I don't think you are passing this function to the
pltcl PL... either you mistyped the language attribute, or
you've managed to create the pltcl language as referencing
the plpgsql call handler.

            regards, tom lane