Function error

From: "Sugandha Shah" <Sugandhas(at)cybage(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Function error
Date: 2002-08-13 06:06:39
Message-ID: 002a01c2428f$96de9000$2005a8c0@cybage.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi ,

I'm porting MS- SQL stored procedure to postgres . I'm getting this error :

Error occurred while executing PL/pgSQL function sel_free_disk_space
line 7 at SQL statement
SELECT query has no destination for result data.
If you want to discard the results, use PERFORM instead.

Here is the MS -SQL stored procedure :

CREATE procedure sel_free_disk_space
@computer_id int,
@letter char(1)
as
declare @free int

select @free = [free]
from logical_drive
where computer_id = @computer_id
and letter = upper(@letter)

if (@free is null)
set @free = -1

return @free
GO

Here is the equivalent function for Postgres :

CREATE FUNCTION sel_free_disk_space(int4,bpchar) RETURNS integer AS '
DECLARE
-- Declare variable to store the free space.
free INTEGER;

BEGIN
select free from logical_drive where computer_id = $1 and letter = upper($2);
IF free IS NULL THEN
RETURN -1;
END IF;

RETURN free;
END;
'LANGUAGE 'plpgsql';

I'm not able to understand what I'm missing ?

Secondly is there any equivalent of exec for postgres ?

Any help will be highly appreciated.

Regards,
-Sugandha

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Janning Vygen 2002-08-13 07:01:30 Re: Function error
Previous Message Weiping He 2002-08-13 03:58:02 Re: Is this valid?