Setting variable

Started by Ranieri Mazilialmost 19 years ago2 messagesgeneral
Jump to latest
#1Ranieri Mazili
rmazili@wgsystems.com.br

Hello,
I need to know why can't I do it?

CREATE OR REPLACE FUNCTION lost_hours_temp(date)
RETURNS text AS
$BODY$
DECLARE
START_DATE date;
END_DATE date;
QUERY text;
BEGIN
START_DATE := $1;
END_DATE := START_DATE - interval '3 year';

The last line (END_DATE := START_DATE - interval '3 year';) generate the
following error:

ERROR: operator is not unique: "unknown" / "unknown"
SQL state: 42725
Hint: Could not choose a best candidate operator. You may need to add
explicit type casts.
Context: PL/pgSQL function "lost_hours_temp" line 10 at assignment

How can I solve it?

Thanks

#2Aleksis Petrov
a.aleksis@gmail.com
In reply to: Ranieri Mazili (#1)
Re: Setting variable

On 6/18/07, Ranieri Mazili <rmazili@wgsystems.com.br> wrote:

Hello,
I need to know why can't I do it?

CREATE OR REPLACE FUNCTION lost_hours_temp(date)
RETURNS text AS
$BODY$
DECLARE
START_DATE date;
END_DATE date;
QUERY text;
BEGIN
START_DATE := $1;
END_DATE := START_DATE - interval '3 year';

The last line (END_DATE := START_DATE - interval '3 year';) generate the
following error:

ERROR: operator is not unique: "unknown" / "unknown"
SQL state: 42725
Hint: Could not choose a best candidate operator. You may need to add
explicit type casts.
Context: PL/pgSQL function "lost_hours_temp" line 10 at assignment

How can I solve it?

Thanks

Try adding explicit casts with the "::" operator.