Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 9th, 2008, 08:50 AM
Newbie
 
Join Date: Oct 2008
Posts: 2
Default create table MyVariable

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.........;
.................??

Last edited by eWish; October 22nd, 2008 at 11:06 PM. Reason: Please use code tags
Reply
  #2  
Old October 9th, 2008, 04:02 PM
Moderator
 
Join Date: Dec 2006
Posts: 250
Default

you can try create table using dynamic sql
Expand|Select|Wrap|Line Numbers
  1. execute 'create temp table '||table_name ....
  2.  
Reply
  #3  
Old October 13th, 2008, 10:12 AM
Newbie
 
Join Date: Oct 2008
Posts: 2
Default

It really works, thanks.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles