From d1f418d1d781adc908734b4accfc8950b29f10e9 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 2 Aug 2010 13:24:53 +0000 Subject: [PATCH] fix changed code in setNodesAttribs for DB2 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6941 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index dec0eafcf..81843e117 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -1724,6 +1724,7 @@ sub setNodesAttribs { my %cols = (); my @orderedcols=(); my $oldac = $self->{dbh}->{AutoCommit}; #save autocommit state + my $xcatcfg =get_xcatcfg(); # get current database $self->{dbh}->{AutoCommit}=0; #turn off autocommit for performance my $hashrec; my $colsmatch=1; @@ -1797,7 +1798,13 @@ sub setNodesAttribs { while (scalar @currnodes) { my %updatenodes=(); my %insertnodes=(); - my $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE $nodekey in (";#sort nodes into inserts and updates + my $qstring; + #sort nodes into inserts and updates + if ($xcatcfg =~ /^DB2:/){ + $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE \"$nodekey\" LIKE ("; + } else { + $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE $nodekey in ("; + } $qstring .= '?, ' x scalar(@currnodes); $qstring =~ s/, $/)/; my $query = $self->{dbh}->prepare($qstring); @@ -1843,12 +1850,20 @@ sub setNodesAttribs { if (not $upsth and keys %updatenodes) { #prepare an insert statement since one will be needed my $upstring = "UPDATE ".$self->{tabname}." set "; foreach my $col (@orderedcols) { #try aggregating requests. Could also see about single prepare, multiple executes instead - $upstring .= "$col = ?, "; + if ($xcatcfg =~ /^DB2:/){ + $upstring .= "\"$col\" = ?, "; + } else { + $upstring .= "$col = ?, "; + } } if (grep { $_ eq $nodekey } @orderedcols) { $upstring =~ s/, \z//; } else { - $upstring =~ s/, \z/ where $nodekey = ?/; + if ($xcatcfg =~ /^DB2:/){ + $upstring =~ s/, \z/ where \"$nodekey\" = ?/; + } else { + $upstring =~ s/, \z/ where $nodekey = ?/; + } } $upsth = $self->{dbh}->prepare($upstring); }