do you guys have users out there dropping columns that once existed? or do you just want to have applications that work regardless of whether the schema is actually the same or not? seems like if a column is missing, and it is worth checking for in a perl script, that there may be many other serious problems in the schema, missing tables, no stats, wrong data type definitions, missing indexes, missing grants, etc. maybe a one time schema compare to ensure that the schema the app is running against is what you expect it to be upfront would be an optimal approach vs. handling this kind of thing in code, even if it is only one line. :) Job
"Ing. Branislav Gerzo" <[EMAIL PROTECTED]> wrote: Michael A Chase [MAC], on Thursday, May 12, 2005 at 05:48 (-0700) made these points: MAC> I'd do something like this: MAC> my $sth = $dbh -> column_info( undef, $sSchema, $sTable, $sColumn ); MAC> my @sColumnInfo = (); MAC> eval { # The eval isn't needed if RaiseError == 0. MAC> @sColumnInfo = $sth -> fetchrow_array() || (); MAC> }; MAC> if ( ! @sColumnInfo ) { MAC> # The ALTER TABLE statement is likely to be RDBMS specific. MAC> $dbh -> do( "ALTER TABLE my_table ADD my_column VARCHAR(100)" ); MAC> } Today I _need_ that, and came to this solution: create_column() unless $dbh->column_info(undef, undef, 'table_here', '%')->fetchall_hashref('COLUMN_NAME')->{column_here}; 1 line :) -- How do you protect mail on web? I use http://www.2pu.net [SD Stardate] --------------------------------- Discover Yahoo! Have fun online with music videos, cool games, IM & more. Check it out!