Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with an SQL update statement - Urgent

Status
Not open for further replies.

sarcophil

Programmer
Jun 14, 2006
8
NO
Hello, we are using Sybase ASA9 for our application
database. We are now in the process of upgrading our
application, and in that respect we have created a
table "maker". This is filled from a previous Vendor table, so that there are unique names. The ID's are NULL.

So therefore we want to create the ID's. One of our programmers have come up with an SQL, which works on our old database (Sybase 5.5) but in ASA9 it fails. And we're not able to see what is the error.

Here is the SQL:

UPDATE DBA.maker w
SET id_maker = (
(SELECT (count(y.name))
FROM maker x, maker y
WHERE w.name = x.name AND
(x.name) >=
(y.name) AND y.id_maker is null
GROUP BY (x.name )) + (SELECT IsNull(general_id,0) FROM sys_variables))
WHERE id_maker is null;

In 5.5 it goes through the table, and fills in unique
id's on every post, but in ASA9 a lot of the id's are equal. I guess it is a small change, but I cant find it.

We tried using a cursor, but that caused our replication to crash.

Please help.

Thank you
 
SOLVED - It was easy, when you found the error :)

It was supposed to have "AND x.id_maker is null" instead of "AND y.id_maker is null".

Best of luck to you all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top