troubleshooting Question

ORA-00932 inconsistant data types - I have 2 queries in pass thro SQL one works and the other does not?

Avatar of PNickJames
PNickJamesFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft AccessEnterprise SoftwareSQL
6 Comments1 Solution634 ViewsLast Modified:
I have 2 queries on a booking system for an id card with a photo(a blob) report. The first query here works fine. But I was asked to add the maximum expiry date from another table for each person. So I added the code I needed to do this. But now it seems I get an error with part of the code that was already working. Has anyone got any ideas of what I'm doing wrong here or if there's any syntax I might be missing?

Query one:
======================================================
select
   p.person_code,
   p.surname,
   p.forename,
 nvl(p.fes_user_6, 'n/a') BUS,
  CASE WHEN (to_date(sysdate) - to_date(p.date_of_birth)) /365.25 < 18 THEN to_char(p.date_of_birth,'dd/mm/yyyy') ELSE 'Over 18' END DOB,
(CASE WHEN b.id IS NOT NULL THEN
          (CASE WHEN (substr(webadminpkg.get_web_setting('PhotoSource'),-1,1)) = '\' THEN
             webadminpkg.get_web_setting('PhotoSource') || p.person_code || '.jpg'
           ELSE
             webadminpkg.get_web_setting('PhotoSource') || '\' || p.person_code || '.jpg'
           END)
         ELSE null END) photopath,
(CASE WHEN  b.id IS NOT NULL THEN
         b.binary_object
END) photodata,
(CASE WHEN  b.id IS NOT NULL THEN
         b.blob_type
END) phototype
from people p
LEFT OUTER JOIN blobs b     ON (b.owner_ref    = p.person_code AND b.domain = 'PEOPLE')
where
  p.person_code = 17867

Second Query:
=======================================================
select distinct
   p.person_code,
   p.surname,
   p.forename,
 nvl(p.fes_user_6, 'n/a') BUS,
to_char(max(r.fes_spcl_end_date)) expdate,
  CASE WHEN (to_date(sysdate) - to_date(p.date_of_birth)) /365.25 < 18 THEN to_char(p.date_of_birth,'dd/mm/yyyy') ELSE 'Over 18' END DOB,
(CASE WHEN b.id IS NOT NULL THEN
          (CASE WHEN (substr(webadminpkg.get_web_setting('PhotoSource'),-1,1)) = '\' THEN
             webadminpkg.get_web_setting('PhotoSource') || p.person_code || '.jpg'
           ELSE
             webadminpkg.get_web_setting('PhotoSource') || '\' || p.person_code || '.jpg'
           END)
         ELSE null END) photopath,
(CASE WHEN  b.id IS NOT NULL THEN
         b.binary_object
END) photodata,
(CASE WHEN  b.id IS NOT NULL THEN
         b.blob_type
END) phototype
from people p
LEFT OUTER JOIN blobs b     ON (b.owner_ref    = p.person_code AND b.domain = 'PEOPLE')
LEFT OUTER JOIN registration_units r  ON (r.fes_per_person_code= p.person_code)
where
  p.person_code = 17867
GROUP BY p.person_code
ASKER CERTIFIED SOLUTION
MikeToole

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004