DBI problem

DBI problem

am 21.09.2007 18:35:14 von francis.moore

Hi,

I'm no perl programmer, but I need to fix some perl code that was
serving some web pages correctly until recently. Since then the name
of a server has changed and we think that this is what is causing the
issue.

The error we get is:

Can't call method "prepare" on an undefined value at line 77...

Which is caused by these lines:

my $dbHandle = DBI->connect("dbi:Sybase:server=ODB;database=ABC",
'user', 'password', {PrintError => 1});
my $sqlStatement=$reports{$report}->{'query'};
my $stHandle = $dbHandle->prepare($sqlStatement);

We think it's because the value of the ODB variable (the db server)
has changed recently, but we can't find the definition of this
variable to check the current value or change it to the correct
servername.

Can anyone give me a hint as to where this variable is likely to be
defined?
It's not in this perl file and I've grepped all the nearby directories
but without any luck.
Or how to view it, i.e. using a print statement to a file

Many thanks,
Frank.

Re: DBI problem

am 21.09.2007 18:44:07 von xhoster

francis.moore@gmail.com wrote:
> Hi,
>
> I'm no perl programmer, but I need to fix some perl code that was
> serving some web pages correctly until recently. Since then the name
> of a server has changed and we think that this is what is causing the
> issue.
>
> The error we get is:
>
> Can't call method "prepare" on an undefined value at line 77...
>
> Which is caused by these lines:
>
> my $dbHandle = DBI->connect("dbi:Sybase:server=ODB;database=ABC",
> 'user', 'password', {PrintError => 1});
> my $sqlStatement=$reports{$report}->{'query'};
> my $stHandle = $dbHandle->prepare($sqlStatement);
>
> We think it's because the value of the ODB variable (the db server)
> has changed recently,

There is no $ODB variable in your code. The name of the server you
are attempting to connect to in the above code is the literal string "ODB",
not the value of some variable named $ODB.

If the name of your server is not "ODB", then change "ODB" to whatever
the name of your server is.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: DBI problem

am 21.09.2007 18:57:12 von francis.moore

Xho,

Thanks for your response.
But now I'm even more confused :-)
This web page was working until recently, when the DB server was
renamed.
However, the server has never been called ODB (although the server is
known colloquialy as the Operational DataBase, hence the initials ODB,
the servername is actually DCSVPA-09), so I can't see how it ever
worked.
And the fact that ODB is in uppercase makes me suspect that this is a
global variable of some sort.
I have to bow to your superior knowledge, but this just doesn't make
sense.
Could it be a DSN id or similar defined somewhere?
If so, I just don't know where to look.

Thanks again,
Frank.

Re: DBI problem

am 21.09.2007 19:02:38 von vbMark

francis.moore@gmail.com wrote:

> Xho,
>
> Thanks for your response.
> But now I'm even more confused :-)
> This web page was working until recently, when the DB server was
> renamed.
> However, the server has never been called ODB (although the server is
> known colloquialy as the Operational DataBase, hence the initials ODB,
> the servername is actually DCSVPA-09), so I can't see how it ever
> worked.
> And the fact that ODB is in uppercase makes me suspect that this is a
> global variable of some sort.
> I have to bow to your superior knowledge, but this just doesn't make
> sense.
> Could it be a DSN id or similar defined somewhere?
> If so, I just don't know where to look.
>
> Thanks again,
> Frank.


Have a look in your hosts file, is ODB in there?

--
Brian Wakem

Re: DBI problem

am 21.09.2007 19:19:30 von xhoster

francis.moore@gmail.com wrote:
> Xho,
>
> Thanks for your response.
> But now I'm even more confused :-)
> This web page was working until recently, when the DB server was
> renamed.
> However, the server has never been called ODB (although the server is
> known colloquialy as the Operational DataBase, hence the initials ODB,
> the servername is actually DCSVPA-09), so I can't see how it ever
> worked.

Someplace ODB is getting mapped to DCSVPA-09. I strongly suspect that
this mapping is not happening inside Perl proper. I think the Sybase
client API library (which Perl uses, but which isn't actually part of Perl)
has its own configuration file, something like sql.ini, which may contain
this mapping.


> And the fact that ODB is in uppercase makes me suspect that this is a
> global variable of some sort.
> I have to bow to your superior knowledge, but this just doesn't make
> sense.
> Could it be a DSN id or similar defined somewhere?

Yes, I think that is probably the case. But the "somewhere" is probably
not in Perl itself, nor in DBI, but in some external configuration.

> If so, I just don't know where to look.

You probably need to consult a Sybase expert, or maybe system administrator
for the system your client is running on.


Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: DBI problem

am 21.09.2007 19:27:12 von francis.moore

All,

I've found the ODB mapping in /etc/freetds.conf.
Changed the server name and it works again.

Many thanks to all that answered.
Frank.