O
Occidental
...ie the column name, definitions (varchar(100) etc). The most
obvious way is to parse the output from describe table_name. Is there
an easier way? My goal is to create a generic INSERT sub, which takes
as args table_name and a hash reference, eg:
$table_name = "TheTable";
$hash(Int1) = 99;
$hash(Float2) = 1.54;
$hash(String7) = "Goodbye cruel world";
...where Float2, Int1, String7 are some but not all cols in mysql table
TheTable. The sub is invoked as follows:
DoInsert($table_name, \%hash);
DoInsert will generate and execute the INSERT statement, NULLing out
fields not in %hash, single quoting string fields, etc., maybe even
doing data tyep compatibility tests. I would be happy to learn that
some one has beaten me to it, and a procedure like DoInsert already
exists.
obvious way is to parse the output from describe table_name. Is there
an easier way? My goal is to create a generic INSERT sub, which takes
as args table_name and a hash reference, eg:
$table_name = "TheTable";
$hash(Int1) = 99;
$hash(Float2) = 1.54;
$hash(String7) = "Goodbye cruel world";
...where Float2, Int1, String7 are some but not all cols in mysql table
TheTable. The sub is invoked as follows:
DoInsert($table_name, \%hash);
DoInsert will generate and execute the INSERT statement, NULLing out
fields not in %hash, single quoting string fields, etc., maybe even
doing data tyep compatibility tests. I would be happy to learn that
some one has beaten me to it, and a procedure like DoInsert already
exists.