Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:31:10+00:00 2026-05-14T07:31:10+00:00

Im having a very strange problem, i have a complicated view that returns incorrect

  • 0

Im having a very strange problem, i have a complicated view that returns incorrect data when i query on a particular column.
heres an example:

select empname
       , has_garnishment 
from timecard_v2 
where empname = 'Testerson, Testy';

this returns the single result ‘Testerson, Testy’, ‘N’

however, if i use the query:

select empname
       , has_garnishment 
from timecard_v2 
where empname = 'Testerson, Testy'
and has_garnishment = 'Y';

this returns the single result ‘Testerson, Testy’, ‘Y’

The second query should return a subset of the first query, but it returns a different answer.

When I use the query:

select empname
       , has_garnishment 
from timecard_v2 
where empname = 'Testerson, Testy'
and has_garnishment = 'N';

I get no results

I have dissected the view and determined that this section of the view definition is where the problem arises and the problem exists even if i take the sql definition and run it as a straight query(Note, I removed all of the select clause except the parts of interests for clarity, in the full query all joined tables are required):


SELECT 
  e.fullname empname ,
  NVL2(ded.has_garn, 'Y', 'N') has_garnishment
FROM timecard tc ,
  orderdetail od ,
  orderassign oa ,
  employee e ,
  employee3 e3 ,
  customer10 c10 ,
  order_misc om,
  (SELECT COUNT(*) has_garn,
    v_ssn
  FROM deductions
  WHERE yymmdd_stop                             = 0
  OR (LENGTH(yymmdd_stop)                       = 7
  AND to_date(SUBSTR(yymmdd_stop, 2), 'YYMMDD') > sysdate)
  GROUP BY v_ssn
  ) ded
WHERE oa.lrn(+) = tc.lrn_order
AND om.lrn(+)   = od.lrn
AND od.orderno  = oa.orderno
AND e.ssn       = tc.ssn
AND c10.custno  = tc.custno
AND e.lrn       = e3.lrn
AND e.ssn       = ded.v_ssn(+)

One thing of note about the definition of the ‘ded’ subquery. The v_ssn field is a virtual field on the deductions table.

I am not a DBA im a software developer but we recently lost our DBA and the new one is still getting up to speed so im trying to debug this issue. That being said, please explain things a little more thoroughly then you would for a fellow oracle expert.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:31:10+00:00Added an answer on May 14, 2026 at 7:31 am

    Turns out the problem was a conflicting index. There was an old index on the column that the v_ssn virtual column is built from. I dropped that index and the query began behaving as expected. Im still concerned about how that index was affecting the query but at least my immediate problem is solved.

    Thanks for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.