471,050 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

Temporary tables

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
1 1802
534 Expert 512MB
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.

Similar topics

reply views Thread by Zlatko Matić | last post: by
1 post views Thread by Stefan van Roosmalen | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.