473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

SQL error 204 when we try to access tables via alias

Hi. We have almost all our tables defined on library lib1 and some on
lib2. We have alias defined on lib1 to access tables on lib2 so there
is no need to qualify library name. Alias for tables on lib2 are
defined this way:

CREATE ALIAS lib1.table1 FOR lib2.table1;

Both table owner and alias owner is the same. Tables reside on a
AS/400 server and we are accesing database from a DB2 client on a PC
workstation (DB2 is version 7)

When we try to access one of these tables (for example select * from
table1) we get error

SQL0204N "OWNER .TABLE1" is an undefined name. SQLSTATE=42704

Where OWNER is the name of the table/alias owner.

We have no problem if we qualify the library name where alias is
defined (select * from lib1.table1). There is no need to qualify
library name for tables on lib1.

Any ideas?

Thanks in advance.
Nov 12 '05 #1
5 9633
Hi,
Is enough privileges availables for both the libraries to access the
other library's object?

Cheers,
Thiru

Nov 12 '05 #2
Santiago Ordax Solivellas wrote:
Hi. We have almost all our tables defined on library lib1 and some on
lib2. We have alias defined on lib1 to access tables on lib2 so there
is no need to qualify library name. Alias for tables on lib2 are
defined this way:

CREATE ALIAS lib1.table1 FOR lib2.table1;

Both table owner and alias owner is the same. Tables reside on a
AS/400 server and we are accesing database from a DB2 client on a PC
workstation (DB2 is version 7)

When we try to access one of these tables (for example select * from
table1) we get error

SQL0204N "OWNER .TABLE1" is an undefined name. SQLSTATE=42704

Where OWNER is the name of the table/alias owner.

We have no problem if we qualify the library name where alias is
defined (select * from lib1.table1). There is no need to qualify
library name for tables on lib1.

Any ideas?


I don't quite understand your question. A table is uniquely identified by
its schema name, combined with the table name. If no explicit schema name
is given, then DB2 will consult a so-called special register named CURRENT
SCHEMA. Per default, the value in that special register is set to the name
of the user who connected to the database.

In the above examples, the schema name used to find the tables is OWNER,
lib1, or lib2. Do you actually want to do away with the schemas
alltogether?

Personally, I'd recommend to _always_ qualify your table names explicitly
with schema names. I don't see a good reason speaking against it, and it
does make things clearer.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3
To Thiru:
Hi,
Is enough privileges availables for both the libraries to access the
other library's object?

Cheers,
Thiru
Well, if you are talking about the privileges granted to the users
that have the same name as the library, lib1 user has enough
privileges on lib2 library. There is no lib2 user.

To Knut:

Knut Stolze <st****@de.ibm.com> wrote in message > I don't quite understand your question. A table is uniquely identified by its schema name, combined with the table name. If no explicit schema name
is given, then DB2 will consult a so-called special register named CURRENT
SCHEMA. Per default, the value in that special register is set to the name
of the user who connected to the database.

In the above examples, the schema name used to find the tables is OWNER,
lib1, or lib2. Do you actually want to do away with the schemas
alltogether?

Personally, I'd recommend to _always_ qualify your table names explicitly
with schema names. I don't see a good reason speaking against it, and it
does make things clearer.


We are using an user with the same name as the library lib1, so the
user in the above examples is lib1.

We are developing and testing or programs on PC workstations and
accessing database on a AS/400 host via DB2 connect. Once the programs
are finished they are generated to host where they run. We do not
qualify table names on our programs cause we want them to use the
database library the AS/400 user has defined in his library list.

There is no problem with alias once the programs are running on the
AS, our problem is when accessing via DB2 connect with our developing
tool or any DB2 client.

Thanks both
Nov 12 '05 #4
The error message refers to the statement you wrote, not the aliases. The
statement:
select * from table1
qualifies table1 with the current schema or owner as determined by the
statement's context.

You must either qualify the table (as Knut recommends), or specify an
alternative default . I use qualification for ad-hoc SQL, and the
precompiler QUALIFIER option with unqualified names in embedded SQL.

"Santiago Ordax Solivellas" <sa********@yahoo.com> wrote in message
news:cc**************************@posting.google.c om...
To Thiru:
Hi,
Is enough privileges availables for both the libraries to access the
other library's object?

Cheers,
Thiru


Well, if you are talking about the privileges granted to the users
that have the same name as the library, lib1 user has enough
privileges on lib2 library. There is no lib2 user.

To Knut:

Knut Stolze <st****@de.ibm.com> wrote in message > I don't quite
understand your question. A table is uniquely identified by
its schema name, combined with the table name. If no explicit schema
name
is given, then DB2 will consult a so-called special register named
CURRENT
SCHEMA. Per default, the value in that special register is set to the
name
of the user who connected to the database.

In the above examples, the schema name used to find the tables is OWNER,
lib1, or lib2. Do you actually want to do away with the schemas
alltogether?

Personally, I'd recommend to _always_ qualify your table names explicitly
with schema names. I don't see a good reason speaking against it, and it
does make things clearer.


We are using an user with the same name as the library lib1, so the
user in the above examples is lib1.

We are developing and testing or programs on PC workstations and
accessing database on a AS/400 host via DB2 connect. Once the programs
are finished they are generated to host where they run. We do not
qualify table names on our programs cause we want them to use the
database library the AS/400 user has defined in his library list.

There is no problem with alias once the programs are running on the
AS, our problem is when accessing via DB2 connect with our developing
tool or any DB2 client.

Thanks both

Nov 12 '05 #5
Lets see, table1 is the table i want to access on lib2, and alias1 is
the alias i have on lib1 pointing to lib2.table1. If I...

connect to database user lib1 using password

and then

select * from alias1

it should look for lib1.alias1 (the alias) as it do with normal tables
on lib1 but it fails and it seems its looking for owner.alias1, but if
i

select * from lib1.alias1

it works!

Why does it put "lib1" as the default schema for tables and "owner" as
the default schema for aliases???

I cannot qualify tables cause programs must run non qualified on
target environment.
"Mark Yudkin" <my***********************@boing.org> wrote in message news:<ct**********@ngspool-d02.news.aol.com>...
The error message refers to the statement you wrote, not the aliases. The
statement:
select * from table1
qualifies table1 with the current schema or owner as determined by the
statement's context.

You must either qualify the table (as Knut recommends), or specify an
alternative default . I use qualification for ad-hoc SQL, and the
precompiler QUALIFIER option with unqualified names in embedded SQL.

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James Foreman | last post by:
We have 5 users of our database (DB2 UDB 8.1 on SuSE linux) : db2inst1 bill fred sarah jessica The tables are created under db2inst1, which has the ability to drop/create/alter/etc. bill,...
4
by: shaun palmer | last post by:
when or Where do you use a union query ? how can I wright sql, tblPopulation,* tblcustomer,* one to one with all the appropriate attributes(field). Your help would be greatly...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: sbowman | last post by:
I'm linking a bunch of tables that are in SQL to my Access db and I get the following error on 3 of the tables: "Seq.Group is not a valid name." I tried doing an import instead of a link, but I got...
4
by: lspoulin | last post by:
Hi, We have a webpage browsing folders within the wwwroot. We need to access a remote shared directory the same way. We created a virtual directory in IIS with an alias pointing on this...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.