Print child SQL that returns multiple lines for single colum.
I have a requirement to print lines both Parent and child SQLs to a line.For Ex:
Parent row is back a row
ID, name, primary flow.
101, LName, FName, 30
Child line returns several lines
ID, name, lower secondary
101, LName, FName, 15
101, LName, FName, 10
The end result should be
101, LName, FName, 10, 15 and 30
Any suggestions please?
You can also follow this approach presented by Tim Dexter some time ago.
[url: http://blogs.oracle.com/xmlpublisher/entry/across_not_down] report
concerning
Jorge
PS once again, if you consider the answer to your question, please mark my answer as 'Correct' or 'useful '.
Tags: Business Intelligence
Similar Questions
-
Need help with a SQL qurey that returns multiple lines for a record?
I have the following query where I use a WHEN clause CASES to determine the date of a change that starts with 'FRLO' on day 1 - day14 of the pay period. It works fine if a folder schedule with a day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day he finds and not others. Is there a way to get the query to return a ron for every day 1-14 that begins "FRLO"? System if Oracle 11 G
The order of the results is not important, because this is part of a larger query that orders the results.
Thanks in advance for any help,
George
---------------------------------------------------------------------------------------------------------------------------------
SELECT s.empid,
CASE
A SUPERIOR TIME (SUBSTR (s.Day1, 0, 4)) = "FRLO".
THEN
pp.startpp
A SUPERIOR TIME (SUBSTR (s.Day2, 0, 4)) = "FRLO".
THEN
pp.startpp + 1
A SUPERIOR TIME (SUBSTR (s.Day3, 0, 4)) = "FRLO".
THEN
pp.startpp + 2
A SUPERIOR TIME (SUBSTR (s.Day4, 0, 4)) = "FRLO".
THEN
pp.startpp + 3
A SUPERIOR TIME (SUBSTR (s.Day5, 0, 4)) = "FRLO".
THEN
pp.startpp + 4
A SUPERIOR TIME (SUBSTR (s.Day6, 0, 4)) = "FRLO".
THEN
pp.startpp + 5
A SUPERIOR TIME (SUBSTR (s.Day7, 0, 4)) = "FRLO".
THEN
pp.startpp + 6
A SUPERIOR TIME (SUBSTR (s.Day8, 0, 4)) = "FRLO".
THEN
pp.startpp + 7
A SUPERIOR TIME (SUBSTR (s.Day9, 0, 4)) = "FRLO".
THEN
pp.startpp + 8
A SUPERIOR TIME (SUBSTR (s.Day10, 0, 4)) = "FRLO".
THEN
pp.startpp + 9
A SUPERIOR TIME (SUBSTR (s.Day11, 0, 4)) = "FRLO".
THEN
pp.startpp + 10
A SUPERIOR TIME (SUBSTR (s.Day12, 0, 4)) = "FRLO".
THEN
pp.startpp + 11
A SUPERIOR TIME (SUBSTR (s.Day13, 0, 4)) = "FRLO".
THEN
pp.startpp + 12
A SUPERIOR TIME (SUBSTR (s.Day14, 0, 4)) = "FRLO".
THEN
pp.startpp + 13
END
StartDate,
StartTime, NULL,
Time NULL terminator,
8 hours,
0 minutes
Time S
JOIN THE
payperiods pp
ON pp.periodid = s.periodid
WHERE SUPERIOR (SUBSTR (s.Day1, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day2, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day3, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day4, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day5, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day6, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day7, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day8, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day9, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day10, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day11, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day12, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day13, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day14, 0, 4)) = "FRLO";
----------------------------------------------------------------------------------------------
OUTPUT CURRENT
EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
753738, 25/03/2013, 8, 0
753740, 25/03/2013, 8, 0
753748, 25/03/2013, 8, 0
DESIREE OUTPUT
EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
753738, 25/03/2013, 8, 0
753740, 25/03/2013, 8, 0
753748, 25/03/2013, 8, 0
753738, 26/03/2013, 8, 0
753740, 26/03/2013, 8, 0
753740, 28/03/2013, 8, 0
753748, on 01/01/2013, 8, 0
753738, on 03/04/2013, 8, 0
753748, on 03/04/2013, 8, 0
-----------------------------------------------------------------------------------------------
CREATE THE TABLE PROGRAMS
(
SCHEDULEID NUMBER (12) NOT NULL,
EMPID NUMBER (12) NOT NULL,
PERIODID VARCHAR2 (6 BYTE) NOT NULL,
AREAID NUMBER (12) NOT NULL,
DAY1 VARCHAR2 (50 BYTE),
DAY 2 VARCHAR2 (50 BYTE).
DAY 3 VARCHAR2 (50 BYTE).
DAY4 VARCHAR2 (50 BYTE),
DAY5 VARCHAR2 (50 BYTE),
DAY6 VARCHAR2 (50 BYTE),
DAY 7 VARCHAR2 (50 BYTE).
JOUR8 VARCHAR2 (50 BYTE),
DAY9 VARCHAR2 (50 BYTE),
DAY10 VARCHAR2 (50 BYTE),
DAY 11 VARCHAR2 (50 BYTE).
DAY12 VARCHAR2 (50 BYTE),
J13 VARCHAR2 (50 BYTE),
DAY14 VARCHAR2 (50 BYTE),
NOPTIND1 INTEGER DEFAULT 0,
NOPTIND2 INTEGER DEFAULT 0,
NOPTIND3 INTEGER DEFAULT 0,
NOPTIND4 INTEGER DEFAULT 0,
NOPTIND5 INTEGER DEFAULT 0,
NOPTIND6 INTEGER DEFAULT 0,
NOPTIND7 INTEGER DEFAULT 0,
NOPTIND8 INTEGER DEFAULT 0,
NOPTIND9 INTEGER DEFAULT 0,
NOPTIND10 INTEGER DEFAULT 0,
NOPTIND11 INTEGER DEFAULT 0,
NOPTIND12 INTEGER DEFAULT 0,
NOPTIND13 INTEGER DEFAULT 0,
NOPTIND14 INTEGER DEFAULT 0
);
CREATE TABLE PAYPERIODS
(
PERIODID VARCHAR2 (6 BYTE) NOT NULL,
DATE OF STARTPP,
DATE OF ENDPP
);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693744, 753738, '082013' 2167, 'X')
"FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', '1530', '1530',
'X', 'X', '1530', '1530', 'FRLO ',.
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693745, 753740, '082013' 2167, 'X')
"FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', 'FRLO', '1530',
'X', 'X', '1530', '1530', ' 1530',
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693746, 753748, '082013' 2167, 'X')
"FRLO < 1530 > ', '1530', '1530', '1530', '1530',.
'X', 'X', ' FRLO < 1530 > ', '1530', 'FRLO ',.
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
COMMIT;
Insert into PAYPERIODS
(PERIODID, STARTPP)
Values
(TO_DATE '082013', (MARCH 24, 2013 00:00:00 "," MM/DD/YYYY HH24:MI:SS'));))
COMMIT;Hello
I think you want:
SELECT s.empid, pp.startpp, startdate, NULL starttime, NULL endtime, 8 hours, 0 minutes FROM schedules s JOIN payperiods pp ON pp.periodid = s.periodid WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO' UNION SELECT s.empid, pp.startpp + 1, startdate, NULL starttime, NULL endtime, 8 hours, 0 minutes FROM schedules s JOIN payperiods pp ON pp.periodid = s.periodid WHERE UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO' --ETC.
Kind regards
Peter
-
Can't understand why this query returns multiple lines with the same data
Hi all
I am a relative novice and self-taught when it comes to SQL. I wrote a query to our reporting tool that returns multiple rows, and I can't understand why. I know that I can use the SELECT DISTINCT option, but it really slows the execution when I do. I'd really rather understand if I can change the code to avoid the multiples. This is the query. I've included a few statements in italics to help explain the break. Any ideas?
SELECT MATSITE, MATPONUM, FIRSTRECPTDATE
Of
Subquery that concludes the first date on which purchase orders have been implemented with ACK State
(SELECT ACKSTAT. PONUM AS 'ACKPONUM', (MIN (ACKSTAT. CHANGEDATE)) AS 'FIRSTACKDATE '.
OF PZMAX. POSTATUS ACKSTAT
WHERE (ACKSTAT. STATE = 'ACK') AND (ACKSTAT.ORGID ='CGSALTUS)
GROUP OF ACKSTAT. PONUM),
Subquery that concludes the first reception against a purchase order transaction for purposes of comparison
(SELECT TRANS. PONUM AS "MATPONUM", TRANS. SITEID AS 'MATSITE', (MIN (TRANS. TRANSDATE)) AS 'FIRSTRECPTDATE '.
OF PZMAX. MATRECTRANS TRANS
WHERE (TRANS.ORGID ='CGSALTUS) AND (TRANS. HOUR > =: startDate and TRANS. TRANSDATE < =: endDate)
TRANS GROUP. SITEID, TRANS. PONUM)
WHERE
(ACKPONUM = MATPONUM AND FIRSTRECPTDATE < FIRSTACKDATE) OR (NOT EXISTS (SELECT 1 FROM PZMAX. POSTATUS ACKSTAT2 WHERE (ACKSTAT2. PONUM = MATPONUM) AND (ACKSTAT2. STATE = 'ACK') AND (ACKSTAT2.ORGID ='CGSALTUS)))
The where the instruction is intended to find when one of two conditions exists. ((1) received happened before the command either in ACK or 2) a reception that's happened, but the purchase order is never in ACK State. It seems that this second condition that creates multiple lines.
Any thoughts will be appreciated geratly.
Dave Teece
-
Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value
Hello
a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:
Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.
I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)
Workspace: tests
USER: supporter
PWD: supporter1234
Any help would be much appreciated.
Kind regards
Pavel
Pavel
If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.
This will jump to the top of the page of the modal dialog box
: P1_URL: = apex_util.prepare_url)
' f ? p ='|| : APP_ID - Application id
|': 2' - Page id
||': ' || : APP_SESSION - Session id
||':' -- Request
||':NO' -- Debug
: ': ' - Clear Cache
: ': ' - Settings
||' P2_ITEMVAL'
: ': ' - Parameter values
|| (: P1_ITEMVAL);
then in the action of javascript
Window.Location.Replace ($v ('P1_URL'));
Hope this is of some use
Concerning
Kelvin
-
Plugin to point that returns multiple values
When you create an APEX element that can return multiple values, such as a checkbox, APEX uses the settings of varchar2 p_v01 - p_v200 instead of the p_t01 table settings - p_t200.
I would like to create a plugin item type that can return multiple values in the same way, so that the session recorded for the item state contains a delimited string of values. I realize, I could achieve with Javascript and a hidden item, but I really want to a non-Javascript solution. Is this possible? If this isn't the case, it would be a nice improvement!
Hi Tony,.
Take a look at the level of the parameter p_is_multi_value of the APEX_PLUGIN. GET_INPUT_NAME_FOR_PAGE_ITEM api (http://docs.oracle.com/cd/E37097_01/doc.42/e35127/apex_plugin.htm#AEAPI1254). If you set it to TRUE, you will get one of the p_v01 - p_v200 table settings. It's the same what our box element type calls.
Concerning
Patrick
Member of the APEX development team
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf
-
Print every word in the new line for a space in a string
Hi all
I would print every word in the new line, if there is a space in the string.
Is there a better way using regexp?
declare
number of v_count;
v_text varchar2 (1000): = 'Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - Production | " ';
v_single_text varchar2 (1000);
number of v_space_pos;
Start
Select regexp_count (v_text,' ') in double v_count;
While v_count > 0
loop
v_space_pos: = instr (v_text,' ');
v_single_text: = substr(v_text,1,v_space_pos-1);
dbms_output.put_line (v_single_text);
v_text: = substr (v_text, v_space_pos + 1);
v_count: = v_count-1;
end loop;
end;
Thank you
Rambeau
HI - try as
with t as (select 'Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - Production' |) "" double str)
Select regexp_substr (str,'[^] +', 1, level)
t
connect by level<=regexp_count(str,'[^>=regexp_count(str,'[^>
-
multiple folder for single user
I want to configure several share folder in the folder for single user, but the user profile only have one option of folder is there, y at - it an option to configure multiple home folder?
Hello
I suggest you according to the question in this forum and check if that helps:
http://social.technet.Microsoft.com/forums/en-us/categories
It will be useful.
-
Hello
I have a report that uses apex_item.checkbox (...) to generate the check box. This report correctly displays a check box for each line. The source code that is generated in the html page is:
< input type = "checkbox" name = "f01" value = "202" id = "P1_CHECKBOX" / >
...
...
< input type = "checkbox" name = "f01" value = "220" id = "P1_CHECKBOX" / >
...
...
< input type = "checkbox" name = "f01" value = "210" id = "P1_CHECKBOX" / >
...
...
I want to use the javascript function $v () to get the values of the enabled check box. I thought that the return of this function all the checked values separated by ':' but I noticed that my code alert ($v ('P1_CHECKBOX')); return whenever the value of the first checkbox if it is checked.
It returns '202' if the first box is checked, but nothing, if only the second checkbox is checked and '202' if the box of the first and the second is checked.Hello
first of all, $v, $x and $s are supposed to not work for items on the page, not the columns in a table or manually generated HTML elements.
Secondly, I think that your HTML code is not correct, because each of your boxes has the same ID. But the ID must be unique in the DOM of the browser tree. Thus the different box should actually named P1_CHECKBOX_1... P1_CHECKBOX_3. Just look at what is actually generated for a page element real checkbox. BTW, I think that you should not name the checkbox as part of page elements, because they are not actually page elements. I think that this could be confusing for other developers.
Hope that helps
Patrick
-----------
My Blog: http://www.inside-oracle-apex.com
APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf -
Tab Leader points to the text that spans multiple lines
I have a numbered list with large amounts of information in what is connected by points of the leader. It's a mush very such as a table of contents or a restaurant menu (for example "name of the dish"... $ price). My case, however, has a simple shade which breaks everything and is not explained by the conversations or documentation that I could find via search this forum and in the rest of the web.
What happens if the leader points lead to something that does not fit on a single line?
Here is an example:
Basically, what I need is for everything between the tab (which generates points of the leader) and the end of the paragraph (when I press Enter) to stay on the right points. Do not let my small silly example, lists, I care are very long and subject to the order of drastic change. Certainly, there must be a way to do this, but I'm completely lost. I considered just it winging and putting things in their own areas of text and force alignment manually through various methods. But still there are very many content and order him will almost certainly change, so I want to keep everything in a changeable, easy to work with the format.
Thanks so much to anyone who might have seen or advice on what to do!
The only thing I can think immediately would be a big left indent on the model numbered with a corresponding left out-tooth of the first line end up with something like this:
But I know when I played, I killed the leader of the dowry, but hey, I was clicking faster that the brain could keep up...
Mike
-
I get no line despite the fact that there are lines for the matcin
Select 1 of
processing_validation_rules
where
TO_CHAR (processing_validation_rules. BST_ERROR_CODE) in (select substr (factor_fun (1.15), 2) double)
the substr function (factor_fun (1.15), 2) returns 3.5
There are a 2 rows each with 3 and 5
So why am I no rows returned?user8731258 wrote:
Select 1 of
processing_validation_rules
where
TO_CHAR (processing_validation_rules. BST_ERROR_CODE) in (select substr (factor_fun (1.15), 2) double)the substr function (factor_fun (1.15), 2) returns 3.5
There are a 2 rows each with 3 and 5
So why am I no rows returned?It won't work because your function returns a single string "3.5", and no two values 3 and 5 and you try to match a unique value to one of those.
You have varying in lists for example
SQL> ed Wrote file afiedt.buf 1 select * 2 from emp 3 where ename in ( 4 with t as (select '&input_string' as txt from dual) 5 select REGEXP_SUBSTR (txt, '[^,]+', 1, level) 6 from t 7 connect by level <= length(regexp_replace(txt,'[^,]*'))+1 8* ) SQL> / Enter value for input_string: SCOTT,JAMES old 4: with t as (select '&input_string' as txt from dual) new 4: with t as (select 'SCOTT,JAMES' as txt from dual) EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- 7788 SCOTT ANALYST 7566 19-04-1987 00:00:00 3000 20 7900 JAMES CLERK 7698 03-12-1981 00:00:00 950 30 SQL>
Or read this...
http://tkyte.blogspot.com/2006/06/varying-in-lists.html
-
Function returns multiple lines.
Hello
I want to get the data from the service.
My source having a column as shown below
type
AAA
BBB
and my reference table having 2 columns as shown below
type code
AAA 1
AAA 2
BBB 34
My function is like this
create or replace FUNCTION GET_CODE (pv_type IN table1.type%TYPE)
RETURN table2.code%TYPE
IS
V_ret_string table2.code%TYPE;
BEGIN SELECT DISTINCT b.code IN V_ret_string
OF b table2 WHERE UPPER (b.type) = UPPER (pv_type);
RETURN V_ret_string; END GET_TRANSACTION_CODE;
during execution of the function above
Returns the error as exact fetch returns more than one more
but I badly need a whole line of reference table
Pls help me.
Kind regards
MaëlleSELECT b.code INTO V_ret_string FROM table2 b WHERE UPPER(b.type) = UPPER(pv_type) and rownum = 1;
-
Help in the treatment of "subquery returns multiple rows.
Appreciate your help on this.
I have under sql query fails with the error "ORA-01427: einreihig subquery returns multiple lines"
WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT distinct col2 FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 WhenI checked the count using below query WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT count(col2) FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 (+) it shows as below ----------------- COL1 RND_COL A 2 A 2 D 1 E 0 My Requirement is for all the values in the column 'RND_COL' > 1 it should display text as 'Multiple', for 'RND_COL' = 1 display actual value returned by sub query and 'RND_COL' = 0 display it as NULL. expected output ------------------- COL1 RND_COL A Multiple A Multiple D E E NULL
Hello
Here's another way. It's like the solution in response #1, but it does not use a subquery:
SELECT t.col1
CASE
WHEN COUNT (DISTINCT t2.col2) > 1
THEN "Multiple."
For ANOTHER MIN (t2.col2)
END AS rnd_col
T
LEFT OUTER JOIN t2 ON t2.col1 = t.col1
GROUP OF t.col1, t.col2, t.col3
ORDER BY t.col1
;
This assumes that in table t (col1, col2, col3) combination is unique. If theat is not the case, change the GROUP BY clause, but you need to ensure that all lines of t becomes a separate group.
-
Web service PLSQL returning multiple records
Hello
I am creating a web service using oracle 11 g, which should be able to return multiple records.
Based on the code and the advice of the samples found on the internet, here is my code:
CREATE OR REPLACE TYPE test_rec is OBJECT ( s_nume_adre NUMBER , c_eta_civi VARCHAR2(4 BYTE), l_nom1_comp VARCHAR2(40 BYTE), l_nom2_comp VARCHAR2(40 BYTE), l_nom3_comp VARCHAR2(40 BYTE), l_pren_comp VARCHAR2(30 BYTE), d_date_nais DATE); CREATE OR REPLACE TYPE test_array AS TABLE OF test_rec; */ CREATE OR REPLACE PACKAGE test_pkg AS function get_rows(snume_adre in number) return test_array; END; / CREATE OR REPLACE PACKAGE BODY test_pkg AS function get_rows(snume_adre in number) return test_array is v_rtn test_array := test_array(null); v_first boolean := true; cursor c_get_rows(snume_adre in number) is SELECT a.s_nume_adre, nvl(a.c_eta_civi, '') c_eta_civi, nvl(a.l_nom1_comp, '') l_nom1_comp, nvl(a.l_nom2_comp, '') l_nom2_comp, nvl(a.l_nom3_comp, '') l_nom3_comp, nvl(a.l_pren_comp, '') l_pren_comp, nvl(a.d_date_nais, to_date('01.01.1900', 'dd.mm.yyyy')) d_date_nais FROM bro.z45 a where a.s_nume_adre = snume_adre or snume_adre is null; begin for rec in c_get_rows(snume_adre) loop if v_first then v_first := false; else v_rtn.extend; end if; v_rtn(v_rtn.last) := test_rec(rec.s_nume_adre, rec.c_eta_civi, rec.l_nom1_comp, rec.l_nom2_comp, rec.l_nom3_comp, rec.l_pren_comp, rec.d_date_nais); end loop; return v_rtn; end; END; / --select * from table (test_pkg.get_rows(null));
I am able to retrieve data using select.
However, when I try to access its wsdl I get an error:
< envelope soap: >
< soap: Body >
< soap: Fault >
Client: soap < faultcode > < / faultcode >
entry processing < faultstring > error < / faultstring >
< detail >
< OracleErrors > < / OracleErrors >
< / details >
< / soap fault: >
< / soap: Body >
< / envelope soap: >
-- -------------------------------------------------------------------------------------------------------------
If I comment the function call in the package declaration I get a "correct": wsdl
-- -------------------------------------------------------------------------------------------------------------
" < name definitions = targetNamespace"GET_ROWS"=" http://xmlns.Oracle.com/orawsv/test/TEST_PKG/GET_ROWS "xmlns =" http://schemas.xmlsoap.org/wsdl/ "xmlns:tns =" http://xmlns.Oracle.com/orawsv/test/TEST_PKG/GET_ROWS "container =" http://www.w3.org/2001/XMLSchema "xmlns:soap =" http://schemas.xmlsoap.org/wsdl/SOAP/ "> " ""
< types >
" < xsd: Schema targetNamespace = ' http://xmlns.Oracle.com/orawsv/test/TEST_PKG/GET_ROWS "elementFormDefault ="qualified"> "
< xsd: element name = "GET_ROWSInput" >
< xsd: complexType >
< / xsd: complexType >
< / xsd: element >
< xsd: element name = "GET_ROWSOutput" >
< xsd: complexType >
< / xsd: complexType >
< / xsd: element >
< / xsd: Schema >
< / types >
< name of message = "GET_ROWSInputMessage" >
< name of part = "parameters" element = "tns:GET_ROWSInput" / >
< / message >
< name of message = "GET_ROWSOutputMessage" >
< name of part = "parameters" element = "tns:GET_ROWSOutput" / >
< / message >
< portType name = "GET_ROWSPortType" >
< operation name = "GET_ROWS" >
< input message = "tns:GET_ROWSInputMessage" / >
< output message = "tns:GET_ROWSOutputMessage" / >
< / operation >
< / portType >
< connection name = "GET_ROWSBinding" type = "tns:GET_ROWSPortType" >
" < style: soap = transport = 'document' binding ' http://schemas.xmlsoap.org/SOAP/HTTP "/>
< operation name = "GET_ROWS" >
< soap: operation soapAction = "GET_ROWS" / >
< input >
< soap body parts: = 'settings' use = "literal" / >
< / Entry >
< output >
< soap body parts: = 'settings' use = "literal" / >
< / output >
< / operation >
< / binding >
< service name = "GET_ROWSService" >
< documentation > Oracle Web Service < / documentation >
< name of port = "GET_ROWSPort" binding = "tns:GET_ROWSBinding" >
" < soap: address location = ' http://server.domain.ch:8080 / orawsv/TEST/TEST_PKG/GET_ROWS "/>
< / port >
< / service >
< / definitions >
-- -------------------------------------------------------------------------------------------------------------
Any suspicion that how create and access pl sql web service returning multiple lines?
I use java not and do not have access to tools such as JDeveloper.
Thank you!
The real problem is that collection types are not supported for the return parameters.
The solution is to wrap the collection into another object.
Here is an example of work based on your settings:
CREATE OR REPLACE TYPE test_rec is OBJECT ( empno number(4) , ename varchar2(10) , hiredate date ); / CREATE OR REPLACE TYPE test_array AS TABLE OF test_rec; / CREATE OR REPLACE TYPE test_array_wrapper is OBJECT ( arr test_array ); / CREATE OR REPLACE PACKAGE test_pkg AS function get_rows(p_deptno in number) return test_array_wrapper; END; / CREATE OR REPLACE PACKAGE BODY test_pkg AS function get_rows(p_deptno in number) return test_array_wrapper is results test_array; begin select test_rec(empno, ename, hiredate) bulk collect into results from scott.emp where deptno = p_deptno; return test_array_wrapper(results); end; END; /
The wsdl is then generated correctly:
SQL> select httpuritype('http://DEV:dev@localhost:8080/orawsv/DEV/TEST_PKG/GET_ROWS?wsdl').getxml() from dual; HTTPURITYPE('HTTP://DEV:DEV@LOCALHOST:8080/ORAWSV/DEV/TEST_PKG/GET_ROWS?WSDL').GETXML() --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle Web Service -
USERENV ('sessionid') returns multiple rows
Hello
Im trying to put in place a db trigger that will record all DDL operations on the db.
for which purpose the following statement is included in the trigger to return information about the user who wishes to make changes:
problem is that this statement returns multiple lines when 2 users are connected to the same database by using the same username for example SYS;select osuser, machine, process, program, AUDSID, sid, SERIAL# from v$session where AUDSID=USERENV('sessionid');
I see that audsid is the same for these 2 users, but the osuser, the machine etc. are different, so I can easily tell who is who.
How to distinguish these in the query to be able to capture only the actually executing the DDL operation?
ID appreciate any advice
Thank you very much
Rgdsselect osuser, machine, process, program, AUDSID, sid, SERIAL# from v$session where SID=USERENV('sid') /
Published by: JohnWatson on November 23, 2012 14:32
addedtags
-
Convert a single column into multiple lines
Hi people,
I have a task to display a single column into multiple lines (for use in LOV)
For Ex:
The column consistes of value such as 98,78,67,68,34,90. -It's a unique column values where none of the values can be ' number that is separated by commas
Then we must view it as
98
78
67
68
34
90
-under the number of lines (no lines can be ' do not number).
Thanks in advanceTry this...
SQL> ed Wrote file afiedt.buf 1 select regexp_substr('98,78,67,68,34,90', '[^,]+',1,level) Value 2 from dual 3* connect by level <= regexp_count('98,78,67,68,34,90',',') + 1 SQL> / VALUE ----------------- 98 78 67 68 34 90 6 rows selected.
Thank you!
Maybe you are looking for
-
Delete the content of new tabs
When you click to add a new tab, I get yahoo home page... I want to search (Google) or a cache...
-
I just plugged my Windows PC to the scanner, a printer and copier HP C4200. It prints well but when I try to scan, it says "USB not connected". It is connected. My daughter has used this printer on its products Mac and says it has never analyzed i
-
Qosmio F30: Is there a way to get the remote to work directly with built in receiver
My remote control Media Center only works when I plug the Receiver USB on my Qosmio F30 yet will work directly to the laptop with the vista media center pre program. Is there a way to get my remote to work directly on the built-in receiver? Steve.
-
My printer (Canon MG5250) stopped printing. I can copy and scan.
What happens is... I click to print something from Windows, but what I get out of the computer is the header (which normally gives the time and Page number) and at the bottom of the page I usually get..."file://C:\users\etc. Is there anything you can
-
Acer liquid gallant duo, E350 and no internet
I have a new Acer E350 liquid Gallant Duo. A SIM (vodafone) is my work and only for telephone conversations, the other that I bought is a prepaid internet SIM (AH). With both I can't get a connection to the internet. What I am doing wrong? Vodafone i