Concat variable to form Table name inside Select statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soelistyani
    New Member
    • Jan 2008
    • 1

    Concat variable to form Table name inside Select statement

    Originally posted by mwasif
    Are you looking for this?
    [CODE=mysql]SET @a = 'table';
    SET @x := CONCAT('SELECT * FROM ', CONCAT(@a, '_', 'name'));
    Prepare stmt FROM @x;
    Execute stmt;[/CODE]
    This is equal to
    [CODE=mysql]SELECT * FROM table_name;[/CODE]




    i need help,
    how to Concat variable to form Table name inside insert statement in PL/SQL in oracle 7.3 ?

    thank you..
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Hi soelistyani,

    Welcome to TSDN!!!

    I am moving the question to Oracle Forum.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      try like the following sample code snippet.

      [code=oracle]
      declare
      t_name carchar2(30) :=&t_name;
      str_ins varchar2(200);
      begin
      str_ins:='inser t into' || t_name || 'values (...........,.. ......,........ ..);

      execute immediate str_ins ;
      end;

      [/code]

      Comment

      • vallis
        New Member
        • Jan 2008
        • 1

        #4
        Hello
        I m also having requiremnet of same kind.
        I would like to know how to concat a variable to a table in pl/sql
        as i need to insert data from the concated table to a custom table
        please help

        thanks

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Originally posted by vallis
          Hello
          I m also having requiremnet of same kind.
          I would like to know how to concat a variable to a table in pl/sql
          as i need to insert data from the concated table to a custom table
          please help

          thanks
          kindly post the code that you are working on for reference of our experts.

          Comment

          Working...