[prev in list] [next in list] [prev in thread] [next in thread]
List: msqlperl
Subject: Inserting with Perl Module
From: Ruben I Safir <rs83 () is7 ! nyu ! edu>
Date: 1998-07-10 0:53:49
[Download RAW message or body]
I'm having trouble figuring out how to use the PERL module for Inserting
data into a table on the fly.
My confusion is coming from 2 problems. One is that, the docs in the
MYSQL reference is not conistitant with the references for CSPAN where I
downloaded the modules from.
Secondly, there is not a lot of info on INSERT using dymanic programing.
Our test code looks as follows:
#! /usr/bin/perl
%pairs;
@field = ("FamNum", "First", "Last", "MTDDebits",
"MTDCredits", "CurrBal", "YTDFamilyPmts", "YTDPmtsThisPat",
"PatientFlags", "LastTransDate", "LastPmtDate", "LastTreatDate",
"LastProphyDate", "ProphyRecNum", "NextProphyDate", "NextProphyTime",
"DentalRecNum", "NextDentalDate", "NextDentalTime", "Sex",
"MaritalStat", "Future7", "BirthDate", "SocialSec", "HomePh", "WorkPh",
"Address", "City", "State", "Zip", "NumReferrals", "MedDentHistQue",
"CumInsBal1", "CumInsBal2", "LstFamPmtAmt", "FamPointer",
"TransPointer", "OldUnposted", "FamTransPtr", "OldMonthlyPayment",
"IncomeFromRefer", "YTDInsFiled", "YTDInsPmtsPrim", "YTDInsPmtSec",
"PrintFlags", "Future1", "YTDPrevCrgs", "YTDBasicAndMajor",
"SuppressPosting", "YTDFinanceChrgs", "Future2", "LastTransBatch",
"ApptPtr", "PreferHyg", "PatStatus", "PrefDent", "PatProvInsPrim",
"EmpProvInsPrim", "EmpProvInsSec", "RelToInsPrim", "Future10",
"ReferType", "ReferredBy", "OldChart", "SendStatements", "CollAgency",
"AnnivDate", "NumInsCovers", "Future4", "RecallFreq", "CleaningTime",
"RelToInsSec", "ChargeInterest", "PatProvInsSec", "Chart",
"OnPaymentPlan", "Conversion", "Location", "Future11", "UnUsed",
"BadDebt");
opendir(DATABASE, "/d/dental") || die "can't open Dental
Directory";
@allfiles = readdir DATABASE;
use Mysql;
use DBI;
$dbh = DBI
->connect("DBI:mysql:patients:localhost",root,'let.me.in') or die "we're
fucked";
print "Handle $dbh XXX \n";
for( $i=0; $i<@allfiles; $i++){
next if( $allfiles[$i]!~/^patient$/);
print "***********Hey We have $allfiles[$i]*************\n\n";
open( WORKING_FILE, "/d/dental/"."$allfiles[$i]") or die "Can't
open $allfiles[$i]";
$j=0;
$offset=0;
while( $offset = read WORKING_FILE, $parse_file,416){
$j++;
print"Record Number : $j \n";
@datastring =
unpack(a5a13a16llllla2a6a6a6a6aa6a4aa6a4aaa39a6a9A14A14A27a17a2a10a2a5lllllllllllla2allala8Cssasa5a4a4aa18aa5a5aaa6aa7aa2aaa5a6aa3saa4a,
$parse_file);
for($k=0;$k<@datastring;$k++){
$pairs{$field[$k]} = $datastring[$k];
# print "$k : $field[$k] :: $datastring[$k]// \n";
}
# $rowef = $dbh ->do( "INSERT INTO patients VALUES
($pairs{FamNum}, $pairs{First}, $pairs{Last}, $pairs{Sex},
$pairs{MaritalStat}, $pairs{BirthDate}, $pairs{SocialSec},
$pairs{HomePh}, $pairs{WorkPh}, $pairs{Address}, $pairs{City},
$pairs{State}, $pairs{Zip}, $pairs{PreferHyg}, $pairs{PrefDent},
$pairs{Chart})") or die "finished";
print "\nRECORD ENTERED\n";
}
print "WHILE is Finished\n";
}
$rc = $dbh->disconnect;
It's was choking on a null input, then we changed the login to root.
Now it works, but
when I select on the table in the mysql client - nothing happens.
Ruben
----------------------------------------------------------------------
To unsubscribe from this list send a message containing "unsubscribe"
to msqlperl-request@franz.ww.tu-berlin.de
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic