Perl

Moderators: Jonathan
Number of threads: 1259
Number of posts: 3644

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
SQL/Perl: Creating a table with a variable name. Posted by FoR Trent on 25 Jun 2003 at 4:26 AM
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.
Report
Re: SQL/Perl: Creating a table with a variable name. Posted by Jonathan on 25 Jun 2003 at 4:38 AM
: 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:-

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


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.");

Report
Re: SQL/Perl: Creating a table with a variable name. Posted by FoR Trent on 25 Jun 2003 at 4:44 AM
: : 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:-
:
:
my $name = "table_name";
: my $sql = "CREATE TABLE $name (
:                column_1    VARCHAR(50)
:            )";

:
: 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. :)
Report
Re: SQL/Perl: Creating a table with a variable name. Posted by Jonathan on 25 Jun 2003 at 12:10 PM
: 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.");




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.