Master-detail: one detail row with multiple columns
Hi All,
I have a normal master-detail situation in the databse, in the form however all detail rows should be displayed in one single row, using more columns. The number of details are limited, so I can use a predefined number of text-items.
Any ideas on how to implement this?
Regards,
Michiel
create a function that returns your details. e.g. :
function get_detail (P_PK, P_rownum) ...
let's use the example dept and emp. Your master is dept. Your detail is emp. deptno is the PK for the master table.
you have in your form multi-records of dept and maybe 5 items for employees. The name of the text-items TI_data_1 .. TI_data_5. In the post-query-trigger you code :
:DEPT.TI_data_1 := get_detail (:DEPT.DEPTNO, 1);
:DEPT.TI_data_2 := get_detail (:DEPT.DEPTNO, 2);
if you need more columns create a loop and use the built-in COPY for assigning the detail-values to the text-items.
the get_detail e.g. is a select-statement:
SELECT ENAME
FROM EMP
WHERE DEPTNO = P_PK
AND rownum = P_rownum
ORDER BY EMPNO
try it
Gerd
Similar Messages
-
Convert multiple rows to one row with multiple columns
Hi
i have a table Match_1 with 2 columns 'Source' and 'target'.One source can have multiple targets and that number could be anything
CREATE TABLE Match_1
Source CHAR(1),
Target CHAR(1)
INSERT INTO Match_1 VALUES ('A', 'B');
INSERT INTO Match_1 VALUES ('A', 'C');
INSERT INTO Match_1 VALUES ('A', 'D');
INSERT INTO Match_1 VALUES ('A', 'E');
INSERT INTO Match_1 VALUES ('V', 'X');
INSERT INTO Match_1 VALUES ('V', 'Y');
INSERT INTO Match_1 VALUES ('V', 'X');
INSERT INTO Match_1 VALUES ('V', 'W');
COMMIT;
i need to get my output in the below format
Source target 1 target 2 target 3 target 4 target n
A B C D
V X Y Z W
Could you please provide me the required SQL.
REgards
-LearnsequelWhat is your database version (4 digit) ? also my example won't be generate columns for your information:
it will produce a result like that :
select source, listagg(target,',') within group (order by target)
from match_1
group by source;
A B,C,D,E
V W,X,X,Yps: in previos post, I wrote "with" word wrong in sql. -
Repeat "Detail a" section when using "Format with Multiple Columns" layout
I am using Crystal Reports for .NET (VS 2008) and I would like to get the "Detail a" section to repeat at top of a second column containing additional data in "Detail b" section. Please see below for example, specifically "Detail a (2)". Any tips or help much appreciated.
Detail a (1)_____Detail a (2)
Detail b (1-1)___Detail b (2-3)
Detail b (1-2)___Detail b (2-4)
--Detail b (1-3)___Detail a (3)
Detail a (2)______--Detail b (3-1)
--Detail b (2-1)
--Detail b (2-2)
Thx, Scottthe format with multiple columns i dont believe will show you the value 2x, but allows you to display the values across instead of down.
i think you may want to use a sub report -
Convert one row to multiple column dynamic in smartform
i want to convert on row to multiple column in smartform.As number of column is not per define..Please suggest the way out in smartform
I saw a post and working perfect. The link is given below.
http://scn.sap.com/community/abap/blog/2013/10/06/the-case-of-dynamic-columns-in-smartform
Thanks to Eitan. -
Selectively Format Groups with Multiple Columns
I have a bit of an obscure task I've been trying to hammer out to no avail. I've searched quite a bit but can't seem to find anyone else who has attempted this. I have two group by statements, one is a category and the other is a rank. What I'm trying to do is organize the report so that there are category rows and below each category row is a set of columns for each rank with their associated values as such:
category1
rank1 rank2 rank3 rank4
value1 value1 value1 value1
value2 value2 value2 value2
category2
rank1 rank2 rank3
value1 value1 value1
value2 value2 value2
I've tried using details>Section Expert>>Layout>Format Groups with multiple column. Unfortunately, this applies to both groups putting the categories into columns instead of rows, making a mess. Does anyone know of a way to selectively put groups into columns and ensure alignment? In the above example the user would be able to compare rank values from multiple categories since they all line up. Any help with this would be very much appreciated.Hi,
Have you tried using a crosstab? Give this a shot:
1) Group the report on Category
2) Create a new group header section. Group Header b
3) Place a crosstab in this section
4) The columns would be the Rank field, I'm not sure about what you would like to show in the rows
5) The summarized field would be the Value field ofcourse
Let me know how this goes.
-Abhilash -
Find MIN, MAX of multiple rows from multiple columns
Hello,
I need to figure out how to pull the MIN/MAX of multiple rows from multiple columns into one column. Even if some are NULL/blank.
For Example: (C: Column, R: Row, N - NULL/Blank)
C:____1____2____3____ 4____Max
R:____20___22___13____4____*22*
R:____N____N____32____14___*32*
R:____N____12____N____N____*12*
That is, it always gives a value for MIN/MAX unless there are NO values in all the rows of the columns.
So if there is one value, it will select that for the MIN/MAX, as it's the smallest/biggest since there is nothing to compare it to.
Here is my current code:
CASE WHEN COLUMN 1 < COLUMN 2 THEN COLUMN 2 ELSE COLUMN 1 ENDHi Thank you for your feedback, unfortunately, I just found out that EVALUATE Function is disabled in our environment for security reasons, so the only other way I've discovered is this:
The problem is that none of the conditions in the case statement are met--so the column is set to null. You can add a WHEN statement (section 2 below) to catch the nulls. There are five cases to consider:
Case 1: begin insp > bad order
Case 2: begin insp < bad order
Case 3: bad order only (begin insp is NULL)
Case 4: begin insp only (bad order is NULL)
Case 5: both begin insp is NULL and bad order is NULL
1) If bgn-crm-insp-ob > report-bo-ob then bgn-crm-insp-ob
(Case 1)
CASE WHEN filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'bgn-crm-insp-ob') > filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'report-bo-ob') THEN filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'bgn-crm-insp-ob')
2) If report-bo-ob is NULL then bgn-crm-insp-ob
(Case 4, 5) for case 5, you will get NULL
WHEN filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'report-bo-ob') IS NULL THEN filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'bgn-crm-insp-ob')
3) Else report-bo-ob
(Cases 2, 3)
ELSE filter ("- Terminal Task Measures"."Task Reported DateTime (Local)" using "Task Detail"."Task Code" = 'report-bo-ob') END
Hopefully this works, I'll give feedback if it does, or if you have any further suggestions please submit, again, THANK YOU SO MUCH ANYWAYS! -
hello all ,
how to create a list with multiple columns ? can anyone share some examples or code snippetsWhat I would usually do is create a movieclip/sprite that contains a row with every column in it (each column being a textfield). Then pile up the rows one atop the other (using Actionscript) as they are populated with data.
-
Multipe rows to Multiple Columns - Oracle9i
Hi
I know there have been similar threads however I haven't found a suitable solution from them.
I'm using Oracle 9i and trying to convert multiple rows to multiple columns.
CREATE TABLE TEST_VALUES
CUSTOMER_ID NUMBER(10),
VAL VARCHAR2(100)
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(10,'VAL1');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(10,'VAL2');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(20,'VAL1');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(30,'VAL3');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(30,'VAL4');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(40,'VAL5');
INSERT INTO TEST_VALUES(CUSTOMER_ID,VAL)VALUES(40,'VAL6');
COMMIT;
SELECT * FROM TEST_VALUES
CUSTOMER_ID VAL
10 VAL1
10 VAL2
20 VAL1
30 VAL3
30 VAL4
40 VAL5
40 VAL6
I want one row per CUSTOMER_ID with two columns to store the values
CUSTOMER_ID FIRST_VAL SECOND_VAL
10 VAL1 VAL2
20 VAL1 NULL
30 VAL3 VAL4
40 VAL5 VAL6
There are only 6 possible 'VAL' values however there are a large number of CUSTOMER_id values. I tried DECODE as suggested elsewhere but that creates 6 columns. However I only want two output columns as there are no more than two values per customer.
If I had 11g I would try pivot, can anyone please suggest any solutions?
Many Thanks
GBThanks Bhushan, that was nearly what I was after. For CUSTOMER 20 it gave
20 VAL1 VAL1
so to make it
20 VAL1 NULL
I just changed your query slightly to
select distinct
customer_id,
min(val) over (partition by (customer_id)) val1,
CASE WHEN max(val) over (partition by (customer_id)) = min(val) over (partition by (customer_id)) THEN NULL
ELSE max(val) over (partition by (customer_id)) END val2
from test_values
order by customer_id
and that gives the correct results. Just checking the full data set now.
Thanks for your help. -
Post Author: vman
CA Forum: General
I am working a report that has had the details section format with multiple columns selected. I want to change the report and remove the check box, but it is grayed out. How can I get the report details section back to default without the detail size constraints?Post Author: rcoleman
CA Forum: General
Bearing in mind that I'm a relative newbie to the report writing/Crystal world...the only thing I can think of is that maybe the report was written using an older version of Crystal and this option wasn't available. Another possibility, if it's a sub-report, you might try making a copy of the sub-report saving it with the same name, deleting the old sub-report, replacing it with the copy you made. I know that has worked for me when I've had problems with the re-import when opening is greyed out. -
Treeview with multiple columns
I googled alot about creating a treeview with multiple columns similar to a listview in details mode with the added benefit of nodes and roots. I got some answers but I was wondering if visual 2008 itself has such an option, and if not what is my best
choice?
Debra has a questionI just wanted to know if in the visual studio 2008 itself there is an option to have a multi column treeview or a listview with nodes...
Debra has a question
Hi Debra,
>> a multi column treeview
As far as I know, the standard Microsoft .NET TreeView does not support columns, and if you want a tree control that supports columns, you could turn to the link from Tony:
#TreeView with Columns
http://www.codeproject.com/Articles/23746/TreeView-with-Columns
>>a listview with nodes
I made a research about “a listview with nodes” and found no results. I checked the ListView Class and did not find information about nodes.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey. -
I have 105 rows with alternating columns of No. sold
I have 105 rows with alternating columns of No. Sold and Amount Sold, for six different dates. I want the two totals columns on the right to sum every other column for the Total No. Sold and the same but one over for Total Amount Sold. I know how to do this for a single row, as I have done for the last totals row. How could I do the formula for all rows without entering it for each one, or if that is not possible, maybe I could copy the formula in some way to make it easier?
rogerfrombellingham wrote:
... I know how to do this for a single row, as I have done for the last totals row. How could I do the formula for all rows without entering it for each one, or if that is not possible, maybe I could copy the formula in some way to make it easier?
Yes, Roger, you can easily copy those formulas for all the rest of the 105 rows.
Select the two totals cells, click on the little circle in the lower right corner of the selection and drag it to the bottom.
Jerry -
Creating Select List with multiple columns
I want to create a select list with multiple columns. I followed the demo application model described in the by Denes Kubicek (Currently my reference for APEX !!)
The code is as follows:
CREATE OR REPLACE FUNCTION getcrops(p_cropid IN NUMBER)
RETURN VARCHAR2
IS
v_cropid VARCHAR2 (400);
v_fcode VARCHAR2 (400);
v_product VARCHAR2 (400);
v_var VARCHAR2 (400);
v_fname VARCHAR2 (400);
v_acres VARCHAR2 (400);
v_style_start VARCHAR2 (400);
v_style_end VARCHAR2 (400);
v_return VARCHAR2 (400);
BEGIN
FOR c IN (select "CROP"."CROPID" as "CROP ID",
"CROP"."FIELDCODE" as "FIELD CODE",
"CARROTPRODUCTLIST"."CARROTPRODUCTNAME" as "PRODUCT",
"VARIETYLIST"."VARIETYNAME" as "VARIETY",
"FIELD"."FIELDNAME" as "FIELD NAME",
"CROP"."SIZEINACRES" as "ACRES"
from "FIELD" "FIELD",
"CARROTPRODUCTLIST" "CARROTPRODUCTLIST",
"VARIETYLIST" "VARIETYLIST",
"CROP" "CROP"
where "CROP"."CARROTPRODUCTTYPE"="CARROTPRODUCTLIST"."CARROTPRODUCTID"
and "CROP"."VARIETYID"="VARIETYLIST"."VARIETYLISTID"
and "CROP"."FIELDID"="FIELD"."FIELDID")
LOOP
v_cropid := TO_CHAR (c.'CROP ID', 'FML999G999G999G999G990');
v_fcode := c.'FIELD CODE';
v_product := c.'PRODUCT';
v_var := c.'VARIETY';
v_fname :=c.'FIELD NAME';
v_acres :=c.'ACRES';
FOR i IN 1 .. 12 - LENGTH (c."CROP ID")
LOOP
v_cropid := v_cropid || ' ';
END LOOP;
FOR i IN 1 .. 12 - LENGTH (c.'FIELD CODE')
LOOP
v_fcode := v_fcode || ' ';
END LOOP;
FOR i IN 1 .. 12 - LENGTH (c.'PRODUCT')
LOOP
v_product := v_product || ' ';
END LOOP;
FOR i IN 1 .. 12 - LENGTH (c.'VARIETY')
LOOP
v_var := v_var || ' ';
END LOOP;
FOR i IN 1 .. 12 - LENGTH (c.'FIELD NAME')
LOOP
v_fname := v_fname || ' ';
END LOOP;
FOR i IN 1 .. 12 - LENGTH (c.'ACRES')
LOOP
v_acres := v_acres || ' ';
END LOOP;
v_return := v_cropid || v_fcode || v_product || v_var || v_fname || v_acres;
END LOOP;
RETURN v_return;
END;
I created this anonymous Pl/SQL function at a application level ..Then I followed up to create a select list with a function inside. However I could not create select list with the command suggested in the demo which is
select getcrops(cropid) d, cropid r from crop;
APEX (2.1) returns a error message. What am I missing ? Should the function be called from somewhere else after creating a regular select list..? Where the functions (Pl/SQL) should be ideally stored for application level access..? and for across application level access ? How can I check the function works good. Help is appreciated.Still really one column.
If they need to be independent then you've got to have three selection lists.
% -
Selection list with multiple columns
How can i create a selection list with multiple columns?
Still really one column.
If they need to be independent then you've got to have three selection lists.
% -
Select list with multiple columns
I want to create a select list with multiple column option. What are the options. Any developments in apex 3.0.1 ? Thanks in advance. I tried the tutorials by Kubicek.
I am kind of stuck to see the function entry inside LOV definition returns a error.Still really one column.
If they need to be independent then you've got to have three selection lists.
% -
GROUP BY with multiple columns.
I have little query about GROUP BY clause.
Sometimes we will give multiple column names in GROUP BY .If it behaves in the same way as ORDER BY (multiple columns) i would love to have an example where I can use GROUP BY multiple columns. Anyways howsoever it behaves it will be really appreciated if anyone can explain a scenario where GROUP BY with multiple columns can be used.
I know about the usage of aggregate functions with GROUP BY but using only one column.
Thanks..!!!Hi,
Group by is used for grouping of same records. check this bellow scenario
SELECT registrationid, dateofbirth, age FROM prawin62 WHERE registrationid = 22;
22 1/23/1975 54
22 5/18/2011 66
22 5/18/2011 66
22 5/18/2011 66
22 5/18/2011 66
22 5/18/2011 66SELECT registrationid, sum(age) FROM prawin62 WHERE registrationid = 22 GROUP BY registrationid;
22 384SELECT registrationid, dateofbirth, sum(age) FROM prawin62 WHERE registrationid = 22 GROUP BY registrationid, dateofbirth ;
22 5/18/2011 330
22 1/23/1975 54Thanks,
Praveen
Maybe you are looking for
-
on your information page it shows a firefox button in the left hand upper corner I don't have that button.
-
Fifth gen. iPod is not podcasting...
I recently discovered the joy of podcasts, especially the video ones. All of a sudden though, iTunes won't let me drag'n'drop new updates to my favorite video podcasts into my iPod. It says that my iPod "can't support" it which I know is a load of...
-
XPath expression for getting nodes based on date
Hello, using javax.xml.xpath.XPath (Java 5) I want to get only nodes with dates (element pubDate) greater then some provided date. What is the expression for getting, say only first two <item> nodes? Is it at all possible? Example XML document: <?xml
-
Vpnclient does it exist or alternatives
Hi I've just recently installed Solaris 10 x86 and one of the main uses I would use it for would be connecting to a network at my office. Is there a working vpnclient for the x86 platform? Thanks Jason
-
How to handle ok/add/update button
hi, the button ui=1 automatically changes in add/update /ok buttons .but how we handle update and add ivent through database. Pandey Sai I.S.