Help with returning affected rows from a function - Mailing list pgsql-novice

From Pradeepkumar, Pyatalo (IE10)
Subject Help with returning affected rows from a function
Date
Msg-id 77ED2BF75D59D1439F90412CC5B109740DBA4B9B@ie10-sahara.hiso.honeywell.com
Whole thread Raw
List pgsql-novice
 Hi,

 I m porting stored procedures from SQL to PGSQL. I dont know much about
PGSQL. I have problems in returning affected rows from the function. I could
not find much information about this. I would really appreciate if anyone
can help me out with this.

This is the procedure i m trying to execute...

CREATE FUNCTION PP_ReadParameter(INTEGER,VARCHAR) RETURNS VARCHAR AS '
DECLARE
    paramId ALIAS FOR $1;
    paramName ALIAS FOR $2;
    use_t Attributes%ROWTYPE;
BEGIN
    IF paramId IS NOT NULL THEN
        SELECT
            AttributeID AS ParameterID,
            AttributeName AS ParameterName,
            IsFixEnum,
            IsExpandEnum
        INTO use_t
        FROM Attributes
        WHERE AttributeID = paramID
        ORDER BY AttributeID;
        RETURN ''paramID successful'';
    ELSE
        IF paramName IS NOT NULL THEN
            SELECT
                AttributeID AS ParameterID,
                AttributeName AS ParameterName,
                IsFixEnum,
                IsExpandEnum
            INTO use_t
            FROM Attributes
            WHERE AttributeName = paramName
            ORDER BY AttributeID;
            RETURN ''paramName successful'';
        ELSE
            SELECT
                AttributeID AS ParameterID,
                AttributeName AS ParameterName,
                IsFixEnum,
                IsExpandEnum
            INTO use_t
            FROM Attributes
            ORDER BY AttributeID;
            RETURN ''paramID AND paramName not  successful'';
        END IF;
    END IF;
END;
' LANGUAGE 'plpgsql';

The Attributes table structure is
        Attributes(AttributeID LONG INTEGER,
            AttributeName    VARCHAR (50),
            AttributeDataType VARCHAR (20),
            AttributeDataSource VARCHAR (20),
            AttributeDataSourceAttribute INTEGER,
            IsFixEnum Bit,
            IsExpandEnum Bit);

Just to chk the working of the function i m returning some text....actually
i want to return the rows that are affected and print them.

Thanks in advance.

> With Best Regards
> Pradeep Kumar P J
>
>

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: libpq.so
Next
From: Alain-Serge Nagni
Date:
Subject: How to copy a database?