A plpgsql unidentifiable problem. - Mailing list pgsql-general

From Ralph Smith
Subject A plpgsql unidentifiable problem.
Date
Msg-id 2E32BABE-8A84-4A60-A420-467A39387350@washington.edu
Whole thread Raw
Responses Re: A plpgsql unidentifiable problem.
Re: A plpgsql unidentifiable problem.
List pgsql-general
I'm baffled and have tried various variations but still nogo.

From PgAdmin III I get:
-------------------------------------------
********** Error **********

ERROR: syntax error at or near ";"
SQL state: 42601
Character: 19001

-- referring to the semi-colon after the 'END' statement.


*******************************
When I check this out in PgAdmin III.
-------------------------------------------
CREATE OR REPLACE FUNCTION time_to_utime(given_time varchar) RETURNS INT AS
$$

DECLARE

  uppergt   varchar ;
  colon1    int ; 
  colon2    int ;
  digitsA   varchar ;
  digitsB   varchar ;
  digitsC   varchar ;
  numberA   int ;
  numberB   int ;
  numberC   int ;
  result    int ;
  
BEGIN

  IF check_time(given_time) = FALSE THEN
    RAISE NOTICE 'The time passed into function time_to_utime is not in a valid format.' ;
  END IF ;

  -- ----------------------------------------

  uppergt := upper(given_time) ;

  IF uppergt = 'BOD' THEN RETURN 0 ;
  IF uppergt = 'MOD' THEN RETURN 86400/2 ;
  IF uppergt = 'EOD' THEN RETURN 86399 ;

  -- ----------------------------------------

  colon1:=strpos(invar,':') ;
  colon2:=colon1+strpos(substring(invar from colon1+1),':') ;

  digitsA := split_part(invar,':',1) ;
  numberA := to_number(digitsA,'99') ;
   
  digitsB := split_part(invar,':',2) ;
  numberB := to_number(digitsB,'99') ;

  digitsC := split_part(invar,':',3) ;
  numberC := to_number(digitsC,'99') ;

  result := 3600*numberA + 60*numberB + numberC  ;

  RETURN result ;
   
END ;
$$ LANGUAGE PLPGSQL ;    /* time_to_utime   */
********************************************

Any clues?

THANKS!

Ralph Smith

pgsql-general by date:

Previous
From: Shane Ambler
Date:
Subject: Re: Database design: Backwards-compatible field addition
Next
From: Garry Saddington
Date:
Subject: Re: Losing data