create table MyVariable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danciu
    New Member
    • Oct 2008
    • 2

    create table MyVariable

    Can I write in a plpgsql function a code like this:
    declare mytablename char(10);
    ............... ...........
    Code:
        if .... then
          mytablename='John';
        else
          mytablename='Johnson';
       end if;
    
    
        create temp table mytablename as.........;
    ............... ..??
    Last edited by eWish; Oct 22 '08, 10:06 PM. Reason: Please use code tags
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    you can try create table using dynamic sql
    Code:
    execute 'create temp table '||table_name ....

    Comment

    • danciu
      New Member
      • Oct 2008
      • 2

      #3
      It really works, thanks.

      Comment

      Working...