Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Cross Database Access not supported

by Bio_ftr (Initiate)
on Apr 28, 2015 at 01:09 UTC ( [id://1124943]=perlquestion: print w/replies, xml ) Need Help??

Bio_ftr has asked for the wisdom of the Perl Monks concerning the following question:

I am connecting to a netzezza database using ODBC. I have worked on this tiny bit of code for a few days and I keep getting an error:
DBD::ODBC::st execute failed: ERROR: Cross Database Access not supported for this type of command (SQL-HY000) at line 20.

Line 20 is $sth-> execute(). I am not crossing databases so I don't understand what is causing this error. I can replace the update statement with a select, and the program runs correctly.

This is the code:

use strict;
use warnings;
use DBI;
use DBD::ODBC;

DBI->trace(0);
my $dbh = DBI-> connect('dbi:ODBC:system', 'user', 'pwd') or die "Couldn't connect to database: " . DBI->errstr;

my $stmt= "update db_name.user.table_name set column_name= 8 where column_name2 like 'someValue'";
#my $stmt= "select column_name1, column_name2 from db_name.user.table_name where column_name2 like 'anotherValue'";

my $sth;
$sth = $dbh->prepare($stmt) or die "Couldn't prepare statement:". $dbh->errstr;
$sth-> execute() #Execute the query or die "Couldn't execute statement:".$dbh->errstr;
$sth->finish();
$dbh->disconnect;
use DBI;

Replies are listed 'Best First'.
Re: Cross Database Access not supported
by erix (Prior) on Apr 28, 2015 at 06:00 UTC

    It seems netezza cross-database access is readonly: it won't work in insert, update, or delete statements.

    At least that is what I conclude from this IBM doc page which says:

    "You cannot use a cross-database INSERT, UPDATE, or DELETE statements to change a table in a different, remote, database. If you attempt a cross-database write operation, the system displays an error message.

    For example:

    DEV.DBUSER(DBUSER)=>INSERT INTO prod..emp SELECT * FROM newusers; Cross Database Access not supported for this type of command."

    So I think you just have to remove the 'dbname.' part from the statement so that netezza won't think it is asked to do (illegal) cross database access.

    update: (Having no Netezza here, I tried to recreate the error on Postgres (on which Netezza was based albeit a long time ago [1]). Postgres doesn't have cross-database access at all, not even readonly. Postgres still shows a similar error message when asked to access another database:

    (Pg 9.5devel, HEAD dcbf5948e12a) $ psql -d testdb psql (9.5devel) Type "help" for help. testdb=# create table t(c text); CREATE TABLE testdb=# insert into t values ('value 1'); INSERT 0 1 testdb=# insert into test.public.t values ('value 3'); ERROR: cross-database references are not implemented: "test.public.t" LINE 1: insert into test.public.t values ('value 2');
    [1] https://wiki.postgresql.org/wiki/PostgreSQL_derived_databases

    )

Re: Cross Database Access not supported
by Anonymous Monk on Apr 28, 2015 at 01:44 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1124943]
Approved by marinersk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2024-04-25 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found