List:General Discussion« Previous MessageNext Message »
From:Richard Reina Date:July 27 2000 8:11pm
Subject:Please Help. Insert won't work for SET column.
View as plain text  
The SET  values don't go in.

#!/usr/bin/perl -w

@D_zone = "";
$D_zone[0] = "Z0";
push(@D_zone, "Z1");
push(@D_zone, "Z2");
push(@D_zone, "Z3");
push(@D_zone, "Z4");

$values[0] = "James Brown Trucking";
$values[1] = "@D_zone";

print @D_zone;
print @values;

use DBI;
my $dbh = DBI->connect("DBI:mysql:inventory","root","rr5492");
my $q = "INSERT INTO zone_test VALUES (" . (join ",", split /,/, ("?," x

@values)) . ")";
my $sth = $dbh->prepare($q);
$sth->execute(@values);
$dbh->disconnect;

#OUTPUT FROM PRINT STATEMENT:
c[root@localhost perlmenu.v4.0]# perl set_test
Z0Z1Z2Z3Z4James Brown TruckingZ0 Z1 Z2 Z3 Z4[root@localhost
perlmenu.v4.0]#

mysql> select * from zone_test;
+----------------------+--------+
| carrier              | d_zone |
+----------------------+--------+
| James Brown Trucking |        |
+----------------------+--------+
1 row in set (0.00 sec)

#TABLE STRUCTURE
mysql> show columns from zone_test;
+---------+--------------------------------------------------------+------+-----+---------+-------+

| Field   | Type                                                   |
Null | Key | Default | Extra |
+---------+--------------------------------------------------------+------+-----+---------+-------+

| carrier | varchar(20)                                            |
YES  |     | NULL    |       |
| d_zone  | set('Z0','Z1','Z2','Z3','Z4','Z5','Z6','Z7','Z8','Z9') |
YES  |     | NULL    |       |
+---------+--------------------------------------------------------+------+-----+---------+-------+

2 rows in set (0.00 sec)


Thread
Please Help. Insert won't work for SET column.Richard Reina27 Jul