List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 16 1999 2:52pm
Subject:Re: How to delete a member from a SET column
View as plain text  
On Thu, 1999-09-16 13:17:46 +0200, Martin Ramsch wrote:
> See the attachment
> (if it hopefully makes it through the list processor).

Did I say attachment? :)
Here it is, finally!

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7

#!/usr/local/bin/perl -w
use strict;
use DBI;
use Math::BigInt;

# "data source name": 3rd element is default database
my $dsn = "DBI:mysql:test";
my ($user, $pass) = ('nobody', '');   # you may need to fix these

my $dbh = DBI->connect($dsn, $user, $pass)
    or die "connect failed: ", $DBI::errstr;

# Prepare the statement for execution.
my $sth = $dbh->prepare('DESCRIBE settable setfield')
    or die "prepare failed: ", $dbh->errstr;

# Execute the prepared statement.
$sth->execute
    or die "execute failed: ", $sth->errstr;

# Get (reference to) the result row.
my $row = $sth->fetchrow_arrayref;

# Extract the 'Type' field (it's the 2nd one!).
my $type = $row->[1];

print "\nType is: $type\n\n";

# Extract array of set element names.
my @element = $type =~ /'([^']+)'/g;     # '

# Show bit value, bit number, and element name.
my $i = 0;
my $v = Math::BigInt->new(1);
my $name;
printf("%20s   %2s   %s\n", 'Value', 'No', 'Name');
foreach $name (@element) {
  printf("%20s = %2d = '%s'\n", $v, $i, $name);
  $i += 1;
  $v *= 2;
}

# Release the statement handle resources.
$sth->finish;

# Disconnect from the database.
$dbh->disconnect;

exit;

Thread
How to delete a member from a SET columnBenjamin Pflugmann7 Jul
  • Re: How to delete a member from a SET columnMartin Ramsch15 Sep
    • Re: How to delete a member from a SET columnJames Manning15 Sep
      • Re: How to delete a member from a SET columnMartin Ramsch16 Sep
        • Re: How to delete a member from a SET columnMartin Ramsch16 Sep
          • Re: How to delete a member from a SET columnJames Manning17 Sep
            • Re: How to delete a member from a SET columnMartin Ramsch17 Sep
              • Re: How to delete a member from a SET columnJames Manning17 Sep
                • Re: How to delete a member from a SET columnMartin Ramsch17 Sep
                  • placeholdersjice17 Sep
                    • Re: placeholdersBob Kline17 Sep
                  • Re: How to delete a member from a SET columnJames Manning17 Sep
        • Re: How to delete a member from a SET columnJames Manning17 Sep
          • Re: How to delete a member from a SET columnMartin Ramsch17 Sep