Gossamer Forum
Home : Products : Gossamer Links : Discussions :

problems with $table->delete

Quote Reply
problems with $table->delete
Hi,



I'm having a problem deleting a record. Whenever I try to delete a record I get the error 'Can't use an undefined value as a HASH reference at <path>/admin/GT/SQL/Table.pm line 2227'.



The code is here;

my $table = $DB->table('MEMBERS');

my $result = $table->delete( {member_key => $member_key} );

The contents of the MEMBERS def file is below:

{
'subclass' => {},
'index' => {},
'fk' => {
'MEMBER_ACCT_DETAILS' => {
'member_id' => 'acct_id'
}
},
'cols' => {
'member_key' => {
'type' => 'INT',
'pos' => '1',
'not_null' => '1',
'unsigned' => '0'
},
'member_id' => {
'type' => 'VARCHAR',
'pos' => '2',
'size' => '6',
'not_null' => '1'
},
'username' => {
'type' => 'VARCHAR',
'pos' => '3',
'size' => '64',
'not_null' => '1'
},
'rawpw' => {
'type' => 'VARCHAR',
'pos' => '4',
'size' => '64',
'not_null' => '1'
},
'password' => {
'type' => 'VARCHAR',
'pos' => '5',
'size' => '32',
'not_null' => '1'
},
'title' => {
'type' => 'VARCHAR',
'pos' => '6',
'size' => '16',
'not_null' => '1'
},
'initials' => {
'type' => 'VARCHAR',
'pos' => '7',
'size' => '8',
'not_null' => '0'
},
'firstname' => {
'type' => 'VARCHAR',
'pos' => '8',
'size' => '32',
'not_null' => '1'
},
'other_names' => {
'type' => 'VARCHAR',
'pos' => '9',
'size' => '32',
'default' => ''
},
'surname' => {
'type' => 'VARCHAR',
'pos' => '10',
'size' => '64',
'not_null' => '1',
'default' => ''
},
'honours' => {
'type' => 'VARCHAR',
'pos' => '11',
'size' => '64',
'default' => ''
},
'dob' => {
'type' => 'DATE',
'pos' => '12',
'not_null' => '1'
},
'membership_type' => {
'type' => 'VARCHAR',
'pos' => '13',
'size' => '8',
'default' => ''
},
'professional_pos' => {
'type' => 'VARCHAR',
'pos' => '14',
'size' => '255',
'default' => ''
},
'pocp' => {
'type' => 'VARCHAR',
'pos' => '15',
'size' => '255',
'default' => ''
},
'diploma_id' => {
'type' => 'VARCHAR',
'pos' => '16',
'size' => '16'
},
'educational_qualifications' => {
'type' => 'VARCHAR',
'pos' => '17',
'size' => '64',
'default' => ''
},
'addr1' => {
'type' => 'VARCHAR',
'pos' => '18',
'size' => '64',
'not_null' => '1',
'default' => ''
},
'addr2' => {
'type' => 'VARCHAR',
'pos' => '19',
'size' => '64',
'default' => ''
},
'addr3' => {
'type' => 'VARCHAR',
'pos' => '20',
'size' => '64',
'default' => ''
},
'town_city' => {
'type' => 'VARCHAR',
'pos' => '21',
'size' => '64',
'not_null' => '1'
},
'county' => {
'type' => 'VARCHAR',
'pos' => '22',
'size' => '64',
'default' => ''
},
'country' => {
'type' => 'VARCHAR',
'pos' => '23',
'size' => '64',
'default' => ''
},
'postcode' => {
'type' => 'VARCHAR',
'pos' => '24',
'size' => '64'
},
'home_phone_no' => {
'type' => 'VARCHAR',
'pos' => '25',
'size' => '24',
'default' => ''
},
'mobile_no' => {
'type' => 'VARCHAR',
'pos' => '26',
'size' => '24',
'default' => ''
},
'home_fax_no' => {
'type' => 'VARCHAR',
'pos' => '27',
'size' => '24'
},
'work_phone_no' => {
'type' => 'VARCHAR',
'pos' => '28',
'size' => '24',
'default' => ''
},
'work_fax_no' => {
'type' => 'VARCHAR',
'pos' => '29',
'size' => '24',
'default' => ''
},
'email_addr' => {
'type' => 'VARCHAR',
'pos' => '30',
'size' => '24',
'not_null' => '11',
},
'web_addr' => {
'type' => 'VARCHAR',
'pos' => '31',
'size' => '255'
},
'ever_logged_in' => {
'values' => [
'Y',
'N'
],
'type' => 'ENUM',
'pos' => '32',
'not_null' => '1',
'default' => 'N'
},
'search_optin' => {
'values' => [
'checked',
'NULL'
],
'type' => 'ENUM',
'pos' => '33',
'not_null' => '0',
'default' => 'NULL'
},
},
'ai' => 'member_key',
'fk_tables' => [
'SESSIONS',
'MEMBER_ACCT_DETAILS'
],
'pk' => [
'member_key'
],
'unique' => {}
};
Quote Reply
Re: [wobbly] problems with $table->delete In reply to
Hi,

Can you print out a couple lines around 2227 and also the exact version of GT::SQL::Table you are using -- look at the top of the file for something like:

# $Id: Table.pm,v 1.220 2002/09/04 07:18:25 aki Exp $

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [wobbly] problems with $table->delete In reply to
Hi Alex,



The code's creator is:

$Id: Table.pm,v 1.159 2001/08/14 21:50:37 aki Exp $



Here's the code around line 2227:

sub _create_sel_hash {
# -------------------------------------------------------------------
# Creates the hash that we either select from or
# delete from
#
my ($self, $href, $table_name) = @_;
my $sel = {};
my $new_schema = $self->new_table ($table_name) or return $self->error ("FKNOTABLE", 'FATAL', $table_name, $GT::SQL::error);


my %fk = $new_schema->fk;

This is line 2227 my %hash = reverse %{$fk{$self->name}};


for (keys %$href) {
$sel->{$hash{$_}} = $href->{$_} if exists $hash{$_};
}
return $sel;
}