Solved

Join SQL view with APEX item as the join condition

Posted on 2016-10-08
4
64 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
Pawan Kumar 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 28

Expert Comment

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

Author Closing Comment

by:Daniel993
ID: 41844052
worked perfectly
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

740 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