whereiskurt has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
I have some really basic DB statement stuff:
my $dbh = DBI->connect( 'DBI:ODBC:ALIAS', $username, $password); my $stmt = $dbh->prepare('SELECT * FROM SCHEMA.TABLE'); $stmt->execute(); ...
I want to be able to generate the DDL (CREATE TABLE ...) that could hold the returned rows.
I realise there are some deeper issues that could crop up, but I'm really hoping there is a solution based on the DBIs structs:
my $type_ref = $stmt->{TYPE}; my $precision_ref = $stmt->{PRECISION}; my $scale_ref = $stmt->{SCALE}; my $colnames = $stmt->{NAME}; my $nullable = $stmt->{NULLABLE};
I've started looking at SQL::Translator but it seems a bit heavy, and might not support DB2. I'm just a little overwhelmed by the amount of places to look ...
Does someone know of such a snippet or a good starting point? I'm sure I could hand code it, but, if I don't have to that'd be even better. :-)
Regards,
Kurt
PS: Long live the Monastery!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CREATE TABLE DDL from DBI Statement
by jfroebe (Parson) on Jul 21, 2008 at 21:57 UTC | |
|
Re: CREATE TABLE DDL from DBI Statement
by jfroebe (Parson) on Jul 21, 2008 at 21:50 UTC | |
|
Re: CREATE TABLE DDL from DBI Statement
by CountZero (Bishop) on Jul 21, 2008 at 22:40 UTC | |
by whereiskurt (Friar) on Jul 21, 2008 at 23:36 UTC | |
by CountZero (Bishop) on Jul 22, 2008 at 05:24 UTC | |
by whereiskurt (Friar) on Jul 22, 2008 at 13:08 UTC | |
by whereiskurt (Friar) on Jul 22, 2008 at 21:09 UTC | |
|
Re: CREATE TABLE DDL from DBI Statement
by dokkeldepper (Friar) on Jul 22, 2008 at 05:58 UTC | |
by whereiskurt (Friar) on Jul 22, 2008 at 13:12 UTC |