Avatar of PNickJames
PNickJamesFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

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

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
Microsoft AccessEnterprise SoftwareSQL

Avatar of undefined
Last Comment
PNickJames
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

r.fes_per_person_code= p.person_code

Are these two the same data type in the oracle db?
Avatar of PNickJames
PNickJames
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi Mike
Yes they're the same type. I've got other queries that use this exact link perfectly fine.
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

The other thing that looks strange is the Group By - there are no Grouping functions in the select statement and the Group By would need to include all the non-group function columns  
Avatar of PNickJames
PNickJames
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

to_char(max(r.fes_spcl_end_date)) expdate
about half way down. I was getting an error message to start saying I needed a Group By statement as soon as I put this line in.
ASKER CERTIFIED SOLUTION
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of PNickJames
PNickJames
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks very much. Knew it would be simple. But as always couldn't see it for looking. Thanks again
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo