Solved

Join SQL view with APEX item as the join condition

Posted on 2016-10-08
4
47 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 24

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 24

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

920 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

14 Experts available now in Live!

Get 1:1 Help Now