I have created a table Called NAMES inside that I have a column called Status.
On STATUS, I created a lookup table and this created a new table called Status_lookup Which has 2 column (STATUS_ID and Status)
So the NAMES table column changed to STATUS_ID
when I do interactive reports, the data do come through from STATUS_ID which is number, I need the text that is stored in the Status.
Could some please explain how I do this. This I thought would be pretty easy but I can't see how to do it.
I am not Newbie to Oracle applications so a step by step would be helpful
Example: select * from emp
I want DEPTNO to display the DNAME which can be found in DEPT
What I usually do is:
Go to "Shared Components > Lists of Values", and create a new one from scratch, type dynamic.
I'm calling my LOV "DEPARTMENTS", and it has this SQL:
select dname d, deptno r
from dept
order by 1
To then map this to the column in the IR, go to the page with the IR and edit it. Go to the report attributes. From there you can see the columns in the IR and edit their attributes by clicking the pencil icon.
In the column attributes you can then change the display type of the column. Set it to "Display as Text (based on LOV, escape special characters)".
Then go to the "List of Values" section, and select the LOV from the "Named List of Values" select list. (In my example this is "DEPARTMENTS").
Apex will then map the values in the IR sql to that of the display value of the LOV.
Alternatively, you could of course also just change the SQL of the report to map a display value, for example:
SELECT empno, ename, depto, (select dname from dept where deptno = e.deptno) dname
from emp
Related
Is there a way to disable/restrict/alert-when-using some column in Oracle in a where clauses?
The reason that I'm asking this is because I have a very complex system (~30 services span cross millions of lines of code with thousends of sqls in it, in a sensitive production environment) working with an Oracle DB I need to migrate from using one column that is part of a key (and have a very not uniqu name) to another column.
Simple search is impossible....
The steps I'm having are:
populate new column
Add indexes on with the second column whenever there's an index with the first one.
Migrate all uses in where caluses from old to new column
Stop reading from the first column
Stop writing to the first column
Delete the column
I'm currently done step 3 and want to verify I've found all of the cases.
So, you're replacing one column with another. Which benefit do you expect once you're done? How will that improve overall experience with that application? I hope it is worth the effort.
As of your question: query user_source (or expand it to all_source or even dba_source, but you'll need additional privileges to do that) and see where's that very not unique name used. Something like this:
SQL> select * from user_source where lower(text) like '%empno%';
NAME TYPE LINE TEXT
--------------- ------------ ----- --------------------------------------------------------------------------------
P_RAISE PROCEDURE 22 WHERE empno = par_empno;
P_RAISE PROCEDURE 14 WHERE empno = par_empno;
P_RAISE PROCEDURE 1 PROCEDURE p_raise (par_empno IN emp.empno%TYPE)
GET_LIST FUNCTION 7 'select empno, ename, job, sal from emp where deptno = 10 order by '
SQL>
I have a interactive grid and one item p11_active_yn , based on the item value i want to check this condition for each row , in one grid we may have so many records, the enable disable should check and do for each row in interactive grid,, how to achieve this
Check the "Allowed Row Operations" attribute of the Interactive Grid. That feature meets your requirement. The help text is pretty clear.
Let me give an example:
This is on the EMP/DEPT sample dataset. There is page item P72_JOB. Only for the selected job, the record is editable.
Source Query:
select EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO,
CASE JOB WHEN :P72_JOB THEN 'U' ELSE NULL END AS UPDATE_ALLOWED
from EMP
Items to submit: P72_JOB
IG Attribute: Allowed Row Operations column: UPDATE_ALLOWED
For the test I added a dynamic action on P72_JOB to refresh the interactive grid on change. Now the interactive grid only allows the rows to be edited for the selected job.
I am using apex 20.1 and try to implement the new cascading lovs option. However it is not working as per expectation.
Can you suggest where am I going wrong.
I have 2 items in my region:
:P5_ASSIGNED_DEPT - Assigned department for each employee
:P5_PERSON_NAME - Name of employee
I want the name of employees to populate as per assigned dept in table.
If assigned_Dept is FINANCE, only employees with assigned dept as finance should populate in :P5_PERSON_NAME.
I made these changes:
But despite selecting finance, i am getting names of all employess irrespective of dept.
What more changes are needed?
I presume that query you used for P5_PERSON_NAME doesn't contain P5_ASSIGNED_DEPT. Apex can't automagically add WHERE clause to your query, you have to do it yourself.
So: P5_PERSON_NAME's LoV query should look like this:
select e.ename as display_value,
e.id as return_value
from emp e
where e.dept_id = :P5_ASSIGNED_DEPT
I have a classic report driven by a SQL query.
How can I dynamically set column headings, based on the value of another column?
For example, my SQL returns columns A, B, VERSION. I'd like the classic report column heading for SQL column A to be 'Foo' if VERSION is 1, but 'Bar' if VERSION is 2.
I don't know what you meant by saying that the query is constrained by primary key.
Anyway, here's a suggestion which might (or might not) help.
Based on sample SCOTT schema, I created a simple classic report as
select e.ename, e.job
from emp e
where e.deptno = :P42_DEPTNO
I also created a P42_DEPTNO item which - kind of - constrains the result to just one department. For example, if you enter 10 into P42_DEPTNO, you'll get employees that work in the ACCOUNTING department.
Furthermore, I created a hidden item P42_DNAME whose souce is a SQL query
select dname
from dept
where deptno = :P42_DEPTNO
and it returns department name for the P42_DEPTNO value. Its "Used" property is set to "Always, replacing any existing value in session state". This item (P42_DNAME) will be used as a custom heading for the ENAME column returned by the report.
In order to do that, open ENAME column's properties and put this into the "Name" property: &P42_DNAME. (literally ampersand + item name + dot - don't forget the trailing dot!).
That's all;
run the report
enter 10 into P42_DEPTNO item
press ENTER key
report will display employees that work in department 10, and ENAME column's heading will be ACCOUNTING
In Oracle, is there an easy way to fully unwrap a view? eg: If I have a view which is made up of selects on more views, is there some way to unwrap it to just select directly on real tables?
The concept of in-line views can be used to do this. Suppose you have these 2 views:
create or replace view london_dept as
select * from dept
where loc = 'LONDON';
and
create or replace view london_mgr as
select * from emp
where job='MANAGER'
and deptno in (select deptno from london_dept);
In the second view's SQL, the reference to view london_dept can be replaced by an in-line view using the SQL from the london_dept view definition as follows:
select * from emp
where job='MANAGER'
and deptno in (select deptno from (select * from dept
where loc = 'LONDON'));
Of course, you can now see that is overly verbose and could be simplified to:
select * from emp
where job='MANAGER'
and deptno in (select deptno from dept where loc = 'LONDON');
Finally, some advice from Tom Kyte on the advantages and disadvantages of creating views of views
Get the query text of your view.
SELECT text FROM dba_views
WHERE owner = 'the-owner' AND view_name = 'the-view-name';
Parse. Search for view names within the query text.
Get the query text for each view name found. (see item 1.)
Replace each view name in the query with the related query text.
Do this recursively until there are no more views found.
Easy?
EDIT: The above instructions do not do everything required. Thinking about this a little more it gets hairy, grows legs, and maybe another arm. Finding column names, and column names that might be elaborate functions and subqueries. Bringing it all back together with the joins and clauses. The resulting query might look very ugly.
Somewhere within Oracle there may be something that is actually unwrapping a view. I don't know. I am glad I didn't use views that much in Oracle.
Up until Oracle 12.1 the correct answer is no, there is no easy way. Now, in 12.1 there is DBMS_UTILITY.EXPAND_SQL_TEXT : Expand SQL References to Views in Oracle Database 12c Release 1 (12.1) does exactly this. See the documentation of dbms_utility