On Feb 10, 2006, at 13:01, James Biggs wrote:


I can do for example

$dbh->do( "CREATE TABLE my_table (etc etc etc)");

but i don't know a Perl command for creating a table with many columns. I
did not find one in the docs either. Thanks

The idea is that you build the SQL string dynamically:

    my @column_defs = fetch_column_defs_from_somwehere();
    my $sql = <<SQL;
    CREATE TABLE my_table (
        @{[ join ",\n", @column_defs ]}
    )
    SQL

The function fetch_column_defs_from_somwehere() is assumed to fetch the column defs dynamically from somewhere. Of course this is worth the effort if the defs are dynamically fetchable somehow, otherwise you'd need to type them as in SQL, which would have no benefit.

-- fxn


Reply via email to