SQL/Perl: Creating a table with a variable name.

How would one go about creating and naming a table for an sql database by using CGI. This is the main part:

my $name="table_name";

my $sql = "CREATE TABLE products(
column_1 VARCHAR(50)
)";


Although, instead of having 'products' as the name, I would want to have the value of $name as the name. I'm not sure exactly how this would be accomplished. Any ideas? Thanks.

Comments

  • : How would one go about creating and naming a table for an sql
    : database by using CGI. This is the main part:
    :
    : my $name="table_name";
    :
    : my $sql = "CREATE TABLE products(
    : column_1 VARCHAR(50)
    : )";
    :
    :
    : Although, instead of having 'products' as the name, I would want to
    : have the value of $name as the name. I'm not sure exactly how this
    : would be accomplished. Any ideas? Thanks.
    This would (almost certainly) work:-

    [code]my $name = "table_name";
    my $sql = "CREATE TABLE $name (
    column_1 VARCHAR(50)
    )";[/code]

    You can generate any bits of an SQL query from variables if you want. :-)

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : How would one go about creating and naming a table for an sql
    : : database by using CGI. This is the main part:
    : :
    : : my $name="table_name";
    : :
    : : my $sql = "CREATE TABLE products(
    : : column_1 VARCHAR(50)
    : : )";
    : :
    : :
    : : Although, instead of having 'products' as the name, I would want to
    : : have the value of $name as the name. I'm not sure exactly how this
    : : would be accomplished. Any ideas? Thanks.
    : This would (almost certainly) work:-
    :
    : [code]my $name = "table_name";
    : my $sql = "CREATE TABLE $name (
    : column_1 VARCHAR(50)
    : )";[/code]
    :
    : You can generate any bits of an SQL query from variables if you want. :-)
    :
    : Hope this helps,
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :
    Wow... What is wrong with me. :-p
    That was the first thing I tried, but it was making a table named "$name"... I must have been doing something wrong. :)

    Thanks a great deal for your help. :)
  • : Wow... What is wrong with me. :-p
    : That was the first thing I tried, but it was making a table
    : named "$name"... I must have been doing something wrong. :)
    Maybe you'd put it in non-interpolating quotes, e.g. '' rather than "".

    : Thanks a great deal for your help. :)
    You're welcome.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories