Search Postgresql Archives

Re: Copying large object in a stored procedure

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

 



> Is there an easy way to copy a large object to a new one, having a new
> OID and it's content independent from the original ?

So my current solution would be:

CREATE OR REPLACE FUNCTION copy_blob(p_blobId OID)
RETURNS OID AS '
DECLARE
    v_NewOID BIGINT;
BEGIN
    SELECT lo_create(0) INTO v_NewOID;

    DELETE FROM pg_largeobject WHERE loid = v_NewOID;

    INSERT INTO pg_largeobject (loid, pageno, data)
    SELECT v_NewOID, pageno, data 
    FROM pg_largeobject
    WHERE loid = p_blobId;

    RETURN v_NewOID;
END;
' LANGUAGE plpgsql;


I would still be grateful if anybody knows a better solution using plain
SQL/plpgsql...

Cheers,
Csaba.




[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