Need help to solve db2 sqlcode=-204 [closed] - db2

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I create tables with data studio but when I try to access that table from java application, or db2 command console, I get -204 which means the object that I am trying to access is not defined. But in fact it is defined, because I am able to list the tables in db2 command console, but I am not able to select or insert into that table. Please help me if possible. I've already spent 1.5 day on this.

Let's suppose you are using the johndoe user.
How are you creating the tables?
create table myTable (col1 int)
Or like this
create table myschema.myTable (col1 int)
The first table will be created in the catalog as follow:
johndoe.myTable
The second one as
myschema.myTable
As you can see, if no schema is specified, the username will be used as schema.
You can check the tables currently created in db2 with this query
select varchar(tabschema,20), varchar(tabname, 20)
from syscat.tables
where tabschema not like 'SYS%'
In this way you will know what exist in the database.

Related

Can't add item in Postgres using pgAdmin [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 14 days ago.
Improve this question
I am trying to use Postgres with Django application.
I am using pgAdmin to manage Postgres database.
But I can't add new item to database using pgAdmin manually.
Once I typed data manually and clicked the save button, I got
ERROR: invalid input syntax for type uuid: "111"
LINE 3: '111'::uuid, 'asdfasdfdasf'::character varying)
^
Schema is just simple.
Just id and name in the table.
Please help me to fix the issue.
Thank you.
Try to add a default auto-generated value for your id field with the following commands:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
ALTER TABLE public.table_name
ALTER COLUMN "id" SET DEFAULT uuid_generate_v4();
After that, you need to populate only the name column.

psql select * from user returns sytem user instead of table content [duplicate]

This question already has an answer here:
Setting schema in PostgreSQL JDBC doesn't seem to work
(1 answer)
Closed 4 years ago.
I've a table named user ( gitea db).
when I try to
select * from user;
I'll get the currently active user instead of the table content.
As I could read, that's normal behavior cause defined like this by psql.
But how can I select the content of my gitea.user table ?
Even quoting "user" did not help.
user is a reserved keyword, so it is a bad idea to use it.
You can use the fully qualified name to refer to your table:
select * from gitea.user;

Insert a new column into the Foreign Key table when a particular column in the primary key table is Update (Using Triggers) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Being new to Triggers, I need some information to INSERT a new column into the Foreign Key table with the values from the Primary Key table, when an UPDATE is made in the primary key table (Only a particular column when it is updated).
I am working on a .NET project with SQL Server 2005.
Thank for the help.
Your question is rather non-specific, but here's an example of using a trigger to keep a parent table's (Table1) count of rows in an associated child table (Table2) up to date.
CREATE TRIGGER tTable2 ON Table2 FOR INSERT, DELETE
AS BEGIN
WITH cte AS
(
SELECT T1ID
FROM INSERTED
UNION
SELECT T1ID
FROM DELETED
)
UPDATE t1
SET t1.CountOfT2s = x.t2Count
FROM
Table1 t1
INNER JOIN
(
SELECT cte.T1ID, COUNT(t2.T2ID) AS t2Count
FROM cte
LEFT JOIN Table2 t2
ON t2.T1ID = cte.T1ID
GROUP BY cte.T1ID
) x
ON t1.T1ID = x.T1ID;
END;
SqlFiddle here

How could update the old row's value when I alter table add column and set default value [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How could update the old row's value when I alter table add column default value
type smallint NOT NULL DEFAULT 0
but old rows is still null, Why can't update to default value automatic?
Issue an update statement prior to the alter table statement in your transaction:
update table set col = 0 where col is null
Alter table won't update the data because it's not its job or responsibility; updating is update's job. (The only exception I'm aware is when you change a column's type, in which case you can toss in a using clause to transform the data as you need.)

Copy (or USE) data from two tables in different databases [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Possible to perform cross-database queries with postgres?
I don-t know how to use one table from one database and second table from another databse at the same time or copy data from table in one database to table from another databse.
I tried following query:
select * into NewTable from existingdb.dbo.existingTable;
But it doesnt't work.
In existing table name, specify the full path. that's database name and table table to be copied. In New table also specify the database name and table name or make sure the console is in same database.
Also verify both the tables have same table structure.
What is the exact error message? It would not work if NewTable already exists. Then you should type insert into NewTable select * from ExistingDb.dbo.ExistingTable.