Connecting Tech Pros Worldwide Forums | Help | Site Map

create table MyVariable

Newbie
 
Join Date: Oct 2008
Posts: 2
#1: Oct 9 '08
Can I write in a plpgsql function a code like this:
declare mytablename char(10);
..........................
Expand|Select|Wrap|Line Numbers
  1.     if .... then
  2.       mytablename='John';
  3.     else
  4.       mytablename='Johnson';
  5.    end if;
  6.  
  7.  
  8.     create temp table mytablename as.........;
.................??

Moderator
 
Join Date: Dec 2006
Location: Europe
Posts: 293
#2: Oct 9 '08

re: create table MyVariable


you can try create table using dynamic sql
Expand|Select|Wrap|Line Numbers
  1. execute 'create temp table '||table_name ....
  2.  
Newbie
 
Join Date: Oct 2008
Posts: 2
#3: Oct 13 '08

re: create table MyVariable


It really works, thanks.
Reply