Avatar of Bobby Sandhu
Bobby Sandhu
Flag for Canada asked on

query help

hi there
when i am running this query no issue
SELECT nvl(po.person_id,ap.employee_id) person_id,
              po.cost_centre po_cost_centre,
              ap.cost_center ap_cost_centre, ap.signing_limit ap_signing_limit
         FROM vzn_po_subordinate_cst_ctr_gtt po FULL OUTER JOIN
              ap_web_signing_limits ap
              --,gl_sets_of_books sob
              ON (po.person_id = ap.employee_id AND po.cost_centre = ap.cost_center)
        WHERE nvl(ap.document_type,'APEXP') = 'APEXP'
       -- and po.SET_OF_BOOKS_ID = sob.SET_OF_BOOKS_ID


when i run this one i get error missing keyword

SELECT nvl(po.person_id,ap.employee_id) person_id,
              po.cost_centre po_cost_centre,
              ap.cost_center ap_cost_centre, ap.signing_limit ap_signing_limit
         FROM vzn_po_subordinate_cst_ctr_gtt po FULL OUTER JOIN
              ap_web_signing_limits ap
              ,gl_sets_of_books sob
              ON (po.person_id = ap.employee_id AND po.cost_centre = ap.cost_center)
        WHERE nvl(ap.document_type,'APEXP') = 'APEXP'
        and po.SET_OF_BOOKS_ID = sob.SET_OF_BOOKS_ID
Oracle Database

Avatar of undefined
Last Comment
Devinder Singh Virdi

8/22/2022 - Mon
Mehuge

Is it not because you are inserting the extra join before the ON clause that defines the join between po and ap?

Does:

SELECT nvl(po.person_id,ap.employee_id) person_id,
              po.cost_centre po_cost_centre,
              ap.cost_center ap_cost_centre, ap.signing_limit ap_signing_limit
         FROM vzn_po_subordinate_cst_ctr_gtt po FULL OUTER JOIN
              ap_web_signing_limits ap
              ON (po.person_id = ap.employee_id AND po.cost_centre = ap.cost_center)
              ,gl_sets_of_books sob
        WHERE nvl(ap.document_type,'APEXP') = 'APEXP'
        and po.SET_OF_BOOKS_ID = sob.SET_OF_BOOKS_ID

Work, or even

SELECT nvl(po.person_id,ap.employee_id) person_id,
              po.cost_centre po_cost_centre,
              ap.cost_center ap_cost_centre, ap.signing_limit ap_signing_limit
         FROM vzn_po_subordinate_cst_ctr_gtt po FULL OUTER JOIN
              , gl_sets_of_books sob ,
              ap_web_signing_limits ap
              ON (po.person_id = ap.employee_id AND po.cost_centre = ap.cost_center)
        WHERE nvl(ap.document_type,'APEXP') = 'APEXP'
        and po.SET_OF_BOOKS_ID = sob.SET_OF_BOOKS_ID
Mehuge

Ignore my second example, its complete rubbish, I had not spotted the outer join keyword, try this instead if the first example does not work

SELECT nvl(po.person_id,ap.employee_id) person_id,
              po.cost_centre po_cost_centre,
              ap.cost_center ap_cost_centre, ap.signing_limit ap_signing_limit
         FROM vzn_po_subordinate_cst_ctr_gtt po FULL OUTER JOIN
              ap_web_signing_limits ap ON (po.person_id = ap.employee_id AND po.cost_centre = ap.cost_center)
              LEFT JOIN gl_sets_of_books sob ON po.SET_OF_BOOKS_ID = sob.SET_OF_BOOKS_ID
        WHERE nvl(ap.document_type,'APEXP') = 'APEXP'
ASKER CERTIFIED SOLUTION
Sean Stuber

THIS SOLUTION 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
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Devinder Singh Virdi

Full outer join ... ON is one complete syntax, by putting comma, you are breaking the syntax, now oracle is not able to figure out that where is its joining condition, thats why ur receiving an error.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Sean Stuber

right, that's what I meant by "combining" syntaxes.

Bobby Sandhu

ASKER
just one thing more can i replace
nvl with sumthing else in oracle
NVL(ap.document_type, 'APEXP') = 'APEXP'
Devinder Singh Virdi

NVL is specifically for null value, but you can use decode(ap.document_type, first_value,'1', second_value,'1', third_value,'1','APEXP')='APEXP'
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.