Re: Oid problem - Mailing list pgsql-general

From Richard Huxton
Subject Re: Oid problem
Date
Msg-id 200404081554.55371.dev@archonet.com
Whole thread Raw
In response to Oid problem  (Sky <sky@sylvio.hu>)
List pgsql-general
On Thursday 08 April 2004 15:21, Sky wrote:
> Problem:
> pg_loopen() unable to open PostgreSQL large object in...
>
> Solution from another mailing list:
> My blob oid was very big.
> I had to cast to (float) the oid parameter of pg_loopen.

Sorry, bigger than what? Why float?

> Question:
> The oid is a type, isn't it?

Yes

> I tried to use the oid in a function:
>
> CREATE FUNCTION addfoto(character varying, oid)
> RETURNS INTEGER
> AS
>  '
>  BEGIN;
>  INSERT INTO foto(filename, image) VALUES ( $1, $2 );
>  COMMIT;
>  SELECT 1 AS RESULT;
>  '
> LANGUAGE 'sql';

Assuming the definition of "foto" is OK, looks fine from here.

> So, What can I do, and how, how can I "CAST" ??

Sorry - dont understand, but you can cast by:

SELECT foo::int8 ...
SELECT CAST(foo as int8) ...


Is the problem that you want to handle oid's (0 .. 4 billion) and you are
using int4 (-2 billion .. +2 billion). In which case int8 might be a better
choice than int4.

HTH
--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: eval in plpgsl
Next
From: Greg Stark
Date:
Subject: Re: Storing jpgs