Home Forums SQL Server 7,2000 T-SQL silly oracle query error( a headache) RE: silly oracle query error( a headache)

  • Well ... thanks!  I don't usually lose my patience with people, and I feel stupid for tooting my own horn, but I was a little frustrated with Sukhoi.  Thanks for helping me calm down! 

    By the way, the following Oracle snippet ...

    SELECT ...
    FROM ...,INTERMEDIARY,CODE_VALUE A,CODE_VALUE B,...
    Where ...
        AND INTERMEDIARY.INTERMEDIARY_TYPE(+)=A.CODE_VALUE_ID 
        AND INTERMEDIARY.OWNERSHIP(+)=B.CODE_VALUE_ID
        AND ...

    ... would translate to "old" T-SQL as ...

    SELECT ...
    FROM ...,INTERMEDIARY,CODE_VALUE A,CODE_VALUE B,...
    Where ...
        AND INTERMEDIARY.INTERMEDIARY_TYPE =* A.CODE_VALUE_ID 
        AND INTERMEDIARY.OWNERSHIP =* B.CODE_VALUE_ID
        AND ...

    ... which translates to ANSI JOIN SQL as something like ...

    SELECT ...
    FROM ...,INTERMEDIARY RIGHT JOIN CODE_VALUE A 
    ON INTERMEDIARY.INTERMEDIARY_TYPE = A.CODE_VALUE_ID 
    RIGHT JOIN CODE_VALUE B 
    ON INTERMEDIARY.OWNERSHIP = B.CODE_VALUE_ID...

    ... which is to say, I think the LEFTs and RIGHTs are switched in your translation.  The tie fighter looks like a plus sign because Oracle will add "null records" as needed to *that* side of the equal sign.  So when the tie fighter is on the RIGHT side of the equal sign, it's a LEFT join, and visa-versa.

    One problem with these formulations (as I've always understood them) is that it's not clear, when "null records" need to be invented for both tables A and B, whether there should be 1 or 2 "null records."  Does that make sense?  I think I said that right, but I'm in a hurry to leave the office (just stopped in to fix a firewall problem, and I have two kiddos with me who need to get to bed!).

    I reply partly because I'm curious as to whether or not your T-SQL query will still compile if you switch the left joins to right joins.  I am expecting that they won't (and that's what my last post was about, ranting aside).  The Oracle docs say that you can't generate "null records" for a given rowsource to match up with more than one other table in a query (which makes sense).  I know I've run into this problem in MS SQL also ... but if you can provide me with a counter-example by saying your query will work with the LEFTs switched to RIGHTs, I'll have learned something new!  So if you still have the rest of the script (I'm thinking table DDL here, in particular) ... would you mind giving it a shot?  Otherwise I can try it tonight or tomorrow.

    Thanks again,

    Chris