That should work (at least it did on my system).
What kind of error are you getting? Without this we on the list can
give you only very vague ideas of what might be going on.
One thing I found is that I need to give the full table name (e.g.,
myschema.mytable).
Another was that I added a "BEGIN" before the insert and an "END;" after
the insert.
Another thing to check to is that the values going in are what you
expect. To do this try printing the values like:
print "[$var1][$var2][$var3][$var4]\n";
right after the split. I use [] so that I can tell the exact content of
the variables. I mean doing something like
print "$var1 $var2 $var3 $var4\n";
won't tell you if one of the vars contains spaces. Note this won't work
too well if a var contains non-printable characters (e.g., chr(1) ).
Also, don't forget to use the -w switch and 'use strict'. They may tell
you more about what's going on that I can.
Dan
Mark Martin wrote:
>
> I'm really not sure what I'm doing here. Are my bindings in the wrong
> place(in the real program they are inside an IF) or do I need explicit
> bindings like this at all?
>
> Cheers
>
> use DBI;
> use DBD::Oracle;
>
> $dbh1 = DBI->connect( "dbi:Oracle:****", "****", "****" );
>
> my $sth2 = $dbh1->prepare("INSERT INTO TABLE VALUES (?,?,?,?)");
>
> open (FILE2, "file.txt")
>
> while (<FILE2>){
> chomp;
> $file2count++;
>
> ($var1,$var2,$var3,$var4) = split(/,/);
>
> $sth2->bind_param(1,$var1);
> $sth2->bind_param(2,$var2);
> $sth2->bind_param(1,$var3);
> $sth2->bind_param(1,$var4);
>
> $sth2->execute();
> }
> close (FILE2);
> _____________________________________________
>
> Mark Martin
> Computer Centre
> National University of Ireland Maynooth
>
> Tel: (01)708 4716/3830
> Fax: (01)628 6249