Search Postgresql Archives

Re: Get interval in months

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



am  Mon, dem 10.11.2008, um 12:06:04 +0700 mailte dbalinglung folgendes:
> Dear Expert,

First, please create a new thread for a new question.


>  
> I have a function to getting time interval bellow :
>  
> create or replace function scmaster.pr_gettimeinterval(time without time zone,
> time without time zone, numeric(5,2)) returns char(10) As '
> declare v_timein    alias for $1;
>         v_timeout   alias for $2;
>         v_timebreak alias for $3;
>         v_output    char(10);
> begin
>   raise notice ''-- BOF --'';
>   v_output := select ((v_timeout - v_timein) - interval ''v_timebreak
> minutes'');
>  
>   raise notice ''-- EOF --'';
> return v_output;
> end;'
> language plpgsql;
>  
>  
> and when i compilled from pgAdmin, i got some error message bellow :
>  
> ERROR:  syntax error at or near "select"
> LINE 1: SELECT  select (( $1  -  $2 ) - interval 'v_timebreak minute...
>                 ^
> QUERY:  SELECT  select (( $1  -  $2 ) - interval 'v_timebreak minutes')
> CONTEXT:  SQL statement in PL/PgSQL function "pr_gettimeinterval" near line 7
>  
> ********** Error **********


Rewrite the line 

v_output := select ((v_timeout - v_timein) ...

to:

select into v_output ((v_timeout - v_timein) ...


(not tested)


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux