× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thatnks for that explanation, Tim.  In a related question: do CTEs allow me to effectively "hardcode" the order, causing the SQL engine to work in my predefined sequence?

For example, if in this case I did this:

    with t1 as (select * from contr where length(trim(cpcsid)) = 10),
      t2 as (select a.cpcono cono, case ... end csno from t1)
        select * from t2 where csno = 1346100

Would that force the SQL engine to create my T1 in its entirety (thus skipping short fields) before then doing the select?  Or is the engine just so darned smart that it ignores my sequence and just optimizes me into errors?  Of course, upon further reflection, if length(trim(cpcsid)) = 10, then no need to check for blanks, so no CASE statement.  But I digress...


On 5/16/2019 4:36 PM, Timothy P Clark wrote:
You can think of the query engine "inlining" the view into the final
select statement.

<...snip lots of relevant and cool stuff...>


Keeping in mind that SQL has no rules about predicate evaluation order, it
should be clear that if the optimizer chooses to evaluate the 2nd
predicate before the first predicate, we can run into the error you're
seeing.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.