Select the child node in Oracle xmltype - oracle

Requirement is to display the Contact details stored in xmlformat.
My dataset as below:
Id XMldata
123 "<row id="123"><c1>Home</c1><c1 m="2">Office</c1><c1 M="3">Personal</c1><c2>+91</c2><c2 m="2">+65</c2><c2 m="3">+1</c2><c3>9900990090</c3><c3 m="2">55667788</c3><c3 m="3">123789073</c3><c4>Test element</c4></row>"
I need to build a select query to select child node matching Office contact details and to view the output in the below format:
Id C1 C2 C3
123 Office +65 55667788

Related

Apex Oracle calendar When Select list value is null show all and when Select value is not null show only the specific values

I'm new with apex and here is my problem. I would like to be able to display only the events of a person chosen in a select list in a calendar. if I choose the default value of the select list, I display all the events of people in my calendar. I created a dynamic action on my select list which when it changes, my calendar is refreshed but this does not work.
I give you my query below.
:P6_CLIENT is my select list
select RES_ID,
RES_ID_CLIENT,
(SELECT CLI_NOM FROM WER_CLI WHERE CLI_ID = RES_ID_CLIENT) AS NOM_CLIENT,
RES_ID_LOC,
RES_DATE_ARRIVE,
RES_DATE_DEPART,
RES_NB_PERS,
RES_TYPE_EVEN,
RES_PRIX_LOC,
RES_AJOUTER_PAR,
RES_AJOUTER_LE,
RES_MODIFIER_PAR,
RES_MODIFIER_LE,
RES_DESCRIPTION,
RES_PAV_ID,
CASE RES_ID_CLIENT
WHEN 87 THEN 'apex-cal-green'
WHEN 88 THEN 'apex-cal-red'
WHEN 89 THEN 'apex-cal-blue'
WHEN 90 THEN 'apex-cal-yellow'
WHEN 42 THEN 'apex-cal-orange'
END AS css_class
from WER_RES
WHERE RES_ID_CLIENT = NVL(:P6_CLIENT,RES_ID_CLIENT)

Netsuitescript 2.x how to load custome record in map/reduce

There are two custom record c1 and c2
me need to be fetch data from c2 based on record c1 item and subsidiaries internal id, after that if get the response the update record c1.
i have tried the search.create for this but its not working ( to load the all record in c1 )

In Oracle apex 20.2, What is the javascript to get the selected tree node id

Good day,
I am running orcl apex 20.2. I have a tree region with a simple table: id, title, parent_id.
I am struggling with the JS to get the selected node id, and store it in a page item. My JS skills are very week. I have been trying to use a dynamic Action to execute JS and use a treeNodeAdapter, but the object returned is a jQuery object. I have no idea what to do at that point.
Given the table above, can someone please write back the exact JS I would need in the DA to capture the selected id and save it to the page item...
Pls & thnx
Nikita
Here's how (based on Scott's EMP table).
Suppose it is page 70 which contains the tree region. Create a page item on it (for example, P70_EMPNO).
The tree query looks like this (pay attention to the link column; once clicked, it stores the selected node value into the P70_EMPNO page item):
select
case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
level,
ename || ' (' || empno ||')' as title,
'icon-tree-folder' as icon,
empno as value,
ename as tooltip,
--
'javascript:$s(''P70_EMPNO'', '''||EMPNO||''')' as link --> this
from emp
start with mgr is null
connect by prior empno = mgr
order siblings by ename;
The result (when you click on the JAMES node):
P.S. It looks that your keyboard is broken; quite a few letters are missing.

Oracle view to return single column from multiple select columns

query 1: I need to get the dept code from one table.
query 2: use that dept code to query another table which also has got another set of dept code. kind of one is to many, one dept referring to many depts.
NOTE: they don't have the same column name in two tables.
and the final result should be union of 1st query and 2nd query.
for eg: query 1 result : ECE
query 2 result : EEE, Mech, Comp. Sc.
I need the result to be ECE, EEE, Mech, Comp. Sc.
declare default_dept_Code varchar2(10);
begin
select dept_code into default_dept_Code from (select dept_code from
course_per WHERE student_no ='526765771');
dbms_output.put_line(default_dept_Code);
SELECT dept_code FROM course_per WHERE student_no ='526765771'
union all
select add_dept_code from addition_dept where dept_Code = default_dept_Code;
I'm unable to execute this query, it has got error. What are the other best ways I can handle it, I need to put this in a VIEW. I tried to create temp table and insert the select result into it, did not work. I'm a new bee to Oracle. I don't want to use cursor, if that is the only option I can go for it.
From what I understand you can write your query like this:
SELECT dept_code as code
FROM course_per
WHERE student_no ='526765771'
UNION ALL
SELECT add_dept_code as code
FROM addition_dept
WHERE dept_Code = (
SELECT dept_code
FROM course_per
WHERE student_no ='526765771');

pl-sql include column names in query

A weird request maybe but. My boss wants me to create an admin version of a page we have that displays data from an oracle query in a table.
The admin page, instead of displaying the data (query returns 1 row), needs to return the table name and column name
Ex: Instead of:
Name Initial
==================
Bob A
I want:
Name Initial
============================
Users.FirstName Users.MiddleInitial
I realize I can do this in code but would rather just modify the query to return the data I want so I can leave the report generation code mostly alone.
I don't want to do it in a stored procedure.
So when I spit out the data in the report using something like:
blah blah = MyDataRow("FirstName")
I can leave that as is but instead of it displaying "BOB" it would display "Users.FirstName"
And I want to do the query using select * if possible instead of listing all the columns
So for each of the columns I am querying in the * , I want to get (instead of the column value) the tablename.ColumnName or tablename|columnName
hope you are following- I am confusing myself...
pseudo:
select tablename + '.' + Columnname as WhateverTheColumnNameIs
from Table1
left join Table2 on whatever...
Join Table_Names on blah blah
Whew- after writing all this I think I will just do it on the code side.
But if you are up for it maybe a fun challenge
Oracle does not provide an authentic way(there is no pseudocolumn) to get the column name of a table as a result of a query against that table. But you might consider these two approaches:
Extract column name from an xmltype, formed by passing cursor expression(your query) in the xmltable() function:
-- your table
with t1(first_name, middle_name) as(
select 1,2 from dual
), -- your query
t2 as(
select * -- col1 as "t1.col1"
--, col2 as "t1.col2"
--, col3 as "t1.col3"
from hr.t1
)
select *
from ( select q.object_value.getrootelement() as col_name
, rownum as rn
from xmltable('//*'
passing xmltype(cursor(select * from t2 where rownum = 1))
) q
where q.object_value.getrootelement() not in ('ROWSET', 'ROW')
)
pivot(
max(col_name) for rn in (1 as "name", 2 as "initial")
)
Result:
name initial
--------------- ---------------
FIRST_NAME MIDDLE_NAME
Note: In order for column names to be prefixed with table name, you need to list them
explicitly in the select list of a query and supply an alias, manually.
PL/SQL approach. Starting from Oracle 11g you could use dbms_sql() package and describe_columns() procedure specifically to get the name of columns in the cursor(your select).
This might be what you are looking for, try selecting from system views USER_TAB_COLS or ALL_TAB_COLS.

Resources