![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hi all, I have written a sample procedure where i pass 2 arguments. Based on the arguments i need to select few fields from a table. After selecting the fields i have to display them. How do i return the selected fields. The procedure is as follows CREATE FUNCTION PP_ReadParameter(integer,varchar) RETURNS TEXT AS ' DECLARE ParamId INTEGER; ParamName TEXT; IsFixEnum BIT; IsExpandEnum BIT; BEGIN IF $1 IS NOT NULL THEN SELECT INTO ParamId,ParamName,IsFixEnum,IsExpandEnum AttributeId,AttributeName,IsFixEnum,IsExpandEnum FROM Attributes WHERE AttributeId = $1 ORDER BY AttributeId; RETURN ''$1 successfull''; END IF; ...... ...... END; ' LANGUAGE 'plpgsql'; So when i say SELECT PP_ReadParameter(50,Null)......it should return the ParamId,ParamName,.... But to check the working of the function i just return ''$1 successfull'' as i dont know how to return the tuple. Please help me on this With Best Regards Pradeep Kumar P J |
#2
| |||
| |||
|
|
I have written a sample procedure where i pass 2 arguments. Based on the arguments i need to select few fields from a table. After selecting the fields i have to display them. How do i return the selected fields. The procedure is as follows CREATE FUNCTION PP_ReadParameter(integer,varchar) RETURNS TEXT AS ' DECLARE ParamId INTEGER; ParamName TEXT; IsFixEnum BIT; IsExpandEnum BIT; BEGIN IF $1 IS NOT NULL THEN SELECT INTO ParamId,ParamName,IsFixEnum,IsExpandEnum AttributeId,AttributeName,IsFixEnum,IsExpandEnum FROM Attributes WHERE AttributeId = $1 ORDER BY AttributeId; RETURN ''$1 successfull''; END IF; ...... ...... END; ' LANGUAGE 'plpgsql'; So when i say SELECT PP_ReadParameter(50,Null)......it should return the ParamId,ParamName,.... But to check the working of the function i just return ''$1 successfull'' as i dont know how to return the tuple. |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
When you send the query to be parsed I presume you must somehow tell which elements of it are parameters. How do you do this? e.g.: SELECT name, phone FROM friends WHERE age > 25; How would I write this if "name" and "25" must be parameters? Or if the operator ">" should be a parameter or modifiable in another way? |
#5
| |||
| |||
|
|
At 4:26 PM +0200 7/8/04, M. Bastin wrote: When you send the query to be parsed I presume you must somehow tell which elements of it are parameters. How do you do this? e.g.: SELECT name, phone FROM friends WHERE age > 25; How would I write this if "name" and "25" must be parameters? |
|
Or if the operator ">" should be a parameter or modifiable in another way? |
|
Can "age > 25" as a whole be a parameter? |
![]() |
| Thread Tools | |
| Display Modes | |
| |