From: Dave W Cottrell [mailto:[EMAIL PROTECTED]
> On 4/18/05, Bowie Bailey <[EMAIL PROTECTED]> wrote:
> > From: Dave W Cottrell [mailto:[EMAIL PROTECTED]
> > > On 4/18/05, Bowie Bailey <[EMAIL PROTECTED]> wrote:
> > > > From: Dave W Cottrell [mailto:[EMAIL PROTECTED]
> > > > >
> > > > > The code:
> > > > > $sql = qq{insert into ppp_admin.$table_name ('$columns') values
> > > > > ('$result') };
> > > > > $sth_prod = $dbh_prod->prepare($sql) || die $dbh_prod->errstr;
> > > > > $sth_prod->execute();
> > > > > $sth_prod->finish() || die $dbh_prod->errstr;.
> > > > >
> > > > > The $columns and $result are coma delimited strings. The error
> > > > > occurs on the 'execute'.
> > > > >
> > > > > DBD::ODBC::st execute failed: [Oracle][ODBC][Ora]ORA-00928:
> > > > > missing SELECT keyword
> > > > >
> > > > > I might note that this script works fine using DBI and on a unix
> > > > > platform and the folloiwng connect.
> > > > > $dbh_prod = DBI->connect(
> > > > > "dbi:Oracle:host=$db_p_server;sid=$db_p_sid;port=$db_p_port",
> > > > > $db_p_user, $db_p_password) || die "Connect Error";
> > > > >
> > > > > When I changed to ODBC and Windows, the problem surfaced.
> > > > > $dbh_prod = DBI->connect( 'DBI:ODBC:DSN, $username, $password)
> > > > > or die "Can't connect to $Prod_data_source: $DBI::errstr";
> > > >
> > > > I don't see anything wrong with it. Maybe windows doesn't like
> > > > using prepare/execute with an insert. Try this instead:
> > > >
> > > > $sql = qq{insert into ppp_admin.$table_name ('$columns') values
> > > > ('$result') };
> > > > $dbh_prod->do($sql) || die $dbh_prod->errstr;
> > >
> > > Replacing this :
> > > $dbh_prod->prepare($sql) || die $dbh_prod->errstr;
> > >
> > > with :
> > > $dbh_prod->do($sql) || die $dbh_prod->errstr;
> > >
> > > crashes the script.
> >
> > What did the crash say?
> >
> > Did you just replace that one line? The code piece I gave you should
> > have completely replaced the one you provided. There is no execute and
> > no finish.
> >
> > Instead of:
> > $sth = $dbh->prepare($sql);
> > $sth->execute;
> > $sth->finish
> >
> > You have:
> > $dbh->do($sql);
>
> Yes, did this:
> $dbh->do($sql);
>
> instead of this:
> $sth = $dbh->prepare($sql);
> $sth->execute;
> $sth->finish
>
> The script produced the following error then died:
> DBD::ODBC::db do failed: [Oracle][ODBC][Ora]ORA-00928:
> missing SELECT keyword (SQL-HY0000)(DBD: Execute immediate
> failed err=-1)
> at ....
>
> Using the 'execute' the loop would continue to process until complete.
> Using 'do' produces the above error then quits.
I have no idea unless there is something odd in one of those variables.
This is exactly the way I do all of my inserts. The only difference is that
I prefer to build my sql in arrays rather than strings.
@sql = ( "insert into ppp_admin.$table_name",
"( '$columns' )",
"values",
"( '$results' )",
);
$dbh->do("@sql");
I see no reason why this wouldn't work.
That being said, I've never tried it on Windows, or with odbc, so things may
be a bit different there.
You've reached the limit of my expertise. Maybe someone else has some
ideas.
Bowie
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs