Gossamer Forum
Home : Products : DBMan SQL : Discussion :

The records with the following keys were not found in the database:

Quote Reply
The records with the following keys were not found in the database:
I've been working on converting the archive records mod to work with DBMan SQL v1 and have run into a problem. I keep getting this error:

The records with the following keys were not found in the database: <>2

It doesn't seem to matter what I do. It's like the key isn't there when I try to do the query. I can't get past this to see if my SQL syntax is correct or not. Here is the sub routine:

sub archive_records {
# --------------------------------------------------------
# archives a single or multiple records. First the routine goes thrrough the form input and makes sure there are some records to archive. It then goes
# through the database deleting each entry and marking it archived. If there are any keys not archived, an error message will be returned saying which keys
# were not found and not archived, otherwise the user will go to the success page.

my ($status, $db_table, $data, $auth_email_field, $query, $key, %archive_list, $rec_to_archive, @lines, $line,
@data, $errstr, $succstr, $output, $restricted, $found, $fieldnum);

$rec_to_archive = 0;
foreach $key (keys %in) { # Build a hash of keys to archive.
if ($in{$key} eq "archive") {
$archive_list{$key} = 1;
$rec_to_archive = 1;
}
}
if (!$rec_to_archive) {
&html_archive_failure("no records specified.");
return;
}


foreach $key (keys %archive_list) {
$db_is_int{$db_key} ?
($key_q = int($key)) :
($key_q = $DBH->quote($key));


if ($in{'$key'} eq "archive") {


$query = qq!

INSERT INTO $db_archive
SELECT * FROM $db_table
WHERE $db_key = $key_q

!;

$rc = $DBH->do($query);



if ($rc) {
$archive_list{$key} = 0;
foreach (keys %db_indexed) { &archive_index ($key, $_); }
}
}

else {

$output .= $line . "\n"

}
}

foreach $key (keys %archive_list) {
$archive_list{$key} ? # Check to see if any items weren't archived
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the ones we archived.
}
chop($succstr); # Remove trailing delimeter
chop($errstr); # Remove trailing delimeter


# delete original record

# open (DB, ">$db_file_name") or &cgierr("error in archive_records. unable to open db file: $db_file_name.\nReason: $!");
# if ($db_use_flock) {
# flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
# }
# print DB $output;
# close DB; # automatically removes file lock

&auth_logging("archived records: $succstr") if ($auth_logging);
$errstr ? # Do we have an error?
&html_archive_failure($errstr) : # If so, then let's report go to the failure page,
&html_archive_success($succstr); # else, everything went fine.
}


This is a work in progress, so I know not everything is right yet, but I need to get the Key before the "WHERE $db_key = $key_q" will work.
This is really weird because I can't find any differences between the way this is set up and the way validate_records is set up. Validate gets the keys without any problems, this sub won't get the keys for the records that are checked.
Thanks in advance for any help!


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)
Quote Reply
Re: [shann123] The records with the following keys were not found in the database: In reply to
Never mind... I simply rewrote the Delete records subroutine and it seems like it's going to work!
Check the upgrade from dbman to dbmansql 1 post for the mod. I'll post it as soon as I have it working and the mod posted on my website. Smile


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)