niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
problem with minus operator ...
Post new topic   Reply to topic Page 1 of 1 [6 Posts] View previous topic :: View next topic
Author Message
bravegag
*nix forums beginner


Joined: 12 Apr 2006
Posts: 16

PostPosted: Thu Jun 22, 2006 8:03 am    Post subject: problem with minus operator ... Reply with quote

Hi all,

I can't help but to get continously frustrated with Sybase i.e.
something fairly simple as:

select *
from table_1
minus
select *
from copy_of_table_1

works but does not give me the needed results ... guess what, the
order is missing:

select *
from table_1
order by the_pk
minus
select *
from copy_of_table_1
order by the_pk

Produces: Number (102) Severity (15) State (1) Server ... Incorrect
syntax near 'minus'

I get the same or other errors if I try:

(select *
from table_1
order by the_pk)
minus
(select *
from copy_of_table_1
order by the_pk)

or

select *
from (select * from table_1 order by the_pk)
minus
select *
from (select * from copy_of_table_1 order by the_pk)

etc etc

I am praying for the project to be moved to Oracle ... Sybase sucks!

Is there any chance that I a doing something wrong here? I dont think
so ... but who knows ...

Thanks in advance,
Best Regards,
Giovanni
Back to top
ZeldorBlat
*nix forums Guru Wannabe


Joined: 01 Mar 2005
Posts: 272

PostPosted: Thu Jun 22, 2006 1:11 pm    Post subject: Re: problem with minus operator ... Reply with quote

bravegag wrote:
Quote:
Hi all,

I can't help but to get continously frustrated with Sybase i.e.
something fairly simple as:

select *
from table_1
minus
select *
from copy_of_table_1

works but does not give me the needed results ... guess what, the
order is missing:

select *
from table_1
order by the_pk
minus
select *
from copy_of_table_1
order by the_pk

Produces: Number (102) Severity (15) State (1) Server ... Incorrect
syntax near 'minus'

I get the same or other errors if I try:

(select *
from table_1
order by the_pk)
minus
(select *
from copy_of_table_1
order by the_pk)

or

select *
from (select * from table_1 order by the_pk)
minus
select *
from (select * from copy_of_table_1 order by the_pk)

etc etc

I am praying for the project to be moved to Oracle ... Sybase sucks!

Is there any chance that I a doing something wrong here? I dont think
so ... but who knows ...


Put your order by after the second part of the query only. Just like
union and insersect.
Back to top
bravegag
*nix forums beginner


Joined: 12 Apr 2006
Posts: 16

PostPosted: Thu Jun 22, 2006 4:20 pm    Post subject: Re: problem with minus operator ... Reply with quote

ZeldorBlat wrote:
Quote:
Put your order by after the second part of the query only. Just like
union and insersect.

But that's not what I need though, in order to get reliable minus both

sets need to be equally ordered. I dont want to order *after* the minus
operator has been applied ... that's not what I need ...

Thanks for your will to help anyway.

Best Regards,
Giovanni
Back to top
Carl Kayser
*nix forums beginner


Joined: 25 May 2005
Posts: 42

PostPosted: Thu Jun 22, 2006 4:31 pm    Post subject: Re: problem with minus operator ... Reply with quote

"bravegag" <bravegag@gmail.com> wrote in message
news:1150993229.342528.105770@m73g2000cwd.googlegroups.com...
Quote:

ZeldorBlat wrote:
Put your order by after the second part of the query only. Just like
union and insersect.

But that's not what I need though, in order to get reliable minus both
sets need to be equally ordered.

Huh? Relational theory works with sets and sets are unordered. I suspect
that you are (somehow) viewing the SQL with a mindset of "procedural logic".
Can you provide an example where you would get an unreliable result set?

I dont want to order *after* the minus
Quote:
operator has been applied ... that's not what I need ...

Thanks for your will to help anyway.

Best Regards,
Giovanni
Back to top
Mark A. Parsons
*nix forums beginner


Joined: 18 May 2005
Posts: 17

PostPosted: Thu Jun 22, 2006 5:13 pm    Post subject: Re: problem with minus operator ... Reply with quote

I'm not familiar with the 'minus' operator ... at least not in Sybase ASE.

What version of the Sybase dataserver are you running? (select @@version)

In the meantime, if your objective is pull everything from table_1 which
does not exist in copy_of_table_1 (based solely on a primary key) ... and
assuming your primary key is a column called 'pk' ... try:

select t1.*
from table_1 t1
where not exists(select c1.pk
from copy_of_table_1 c1
where c1.pk = t1.pk)

If on the other hand you have matching pk's in both tables but you're
looking for differences in individual column values ... you could try
something like:

select t1.*
from table_1 t1
where not exists(select c1.pk
from copy_of_table_1 c1
where c1.pk = t1.pk
and c1.col1 = t1.col1
and c1.col2 = t1.col2
and ...)

-----------------------

As for the comment about 'Sybase sucks' ... *shrug* ... I know of
situations where Oracle sucks ... MSSQL sucks (different from MS OS's suck!
Wink ... DB2 sucks ... and on and on and on and on ...

If you have a background of working with one product (eg, Oracle) and then
find yourself having to start over from (relative) scratch with another
product (eg, Sybase) ... yeah, the switch itself sucks ... and learning the
differences between PL/SQL and T-SQL will suck ... and if you're not
able/willing to take the time to learn how to use the new product properly
then life in general will appear to suck ...

I've found that Oracle has a lot of features that make life easier for the
developer but (somewhat) tougher for the DBA ... while Sybase features tend
to make life easier for the DBA while requiring the developer to do a bit
more work ... ymmv ...

bravegag wrote:

Quote:
Hi all,

I can't help but to get continously frustrated with Sybase i.e.
something fairly simple as:

select *
from table_1
minus
select *
from copy_of_table_1

works but does not give me the needed results ... guess what, the
order is missing:

select *
from table_1
order by the_pk
minus
select *
from copy_of_table_1
order by the_pk

Produces: Number (102) Severity (15) State (1) Server ... Incorrect
syntax near 'minus'

I get the same or other errors if I try:

(select *
from table_1
order by the_pk)
minus
(select *
from copy_of_table_1
order by the_pk)

or

select *
from (select * from table_1 order by the_pk)
minus
select *
from (select * from copy_of_table_1 order by the_pk)

etc etc

I am praying for the project to be moved to Oracle ... Sybase sucks!

Is there any chance that I a doing something wrong here? I dont think
so ... but who knows ...

Thanks in advance,
Best Regards,
Giovanni
Back to top
--CELKO--
*nix forums Guru Wannabe


Joined: 01 Jun 2005
Posts: 122

PostPosted: Fri Jun 23, 2006 12:34 pm    Post subject: Re: problem with minus operator ... Reply with quote

MINUS is a proprietary Oracle syntax. The Standard SQL version is
EXCEPT [ALL}. Since tables have no ordering by definition, parts of
this posting make no sense. This is SQL and not sequential tape file
merging.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [6 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 2:41 pm | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Unknown in header problem -SOLVED- Light Speed Postfix 0 Thu Jul 03, 2008 10:40 am
No new posts problem with sending mail nuxia Postfix 0 Mon Apr 21, 2008 3:58 am
No new posts Postfix 2.3.8 Virtual problem Blotto Postfix 0 Fri Apr 04, 2008 6:11 am
No new posts Postfix sending problem for local domain remote email monkey_magix Postfix 0 Mon Sep 10, 2007 10:17 am
No new posts bounce problem murkis Postfix 0 Sun Oct 08, 2006 3:45 pm

Mortgages | Homes for Sale | Problem Mortgage | 2008 Air Jordan Release Dates | Books
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2659s ][ Queries: 16 (0.1727s) ][ GZIP on - Debug on ]