UPDATE statement doesn't work...

UPDATE statement doesn't work...

Post by Pierluigi Buonicor » Sat, 28 Feb 1998 04:00:00



Hello there,
I am running SQl_server 6.5  through ODBC from a C++ application.
I tryed to execute the following SQl statement :

UPDATE tableA, tableB
 SET  tableA.UserName = tableB.NewName
 WHERE tableA.Name = tableB.OldName;

but it doesn't work with SQL_Server. It works fine with MS-Access.
I know that It is not a stadard SQL statement but I cannot figure out how to
convert it into standard SQL without using cursors.

So I was wondering if someone can help me out with the followings:

1. how can I convert the aforementiond statement into standard SQL
2. How can I use cursors with ODBC

Thanks a lot.

Pierluigi.

 
 
 

UPDATE statement doesn't work...

Post by Jan Branberge » Sun, 01 Mar 1998 04:00:00


whats the problem exactly, it won't return an error but
the update is not made ??

check if your auto-commit for your particular session
is set to on (just guessing ...)
+
there rings a bell: mssql could have an extended UPDATE statement:
check out the sql-books(look at the examples..)

hth


>Hello there,
>I am running SQl_server 6.5  through ODBC from a C++ application.
>I tryed to execute the following SQl statement :

>UPDATE tableA, tableB
> SET  tableA.UserName = tableB.NewName
> WHERE tableA.Name = tableB.OldName;

>but it doesn't work with SQL_Server. It works fine with MS-Access.
>I know that It is not a stadard SQL statement but I cannot figure out how
to
>convert it into standard SQL without using cursors.

>So I was wondering if someone can help me out with the followings:

>1. how can I convert the aforementiond statement into standard SQL
>2. How can I use cursors with ODBC

>Thanks a lot.

>Pierluigi.


 
 
 

UPDATE statement doesn't work...

Post by Randy Charles Mori » Mon, 02 Mar 1998 04:00:00


Try...

UPDATE tableA
SET tableA.UserName =
        ( SELECT tableB.NewName
        FROM tableB
        WHERE tableA.Name = tableB.OldName )

I hope this helps.  
--

MiddleWorld SoftWare - http://web2.ica.net/middleworld
--------------------------------------------------
He went out of his way to be good.



Quote:> Hello there,
> I am running SQl_server 6.5  through ODBC from a C++ application.
> I tryed to execute the following SQl statement :

> UPDATE tableA, tableB
>  SET  tableA.UserName = tableB.NewName
>  WHERE tableA.Name = tableB.OldName;

> but it doesn't work with SQL_Server. It works fine with MS-Access.
> I know that It is not a stadard SQL statement but I cannot figure out how
to
> convert it into standard SQL without using cursors.

> So I was wondering if someone can help me out with the followings:

> 1. how can I convert the aforementiond statement into standard SQL
> 2. How can I use cursors with ODBC

> Thanks a lot.

> Pierluigi.

 
 
 

UPDATE statement doesn't work...

Post by Ben McEw » Mon, 02 Mar 1998 04:00:00



says...

Quote:> Hello there,
> I am running SQl_server 6.5  through ODBC from a C++ application.
> I tryed to execute the following SQl statement :

> UPDATE tableA, tableB
>  SET  tableA.UserName = tableB.NewName
>  WHERE tableA.Name = tableB.OldName;

Note that both yours and mine are non-ANSI syntax:

update tableA
from   tableA a join tableB b on a.Name = b.OldName
set    a.UserName = b.NewName

Semicolons are not recognized or used in MS's T-SQL.
--
Ben McEwan, President, Geist, LLC

 
 
 

UPDATE statement doesn't work...

Post by Michael Yocc » Sat, 07 Mar 1998 04:00:00


Isn't the from clause supposed to be after the set and the where
after the from to do the join?  This is the way I've always done it.

-my



>> Hello there,
>> I am running SQl_server 6.5  through ODBC from a C++ application.
>> I tryed to execute the following SQl statement :

>> UPDATE tableA, tableB
>>  SET  tableA.UserName = tableB.NewName
>>  WHERE tableA.Name = tableB.OldName;

>Note that both yours and mine are non-ANSI syntax:

>update tableA
>from   tableA a join tableB b on a.Name = b.OldName
>set    a.UserName = b.NewName

>Semicolons are not recognized or used in MS's T-SQL.
>--
>Ben McEwan, President, Geist, LLC


 
 
 

1. prepared statement update doesn't work

I'm using Oracle 8 with the thin Oracle driver 8.0.4.0.5 in a Java
application.
I create a prepared statement to insert a row, then create a prepared
statement
to update the same row. The insert works, but the update does not, with
no
exceptions thrown. Is there a problem using prepared statements with
Oracle's
thin driver?

Thanks,
Mary

  String query = new String("insert into " + tableName +
      " values(?,?,?,?,?,?,?,?,?,?)");
  PreparedStatement pstmt = db_conn.prepareStatement(query);
  /* set values here */
  pstmt.executeUpdate();

  String query = new String("update " + tableName +
      " set order = ?, status  = ?" +
      " where login = ? and key = ?");
  PreparedStatement pstmt = db_conn.prepareStatement(query);
  /* set values here */
  pstmt.executeUpdate();

2. Job Opportunity

3. AS400 ADO problem.

4. Scheduling DTS doesn't fail but doesn't work

5. Informix/JDBC problem

6. ORACLE DOESN'T COMPLY TO BASIC STANDARD SQL: SIMPLE QUERIES DOESN'T WORK

7. Incremental Processing and Virtual Dimensions

8. SQL statement doesn't work

9. select top n statement doesn't work - MS SQL7 SP1

10. TOP statement doesn't work on upgraded servers

11. SQL statement doesn't work but no error

12. ADO - SQL statement that contains REPLACE doesn't work