PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Raju, Ramakrishna (Equity)" <ramakrishna_raju at ml dot com>
Subject: RE: error - object already exists in database
Date: Jun 20 2005 8:42PM

$server = "SERVER";
$user = "usr";
$pass = "passwd";
 
use DBI;
 
do_command(' create table test_create ( i int )' );
 
sub do_command {
            my $sql_command = shift;
            my $dbh = DBI->connect('DBI:Sybase:server='. $server, $user, $pass, {RaiseError=>1, AutoCommit=>1})
              or die "Couldn't connect to database: " . DBI->errstr;
 
            $dbh->do($sql_command);
            $dbh->disconnect();
}

    The above program works for me. Replace the server, user and password with valid values and run in your environment.
 
Raju

-----Original Message-----
From: owner-sybperl-l@peppler.org [mailto:owner-sybperl-l@peppler.org]On Behalf Of Alan Humphrey
Sent: Monday, June 20, 2005 4:26 PM
To: 'Barlow, Ed'; sybperl-l@peppler.org
Subject: RE: error - object already exists in database



Good thought, but not it.  I made sure to drop the table before re-running the perl script.  In fact, in part of my experimenting I even dropped and recreated the database.  That worked, creating the table did not.

 

- Alan

 

-----Original Message-----
From: Barlow, Ed [mailto:ebarlow@mlp.com] 
Sent: Monday, June 20, 2005 12:24 PM
To: Alan Humphrey; sybperl-l@peppler.org
Subject: RE: error - object already exists in database

 

            Alan

            You need to drop the table "Drop Table abundancies" prior to recreating it

            Obviously, you ran it once in query analyzer, creating the table, and the second run is the one that fails...

            Ed

 

-----Original Message-----
From: owner-sybperl-l@peppler.org [mailto:owner-sybperl-l@peppler.org] On Behalf Of Alan Humphrey
Sent: Monday, June 20, 2005 4:19 PM
To: sybperl-l@peppler.org
Subject: error - object already exists in database

 

I'm trying to create tables via my Perl script, working against a remote database.  The error returned is:

 

DBD::Sybase::db do failed: Server message number=2714 severity=16 state=6 line=1 server=GILGAMESH\BIRDWEB text=There is already an object named 'abundancies' in the database. at sql_server.pl line 74,  chunk 1.

 

The SQL being executed is:

 

CREATE TABLE  abundancies (

        bird_id integer not null,

        ecoregion_id integer not null,

        abundancy_notes text,

        january char(1),

        february char(1),

        march char(1),

        april char(1),

        may char(1),

        june char(1),

        july char(1),

        august char(1),

        september char(1),

        october char(1),

        november char(1),

        december char(1),

        PRIMARY KEY (bird_id, ecoregion_id)

)

 

The code looks like:

 

sub do_command {

            my $sql_command = shift;

            

            my $dbh = DBI->connect('DBI:Sybase:server='. $server, $user, $pass, {RaiseError=>1, AutoCommit=>1})

              or die "Couldn't connect to database: " . DBI->errstr;

 

            $dbh->do($sql_command);

 

            $dbh->disconnect();

}

 

The reason I'm posting to this list is that if I execute the same command from other tools (e.g. Query Analyzer) it works.

 

Any ideas?

 

- Alan
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.     http://www.ml.com/email_terms/
--------------------------------------------------------