CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Matching file data against database data.

 



YouthHelp
New User

Nov 20, 2010, 5:43 PM

Post #1 of 1 (288 views)
Matching file data against database data. Can't Post

I have a situation where as I am matching data within a file and comparing it with the data of a database table. Here is the scenario:

I have a file with two set of numbers:

123456789,987654321

The first set of numbers are called old_results and the second set of numbers are called new_results.

What I have to do first is loop through the file comparing first the old_result numbers against the database result_numbers and then the new_result numbers against the database result_numbers. If the old_result numbers do not exist generate an error if they do continue to the next set of number which are the new_result numbers, if the new_result numbers exist generate an error if not update the database table with the new_results numbers and send out an email through the UNIX system indicating the update to the database table. I have to continue the loop through the file until all numbers in the file evaluated against the database table result_numbers. Here is what I have so far:

sub process_details {

open DAT, "$full_cuisp_path";
@line=<DAT>;
close(DAT);

#Read old cusip number. Verify if the cusip number exists on the buys_nscc_cusips table.


while ($line = <DAT>)
{
$comma = substr $line,10,1;
if (!($comma eq ',')){
&applog("comma in cusip line not in specified location.");
close_and_end;
}

($old_cusip,$new_cusip)= split(/,/,$line);

# Verify if the cusip exist on the buys_nscc_cusips table.
# If it does not, generate error to be used later on the email.

while (($cusip) = &ora_fetch($get_cusip_num_csr))

(($cusip) eq ($old_cusip));
{
if (!($cusip))

{
&applog("Old cusip $old_cusip does not exist.Update not completed.")
$email_subject = "Old cusip $old_cusip does not exist.Update not completed.";
$email_notification_message = "Old cusip $old_cusip does not exist.Update not completed.\n";
$email_user;
}

# Verify if the cusip number exist on the buys_nscc_cusips table.
# If it does generate error to be used later on the email.

if ($cusip eq $new_cusip )
{
&applog("New cusip $new_cusip already exist.Update not completed.");
$email_subject = "New cusip $new_cusip already exist.Update not completed.";
$email_notification_message = "New cusip $new_cusip already exist.Update not completed.\n";
}
# If new cusip does not exist on the buys_nscc_cusips table, update and produce log for
# later use for email.

if (($cusip) ne ($new_cusip )
{

&applog("Old cusip $old_cusip updated to new cusip $new_cusip");
$email_subject = "Old cusip $old_cusip updated to new cusip $new_cusip.";
$email_notification_message = "Old cusip $old_cusip updated to new cusip $new_cusip.\n";
$email_user;
}
}
close(DAT);
$email_user;

Is this logic correct? Please help me!!!!!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives