Skip site navigation (1) Skip section navigation (2)

PLPERLU help

From: Atif Jung <atifjung(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: PLPERLU help
Date: 2010-06-30 08:59:31
Message-ID: AANLkTinjd3zcUpKITpkEOax313qEHs9LQRiYS9FrOXLT@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
I have the following SPL written in plperlu which I need help with please.

CREATE or replace FUNCTION validatesubmission(submission_num text) RETURNS
INTEGER AS $$
   $ISIS2_USER = "unknown";
   $cmd = '/isis2/pgbin/valsub ' || '-u' || ISIS2_USER || ' ' ||
submission_num;

   system($cmd);

   $query = "SELECT COUNT(*) FROM pend_file_results WHERE submission_no = "
|| submission_num || " AND code = '600' ";
   $rv = spi_exec_query($query);
   $count600 = $rv->{processed};
   if ($count600 = 1)
   {
      $result = 0; # JOB_ERRNO_OK
   }
   else
   {
      $result = 110; # JOB_101_ERRNO_VSUB_FAIL
   }
   return($result);
$$ LANGUAGE plperlu IMMUTABLE ;

The above loads into the DB ok, but when I call it I get the following error
msg:

error from Perl function "validatesubmission": syntax error at end of input
at line 8.

I'm not sure what line 8 actually refers to because in the DB the code is:

CREATE OR REPLACE FUNCTION public.validatesubmission(submission_num text)
 RETURNS integer
 LANGUAGE plperlu
 IMMUTABLE
AS $function$
   $ISIS2_USER = "unknown";
   $cmd = '/isis2/pgbin/valsub ' || '-u' || ISIS2_USER || ' ' ||
submission_num;

   system($cmd);

   $query = "SELECT COUNT(*) FROM pend_file_results WHERE submission_no = "
|| submission_num || " AND code = '600'";
   $rv = spi_exec_query($query);
   $count600 = $rv->{processed};

   if ($count600 = 1)
   {
      $result = 0; # JOB_ERRNO_OK
   }
   else
   {
      $result = 110; # JOB_101_ERRNO_VSUB_FAIL
   }

   return($result);
$function$

So that's also confused me. Any help would be appreciated.

Responses

pgsql-novice by date

Next:From: Michael WoodDate: 2010-06-30 11:58:39
Subject: Re: PLPERLU help
Previous:From: BidskiDate: 2010-06-30 08:47:21
Subject: Compiling under MSYS and Windows 7

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group