Advertisement

12.07.2005 at 03:22PM PST, ID: 21657108
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

use of unitialized value error

Asked by worldfear in Perl Programming Language

Tags: , , , ,

this script pulls data from a cvs file, and creates a many to many relationship in an oracle db -
it hangs with this error msg.  pls help before i pull out the rest of my hair!!

Name "main::c" used only once: possible typo at oraperldbi-st2.plx line 128.
Name "main::s" used only once: possible typo at oraperldbi-st2.plx line 129.
Use of uninitialized value at oraperldbi-st2.plx line 183, <CSV> chunk 1.
Use of uninitialized value at oraperldbi-st2.plx line 195, <CSV> chunk 1.
DBD::Oracle::st execute failed: ORA-00936: missing expression (DBD ERROR: OCIStmtExecute) at oraperldbi-st2.plx line 198, <CSV> chunk 1.
Couldn't execute statement: ORA-00936: missing expression (DBD ERROR: OCIStmtExecute) at oraperldbi-st2.plx line 198, <CSV> chunk 1.





\#!/usr/bin/perl -w
$ENV{'ORACLE_HOME'} = '/u00/app/oracle/product/8.1.7';
$ENV{'ORACLE_SID'} = 'ORADEV';
use DBI;
use DBD::Oracle;
use Text::CSV;

    my $file = 'tiexport.csv';
    my $csv = Text::CSV->new();

       $dbh = DBI->connect( 'dbi:Oracle:ORADEV',
                        'RISILL',
                        'RISILL92',
                      ) || die "Database connection not made: $DBI::errstr";
    open (CSV,$file) or die $!;

    while (<CSV>) {
      #  next if ($. == 1);
        if ($csv->parse($_)) {
            my @columns = $csv->fields();
            #print "@columns\n";
            my $c3val=$columns[3];
            my $lc3val=length($c3val);
            if ( $lc3val < 4 ) {
                 $c3val="Empty";
            }
            my @d=split(/;;/,$c3val);
            my $t=$columns[1];

             foreach (@d)
                 {
                 $sbfld=$_;
                 $sl=length($sbfld);
                 my $codeloc=index($sbfld,'|n');
                 my $snameloc=index($sbfld,'|h');
                 my $code=substr ($sbfld,0,$codeloc-1);

                  if ($c3val eq 'Empty')
                 {
                 $sname="no source";
                 }
                 else
                 {
                 $sname=substr ($sbfld,$codeloc +3,$snameloc-$codeloc);
                 $sname=~ s/\|h//g;
                 $sname=~ s/^\s+//;
                 $sname=~ s/\s+$//;
                 }

# IF NO PRICE DATA IN SUBFIELD
                 if ( index($sbfld,'|o') == -1 )
                     {
                         $hold=substr ($sbfld,$snameloc+2,$sl);
                         $hold=~ s/\|o//g;    
                    }

# IF PRICE DATA

                else
                    {
                         my $holdloc=index($sbfld,'|o');
                         $hold=substr ($sbfld,$snameloc+2,$holdloc);
                         $price=substr ($sbfld,$holdloc+2,$sl);
                         $hold=~ s/\|o//g;  
                    }
                              
#####SUB ADDSOURCE
sub addSource($sourcename,$sourcecode)
{
my ($sourcename, $sourcecode) = @_;
my $sthaddSource = $dbh->prepare("insert into source2
            (sourceid,sourcename,sourcecode) values
                    (seq_source2_id.nextval,$sourcename,$sourcecode)");
             $sthaddSource->execute()
                    or die "Couldn't execute statement: " .
$sthaddSource->errstr;
  $newsname= $dbh->quote( $sourcename ) ;
  my $sth = $dbh->prepare("select            
         sourceid from
        source2 where sourcename=$newsname");
                 $sth->execute()
                    or die "Couldn't execute statement: " . $sth->errstr;
 if ( @sdata= $sth->fetchrow_array() )
                {
                $sourceid=$sdata[0];              
                }
return ($sourceid);
}
######SUB ADDTIT
sub addTit($newTit)
{
my ($newTit) = shift(@_);
$sthaddTit = $dbh->prepare("insert into title2
            (title_id,title) values
                   (seq_titid2.nextval,$newTit)");
            $sthaddTit->execute()
                   or die "Couldn't execute statement: " .
$sthaddTit->errstr;
$newTitle= $dbh->quote( $newTit ) ;
my $newsth = $dbh->prepare("select title_id from title2 where
title=$newTitle");
                 $newsth->execute()
                  or die "Couldn't execute statement: " . $newsth->errstr;
 if ( @tdata= $newsth->fetchrow_array() )

                {

                $newtitleid=$tdata[0];              

                }
return ($newtitleid);
}


######TEST FOR SOURCE AND ADD IF NEEDED              
                 my $sname2= $dbh->quote( $sname );
                 my $sth = $dbh->prepare("select                  
                         sourceid,sourcecode,sourcename,sourceaddress,sourcephone,sourcefax from
                          source2 where sourcename=$sname2");

                 $sth->execute()
                    or die "Couldn't execute statement: " . $sth->errstr;

#IF SOURCE IS IN DB, GET SOURCEID, SOURCECODE, SOURCENAME
                if ( @data= $sth->fetchrow_array() )
                {
                $i=$data[0];
                $c=$data[1];
                $s=$data[2];
                }

#IF SOURCE NOT IN DB, CALL FUNCTION TO ADD IT
                else
                {
                $newsid = &addSource($sname,$code);
                print "Source $sname not found in db - callING ADDsource\n";

####$SEARCH=Y -- THE SOURCE JUST ADDED, USE $newsid
                $search='y';
                }
                $sth->finish;
####END OF TEST FOR SOURCE


#####TEST FOR TITLE AND ADD IF NEEDED
                my $t2= $dbh->quote( $t ) ;
                my $sth2 = $dbh->prepare("select title_id,title from
                          title where title=$t2");            

                 $sth2->execute()
                    or die "Couldn't execute statement: " . $sth2->errstr;

#####IF TITLE IS IN DB      
                if ( @data2 = $sth2->fetchrow_array() )
                {
#####GET TITLEID AND TITLE
                my $tid=$data2[0];
                my $tit=$data2[1];
#####IF NEW SOURCE ID, USE NEWSID
                    if ($search eq 'y')
                    {
                        $sth3 = $dbh->prepare("insert into title_source          
                  (title_sourceid,title_sourceno,source_titleno,title_sourcedata) values
                          (seq_tsid.nextval,$tid,$newsid,$hold)");
                  $sth3->execute()
                                or die "Couldn't execute statement: " . $sth3->errstr;
                    }

                    else
                    {
                    $sth3 = $dbh->prepare("insert into title_source        
                        (title_sourceid,title_sourceno,source_titleno,title_sourcedata) values
                                (seq_tsid.nextval,$tid,$i,$hold)");
                   $sth3->execute()
                    or die "Couldn't execute statement: " . $sth3->errstr;
                    }
                }

#####IF TITLE NOT IN DB, CALL FUNC TO ADD IT
                else
                {
        $newtid=&addTit($t2);              
            if ($search eq 'y')
            {
            $sth4 = $dbh->prepare("insert into title_source              
                        (title_sourceid,title_sourceno,source_titleno,title_sourcedata) values
                              (seq_tsid.nextval,$newtid,$newsid,$hold)");
            $sth4->execute()
                or die "Couldn't execute statement: " . $sth4->errstr;
                        
            }

            else
            {
            $sth4 = $dbh->prepare("insert into title_source              
                        (title_sourceid,title_sourceno,source_titleno,title_sourcedata) values
                                   (seq_tsid.nextval,$newtid,$i,$hold)");
            $sth4->execute()
                or die "Couldn't execute statement: " . $sth4->errstr;
            }

                }

                $sth2->finish;

                $hold='';
                $price='';
                $i='';
              $newsid='';
                $search='';
                }
             } else {
           my $err = $csv->error_input;
           print "Failed to parse line: $err";
        }
    }
    close CSV;
      $dbh->disconnect();






Start Free Trial
[+][-]12.07.2005 at 05:44PM PST, ID: 15441680

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: expression, missing, perl, unitialized, value
Sign Up Now!
Solution Provided By: Tintin
Participating Experts: 4
Solution Grade: A
 
 
[+][-]12.07.2005 at 05:51PM PST, ID: 15441711

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.07.2005 at 08:21PM PST, ID: 15442244

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.08.2005 at 05:35AM PST, ID: 15444124

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2006 at 08:19PM PDT, ID: 16696103

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05.20.2006 at 12:25AM PDT, ID: 16723645

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy