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!!
In reply to CREATE TABLE DDL from DBI Statement by whereiskurt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |