BUG #2431: Error:SELECT query has no destination for result data

From: "bhavani" <pavuluribhavani(at)yahoo(dot)co(dot)in>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2431: Error:SELECT query has no destination for result data
Date: 2006-05-11 05:29:02
Message-ID: 200605110529.k4B5T2xn087587@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 2431
Logged by: bhavani
Email address: pavuluribhavani(at)yahoo(dot)co(dot)in
PostgreSQL version: postgresql 8.10
Operating system: windowsxp
Description: Error:SELECT query has no destination for result data
Details:

CREATE OR REPLACE FUNCTION insert_adv_exrate(IN comp_id int4, IN advid int4,
IN currid1 int4, OUT exid int4, OUT exrate float8) RETURNS record
AS $$
/*$BODY$*/
declare currid integer;
get_exdetails refcursor;
begin
select exid=max(ex_id) from adv_exrate where comp_id=comp_id and
adv_id=advid ;

if(coalesce(exid,0)=0) then
exid:=1;
else
exid:=exid+1;
END if;

open get_exdetails FOR

select curr_id,exchange_rate from curr_master where comp_id=comp_id;

LOOP
FETCH get_exdetails into currid,exrate;

IF NOT FOUND THEN
EXIT; -- exit loop
END IF;


insert into adv_exrate values(exid,comp_id,advid,currid,exrate);

END LOOP;

CLOSE get_exdetails;

select exrate=exchange_rate from curr_master where comp_id=comp_id and
curr_id=currid1;

end;

/*$BODY$*/
$$ LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION insert_adv_exrate(IN comp_id int4, IN advid int4, IN currid1
int4, OUT exid int4, OUT exrate float8) OWNER TO postgres;

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

CREATE OR REPLACE FUNCTION insert_adv_exrate(IN comp_id int4, IN advid int4,
IN currid1 int4, OUT exid int4, OUT exrate float8) RETURNS record
AS $$
/*$BODY$*/
declare currid integer;
get_exdetails refcursor;
begin
select exid=max(ex_id) from adv_exrate where comp_id=comp_id and
adv_id=advid ;

if(coalesce(exid,0)=0) then
exid:=1;
else
exid:=exid+1;
END if;

open get_exdetails FOR

select curr_id,exchange_rate from curr_master where comp_id=comp_id;

LOOP
FETCH get_exdetails into currid,exrate;

IF NOT FOUND THEN
EXIT; -- exit loop
END IF;


insert into adv_exrate values(exid,comp_id,advid,currid,exrate);

END LOOP;

CLOSE get_exdetails;

select exrate=exchange_rate from curr_master where comp_id=comp_id and
curr_id=currid1;

end;

/*$BODY$*/
$$ LANGUAGE 'plpgsql' VOLATILE;

i am using the above procedure in postgre sql.
theprocedure is execting successfully.but when i am giving select
insert_adv_exrate(222222222,1,2); it is giving error as

ERROR: SELECT query has no destination for result data
HINT: If you want to discard the results, use PERFORM instead.
CONTEXT: PL/pgSQL function "insert_adv_exrate" line 5 at SQL statement

How can i solve this problem

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Simon Riggs 2006-05-11 11:42:09 Re: BUG #2428: ERROR: out of memory, running INSERT SELECT
Previous Message Casey Duncan 2006-05-10 16:34:20 Re: BUG #2428: ERROR: out of memory, running INSERT SELECT statement