From: | Philippe Grégoire <philippe(dot)gregoire(at)boreal-is(dot)com> |
---|---|
To: | Ralph Smith <smithrn(at)washington(dot)edu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: A plpgsql unidentifiable problem. |
Date: | 2008-06-19 19:51:41 |
Message-ID: | 485AB8CD.8000509@boreal-is.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
And the semi-colon should be removed after the END
Philippe
Philippe wrote:
> I think that the IF clauses need END IF.
>
> IF uppergt = 'BOD' THEN RETURN 0; END IF;
> IF uppergt = 'MOD' THEN RETURN 86400/2; END IF;
> IF uppergt = 'EOD' THEN RETURN 86399; END IF;
>
> This should solve the problem.
>
> Philippe Gregoire
> Information Manager
> www.boreal-is.com
>
>
>
> Ralph Smith wrote:
>> 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
>>
>> ------------------------------------------------------------------------
>>
>> No virus found in this incoming message.
>> Checked by AVG. Version: 7.5.524 / Virus Database: 270.4.0/1507 -
>> Release Date: 6/18/2008 7:09 AM
>>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Charles Simard | 2008-06-19 19:56:31 | FW: finding firstname + lastname groups |
Previous Message | Philippe Grégoire | 2008-06-19 19:49:01 | Re: A plpgsql unidentifiable problem. |