Solved

Join SQL view with APEX item as the join condition

Posted on 2016-10-08
4
40 Views
Last Modified: 2016-10-14
Hi Experts

I'm trying to create a report in Oracle APEX (version 3.2.1) and the report should retrieve values from a database view based on what the user selects into the shuttle box.

I created the following join:

select * from
select COLUMN_1, COLUMN_2
from TABLE
where upper("COLUMN_1") = upper(:SHUTTLE_ITEM)

Open in new window


and below is the code that was generated by APEX in the "source" box.

select * from
( select COLUMN_1, COLUMN_2
from TABLE
where upper("COLUMN_1") = upper(:SHUTTLE_ITEM))
where
(instr(upper("COLUMN_1"),upper(nvl(:SEARCH,"COLUMN_1"))) > 0 or
 instr(upper("COLUMN_2"),upper(nvl(:SEARCH,"COLUMN_2"))) > 0 )

Open in new window


The problem is that, as you probably know, the shuttle item separates the items with a colon ( : ), therefore
 the join does not work correctly. Could you please provide some help in creating the correct join syntax.

I've tried utilizing the following utility but I think I was doing something wrong.
Oracle string to text utility APEX_UTIL
0
Comment
Question by:Daniel993
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Pawan Kumar Khowal earned 500 total points
ID: 41835442
Pls try this . You first need to separate the items by :(semicolon) coming out from the shuttle box then join it will the other table.

I have taken e.g. as 'p:Q'

SELECT Shutles
FROM
(
	SELECT UPPER(REGEXP_SUBSTR('p:Q', '[^:]+', 1, LEVEL)) AS Shutles
	   FROM DUAL
	CONNECT BY REGEXP_SUBSTR('p:Q', '[^:]+', 1, LEVEL) IS NOT NULL
);

Open in new window


Now just join it with the other table/View

--


SELECT COLUMN_1, COLUMN_2
FROM TABLE1 t
INNER JOIN 
(
	SELECT Shutles
	FROM
	(
		SELECT UPPER(REGEXP_SUBSTR(SHUTTLE_ITEM, '[^:]+', 1, LEVEL)) AS Shutles
		   FROM DUAL
		CONNECT BY REGEXP_SUBSTR(SHUTTLE_ITEM, '[^:]+', 1, LEVEL) IS NOT NULL
	);
)m
ON m.Shutles = t.UPPER("COLUMN_1")

--

Open in new window

0
 

Author Comment

by:Daniel993
ID: 41843100
Hi Pawan.

Sorry for the delay, that worked perfectly, thank you.
0
 
LVL 18

Expert Comment

by:Pawan Kumar Khowal
ID: 41843142
Hi, Great that it worked. enjoy !!
0
 

Author Closing Comment

by:Daniel993
ID: 41844052
worked perfectly
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now