Lines 104-116
if ($op eq 'add_form') {
Link Here
|
104 |
my $duplicate_entry = 0; |
104 |
my $duplicate_entry = 0; |
105 |
|
105 |
|
106 |
if ( $id ) { # Update |
106 |
if ( $id ) { # Update |
107 |
my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id='$id' "); |
107 |
my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? "); |
108 |
$sth->execute(); |
108 |
$sth->execute($id); |
109 |
my ($category, $authorised_value) = $sth->fetchrow_array(); |
109 |
my ($category, $authorised_value) = $sth->fetchrow_array(); |
110 |
if ( $authorised_value ne $new_authorised_value ) { |
110 |
if ( $authorised_value ne $new_authorised_value ) { |
111 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
111 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
112 |
"WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' and id<>$id"); |
112 |
"WHERE category = ? AND authorised_value = ? and id <> ? "); |
113 |
$sth->execute(); |
113 |
$sth->execute($new_category, $new_authorised_value, $id); |
114 |
($duplicate_entry) = $sth->fetchrow_array(); |
114 |
($duplicate_entry) = $sth->fetchrow_array(); |
115 |
warn "**** duplicate_entry = $duplicate_entry"; |
115 |
warn "**** duplicate_entry = $duplicate_entry"; |
116 |
} |
116 |
} |
Lines 133-140
if ($op eq 'add_form') {
Link Here
|
133 |
} |
133 |
} |
134 |
else { # Insert |
134 |
else { # Insert |
135 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
135 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
136 |
"WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' "); |
136 |
"WHERE category = ? AND authorised_value = ? "); |
137 |
$sth->execute(); |
137 |
$sth->execute($new_category, $new_authorised_value); |
138 |
($duplicate_entry) = $sth->fetchrow_array(); |
138 |
($duplicate_entry) = $sth->fetchrow_array(); |
139 |
unless ( $duplicate_entry ) { |
139 |
unless ( $duplicate_entry ) { |
140 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
140 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
141 |
- |
|
|