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

Temporary tables

P: 8
Can you build a temporary table with in a sql function?

Expand|Select|Wrap|Line Numbers
  1. CREATE FUNCTION fnTest(integer) RETURNS bigint AS'
  2.  create temporary table mfb (business_name varchar(50) not null);
  4.  insert into mfb
  5.   select business_prov_name from mco61_provider
  6.   where npi = $1;
  8.  select count(1) from mfb;
  9.  '
I'm getting an err

ERROR: relation "mfb" does not exist
SQL state: 42P01
Context: SQL function "fntest"
Jun 11 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 534
Can you build a temporary table with in a sql function?
Yes, you can, but this won't help you because you cannot have a function which makes use of the table it creates - the table must exist in order to create/compile this function.

Please use the CODE tags in your next posting, refer to Posting Guidelines at the top of the forum if you are not sure how to do it.
Jun 12 '07 #2

Post your reply

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