in reply to Re^3: $dbh could not be passed to function unless another variable is also passed
in thread $dbh could not be passed to function unless another variable is also passed
Probably I still miss something.
I have another function called create_table and the db handle does not pass correctly (should I bless it?). I does work when I create the handle within the function.
create_table($dbh, $table, "record_date char(20)"); sub create_table { use DBI; # Variables my $sth; # Database handle my $dbh = "$_[0]"; # Table name and optionally schema name (schema.table) my $table = "$_[1]"; # Columns and their type my $cols_type = "$_[2]"; # } else { # die RED, "ERROR: You have to supply database handle, table n +ame, the columns list with their type and if you to disconnect the da +tabase connection.\n Stopped$!"; # } # Create table $sth = $dbh->prepare("create table $table ($cols_type);"); $sth->execute(); print "INFO: The table has been created successfully.\n"; return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: $dbh could not be passed to function unless another variable is also passed
by Corion (Patriarch) on Aug 08, 2019 at 14:09 UTC | |
by tukusejssirs (Beadle) on Aug 08, 2019 at 14:53 UTC | |
by hippo (Archbishop) on Aug 08, 2019 at 14:58 UTC | |
by dsheroh (Monsignor) on Aug 09, 2019 at 07:24 UTC | |
|
Re^5: $dbh could not be passed to function unless another variable is also passed
by Fletch (Bishop) on Aug 08, 2019 at 14:11 UTC |