dbTalk Databases Forums  

Help with returning affected rows from a function

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Help with returning affected rows from a function in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pradeepkumar, Pyatalo
 
Posts: n/a

Default Help with returning affected rows from a function - 06-18-2004 , 01:42 AM







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.

Quote:
With Best Regards
Pradeep Kumar P J


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.