Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBD::Oracle::st execute failed: ORA-00933: SQL command not properly en

Status
Not open for further replies.
Dec 17, 2002
41
US
I am attempting to run a query in perl that will drop, create, and alter the tables of an Oracle DB. Below is a snippet of how I am doing one table. (Keep in mind, I'm actaully doing this to 21 tables) I used this Perl syntax to retrieve data from this database and write it to a file before and being the Perltard that I am, figured it would work to do some admin. things as well. The complete error I receive is:

"DBD::Oracle::st execute failed: ORA-00933: SQL command not properly ended (DBD ERROR: OCIStmtExecute) at This is where the directory goes\file_name.pl line 514."

Line 514 looks like this:
my $sth = $dbh->prepare( $sql );

This is an example of how I do one table:
#!perl -w
use strict;
use DBI;
use CGI qw/:standard/;

#Connect to Oracle database, making sure AutoCommit is
#turned off and potential errors are raised.

my $dbh = DBI->connect('dbi:Oracle:System', 'username', 'password', {RaiseError => 1,

AutoCommit => 0});

#Create the SQL.

my $sql = qq{DROP TABLE This_Table CASCADE CONSTRAINTS

CREATE TABLE FAQ_Table (
FT_This_NR NUMBER(5) NOT NULL,
This_QSTN VARCHAR2(250) NULL,
This_LINK VARCHAR2(50) NOT NULL,
This_DT_TM_UPDT VARCHAR2(19) NULL,
This_DT_TM_VRFD VARCHAR2(19) NOT NULL,
This_ATHR CHAR(18) NULL,
This_ANSWR CHAR(1000) NULL
)
TABLESPACE IS_STATIC



ALTER TABLE This_Table
ADD ( PRIMARY KEY (FT_This_NR) )
};

#Prepare the SQL and execute.

my $sth = $dbh->prepare( $sql );
$sth->execute();


$dbh->disconnect(); #Disconnect
 
I would do each statement separately, have you tried that?

Also -- I don't think you need to finish SQL statements with a ; when you're using The DBI. Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
:) Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top