Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Oracle / Oracle Server / July 2005

Tip: Looking for answers? Try searching our database.

UPDATE problem - FROM Clause not supported in Oracle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dsriva - 26 Jul 2005 15:53 GMT
Hi,
I want to have a single statement to work on both sql server and
oracle, but am not able to convert the following to do so.
I am trying to update a column

UPDATE field_char f SET maxLength = 254

FROM field_char fc, arschema s

WHERE f.fieldid IN('2', '4', '5', '101', '105', '117', '118')

AND (s.schemaId = fc.schemaId)

AND (s.schemaType = 1)

But it seems that the FROM clause is not supported in Oracle,

Thanks for any help
dsriva
Maxim Demenko - 26 Jul 2005 16:09 GMT
dsriva schrieb:
> Hi,
> I want to have a single statement to work on both sql server and
> oracle,
In most cases a bad idea (IMHO)
but am not able to convert the following to do so.
> I am trying to update a column
>
[quoted text clipped - 12 lines]
> Thanks for any help
> dsriva

Seems me too...
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_100
07.htm#i2112182


Best regards

Maxim
fitzjarrell@cox.net - 26 Jul 2005 16:26 GMT
Comments embedded.
> Hi,
> I want to have a single statement to work on both sql server and
> oracle,

You can't always get what you want.

> but am not able to convert the following to do so.
> I am trying to update a column
[quoted text clipped - 10 lines]
>
> But it seems that the FROM clause is not supported in Oracle,

Possibly because it's a different DBMS engine?  SQL Server implements
UPDATE one way, Oracle another.  Get used to such things, as SQL isn't
SQL just because it's SQL.  Each vendor decides what and how to
implement functionality from the SQL standard and no two vendors decide
on exactly the same features or the same methodology:

SQL Server:

select top 10 userId from user_access where accessLevel = 20

Oracle:

select a.userid from (select rownum r, userid from user_access where
accesslevel = 20) where r < 11;

Stop trying to make SQL Server into Oracle and Oracle into SQL Server.
All you'll end up with in return is a migraine, an ulcer and code that
isn't optimised for any DBMS.

> Thanks for any help
> dsriva

David Fitzjarrell
Mark D Powell - 26 Jul 2005 21:12 GMT
Dsriva, I do not believe that the FROM clause is part of the ANSI
standard for an UPDATE statement.  Regardless, I believe you want
something like the following:

update field_char f
set maxLength = 254
where f.fieldid in ('2','4','5','101',117','118')
and exists (select s.schemald
                from arschema s
                where s.schemald = f.schemald
                and s.schema_type = 1)

You might want to try this version in SQL Server.

HTH -- Mark D Powell --
David Portas - 27 Jul 2005 23:18 GMT
> Hi,
> I want to have a single statement to work on both sql server and
[quoted text clipped - 15 lines]
> Thanks for any help
> dsriva

If you need to work across platforms then avoid propritary features. The
standard SQL update statement doesn't have a FROM clause or aliases for the
target table. The following tested on SQL2000.

UPDATE field_char
SET maxlength = 254
WHERE fieldid IN ('2', '4', '5', '101', '105', '117', '118')
 AND EXISTS
  (SELECT *
   FROM arschema AS S
   WHERE S.schemaid = field_char.schemaid
    AND S.schematype = 1) ;

Signature

David Portas
SQL Server MVP
--

Sybrand Bakker - 27 Jul 2005 23:44 GMT
>If you need to work across platforms then avoid propritary features.

If you want to get a working application under Oracle, ignore this
advice.

--
Sybrand Bakker, Senior Oracle DBA
David Portas - 29 Jul 2005 18:38 GMT
>>If you need to work across platforms then avoid propritary features.
>
[quoted text clipped - 3 lines]
> --
> Sybrand Bakker, Senior Oracle DBA

You mean Oracle can't support Standard SQL92? I accept that you'll need
proprietary features in the physical implementation and for procedural code
but surely straight DML ought to be portable.

Signature

David Portas
SQL Server MVP
--

David Portas - 29 Jul 2005 18:39 GMT
>>If you need to work across platforms then avoid propritary features.
>
[quoted text clipped - 3 lines]
> --
> Sybrand Bakker, Senior Oracle DBA

You mean Oracle can't support Standard SQL92? I accept that you'll need
proprietary features in the physical implementation and for procedural code
but surely straight DML ought to be portable.

Signature

David Portas
SQL Server MVP
--

Sybrand Bakker - 29 Jul 2005 20:27 GMT
>You mean Oracle can't support Standard SQL92? I accept that you'll need
>proprietary features in the physical implementation and for procedural code
>but surely straight DML ought to be portable.

I mean people like you seem to think SQL server is the standard, and
SQL server code will run unaltered on Oracle. Do you know how many
sites suffer from that assumption?
Do you know how many DBAs tear their hair out because that assumption
from the Evil Empire aka Microsoft?

Oracle != Sqlserver.

As for the standard, usually there are several levels in the standard.
Oracle usually complies to the entry level.

--
Sybrand Bakker, Senior Oracle DBA
David Portas - 30 Jul 2005 12:39 GMT
>>You mean Oracle can't support Standard SQL92? I accept that you'll need
>>proprietary features in the physical implementation and for procedural
[quoted text clipped - 14 lines]
> --
> Sybrand Bakker, Senior Oracle DBA

> I mean people like you seem to think SQL server is the standard, and
> SQL server code will run unaltered on Oracle.

I'm aware of the ways in which SQL Server differs from standard SQL. The
code I posted is compliant with entry level SQL-92.

Signature

David Portas
SQL Server MVP
--

Matthias Hoys - 30 Jul 2005 12:51 GMT
> Hi,
> I want to have a single statement to work on both sql server and
[quoted text clipped - 15 lines]
> Thanks for any help
> dsriva

What's the point of doing this ? Are you developing a database-independent
application ? I would say : bad idea. You should use the optimal features
for both engines. Also, SQL features can change between versions. Database
independent development leads to performance and scalability problems. One
example : to create a table with sequence numbers instead of using
autonumbers (SQL Server) or sequences (Oracle).

Matthias
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.