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

Passing tablename as argument into function

P: 18
Create or replace function Test(strTable in text) return bigint as
intSum bigint;
intSum:=(Select sum(salary) from strTable);
return intSum;
language plpgsql;

select Test('Employee');

I want to pass Table name as a argument into function and execute select statement on this table
I run this function error is occure
Aug 26 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 700
Expand|Select|Wrap|Line Numbers
  1. Select sum(salary) from strTable
to do that you have to put execute clause (it is a dynamic query).
Aug 26 '08 #2

Post your reply

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