By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

Functiion Problem

P: 53
hi all,

i have a table with three columns.
tran_event_cd, event_cd,party_cd.
can i pass the column name in the function.

Expand|Select|Wrap|Line Numbers
  1. create or replace function fn_one(int8,int8)
  2. returns setof tbl_one as 
  3. '
  4. declare 
  5. r tbl_one%rowtype;
  6. a alias for $1;
  7. b alias for $2;
  8. begin
  9.  for r in select tran_event_cd, event_cd,party_cd
  10.  from tran_event where $1=$2
  11. loop
  12. return next r;
  13. end loop;
  14. return ''a'';
  15. end'
  16. language 'plpgsql' volatile;
  17.  
where $1 is field name just like event_cd and $2 is its value.
is it possible to do so.
plz any help is appreciated.
TIA
Jul 19 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 534
I don't think you can pass column name to the function.

As a side note if you were to pass the column name the first argument in the function would've been declared as type name, or varchar, not the integer.

Another problem there is on line 14: return ''a'';
You cannot return anything when function returns a rowset - this line should be just return;
Jul 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.