Query with some rows I need in 1 row
I have this:
FK_Field1, Description
1..................A
1
..B
2
..A
1
..C
3
..E
3
..G
And I need to do a query with this result:
FK_Field1, Description
1
..A, B, C
2
..A
3
..E, G
How can I do it?????
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
Similar Messages
-
CSV creation through PLSQL having issue with some rows of data
Hi,
having issue with in some rows of data which is created by the PLSQL code.
Issue description
- 50000 rows of data in my CSV
-around 20 fileds in a row
- in some the row (in 50000 rows) some fields (20 rows of data) are returning empty as result but actually my query returns data for these fields
Hope the issue is clear
Code given below
CREATE OR REPLACE FUNCTION TSC_OM_AUDIT(ERR_DESC IN OUT VARCHAR2,
WEB_FILE_URL IN OUT VARCHAR2 ) RETURN BOOLEAN IS
--Variable Declaration
L_buff_line VARCHAR2(500);
L_hdr_str VARCHAR2(32700);
L_selling_UOM VARCHAR2(5);
L_prim_bar_code VARCHAR2(30);
L_status_pri_bar VARCHAR2(2);
L_multpl_bar_exist VARCHAR2(2);
L_multpl_prim_bar_exist VARCHAR2(2);
L_prim_simp_pack VARCHAR2(30);
L_staus_prim_simp_pack VARCHAR2(2);
L_mupl_prim_pack_exist VARCHAR2(2);
L_prim_supp_prim_simpl_pack VARCHAR2(15);
L_prim_sim_supp_to_TPNB VARCHAR2(2);
L_sel1 VARCHAR2(200);
L_sel2 VARCHAR2(200);
L_sel3 VARCHAR2(200);
L_item_till_desc VARCHAR2(200);
L_lengh1 VARCHAR2(200);
L_width1 VARCHAR2(200);
L_height1 VARCHAR2(200);
L_lengh2 VARCHAR2(200);
L_width2 VARCHAR2(200);
L_height2 VARCHAR2(200);
L_lengh3 VARCHAR2(200);
L_width3 VARCHAR2(200);
L_height3 VARCHAR2(200);
--Item type
CURSOR C_ITEM is
select im.item L_item,
im.status L_status,
im.item_desc L_item_desc,
'Regular' L_item_type,
im.dept L_dept,
im.class L_class,
im.subclass L_subclass,
'N/A' L_CW_item_order_type,
'N/A' L_CW_item_sale_type,
im.standard_uom L_standard_uom,
NULL L_selling_uom,
im.tsl_base_item L_tsl_base_item
from item_master im
where im.item_number_type='TPNB'
-- and im.last_update_id = 'DATALOAD'
-- and im.create_datetime>=to_timestamp('2010-11-05 10:57:47','YYYY-MM-DD HH24:MI:SS')
and im.sellable_ind='Y'
and im.orderable_ind='Y'
and im.inventory_ind='Y'
and im.item_xform_ind='N'
and im.catch_weight_ind='N'
and rownum<10;
--order by im.item asc;
Cursor C_Selling_UOM (tpnb varchar2) is
select selling_uom
from rpm_item_zone_price
where item = tpnb;
Cursor C_prim_bar (tpnb varchar2) is
select item,
status
from item_master iem
where item_parent = tpnb
and iem.primary_ref_item_ind ='Y';
Cursor C_multi_bar_exit (tpnb varchar2) is
select count(*)
from item_master iem
where item_parent = tpnb;
Cursor C_multpl_prim_bar_exist (tpnb varchar2) is
select count(*)
from item_master
where item_parent = tpnb
and primary_ref_item_ind ='Y';
Cursor C_staus_prim_simp_pack (tpnb varchar2) is
select piem.pack_no,
iem.status
from item_master iem,
packitem piem
where piem.item = tpnb
and piem.pack_no = iem.item
and iem.tsl_prim_pack_ind ='Y';
Cursor C_multpl_prim_pack_exist (tpnb varchar2) is
select count(*)
from item_master iem,
packitem piem
where piem.item = tpnb
and piem.pack_no = iem.item
and iem.tsl_prim_pack_ind ='Y';
Cursor C_prim_supp_prim_simpl_pack (tpnd varchar2) is
select supplier
from item_supplier
where item = tpnd
and primary_supp_ind= 'Y';
Cursor C_prim_sim_supp_to_TPNB (tpnb varchar2,suppl number) is
select 'Y'
from item_supplier
where item = tpnb
and supplier = suppl;
Cursor C_item_descretion_SEL (tpnb varchar2) is
select sel_desc_1,
sel_desc_2,
sel_desc_3
from tsl_itemdesc_sel
where item =tpnb;
Cursor C_item_till_descretion (tpnb varchar2) is
select till_desc
from tsl_itemdesc_till
where item=tpnb;
Cursor C_EA (tpnb varchar2,suppl number) is
select length,
width,
height
from item_supp_country_dim
where item= tpnb
and supplier = suppl
and dim_object='EA';
Cursor C_CS (tpnb varchar2,suppl number) is
select length,
width,
height
from item_supp_country_dim
where item= tpnb
and supplier = suppl
and dim_object='TYUNIT';
Cursor C_TRAY (tpnb varchar2,suppl number) is
select length,
width,
height
from item_supp_country_dim
where item= tpnb
and supplier = suppl
and dim_object='TRAY';
BEGIN
--INITIAL
WEB_FILE_URL := TSC_RPT_GRS_EXL_GEN.WEB_URL||TSC_RPT_GRS_EXL_GEN.OPEN_FILE;
TSC_RPT_GRS_EXL_GEN.put_line('Poland Production Cutover');
TSC_RPT_GRS_EXL_GEN.skip_line;
l_hdr_str := 'L_item_TPNB,L_status,L_item_desc,L_item_type,L_section,L_class,L_subclass,L_cw_order_type,L_cw_sale_type,L_std_UOM,L_selling_UOM,'||
'L_base_item,L_prim_bar_code,L_status_pri_bar,L_multpl_bar_exist,L_multpl_prim_bar_exist,L_prim_simple_pack,L_staus_prim_simp_pack,L_mupl_prim_pack_exist,'||
'L_prim_supp_prim_simpl_pack,L_prim_sim_supp_to_TPNB,L_sel1,L_sel2,L_sel3,L_item_till_desc,L_lengh1,L_width1,L_height1,L_lengh2,L_width2,L_height2,L_lengh3,L_width3,L_height3';
l_hdr_str := TSC_RPT_GRS_EXL_GEN.CONVERT_SEPARATOR(l_hdr_str);
TSC_RPT_GRS_EXL_GEN.put_line(l_hdr_str);
for rec_c_item in C_ITEM
LOOP
open C_Selling_UOM (rec_c_item.L_item);
fetch C_Selling_UOM into L_selling_UOM;
close C_Selling_UOM;
open C_prim_bar (rec_c_item.L_item);
fetch C_prim_bar into L_prim_bar_code,L_status_pri_bar;
close C_prim_bar;
open C_multi_bar_exit (rec_c_item.L_item);
fetch C_multi_bar_exit into L_multpl_bar_exist;
close C_multi_bar_exit;
IF to_number(trim(L_multpl_bar_exist)) > 1 THEN
L_multpl_bar_exist:='Y';
ELSE
L_multpl_bar_exist:='N';
END IF;
open C_multpl_prim_bar_exist (rec_c_item.L_item);
fetch C_multpl_prim_bar_exist into L_multpl_prim_bar_exist;
close C_multpl_prim_bar_exist;
IF to_number(trim(L_multpl_prim_bar_exist)) > 1 THEN
L_multpl_prim_bar_exist:='Y';
ELSE
L_multpl_prim_bar_exist:='N';
END IF;
open C_staus_prim_simp_pack (rec_c_item.L_item);
fetch C_staus_prim_simp_pack into L_prim_simp_pack,L_staus_prim_simp_pack;
close C_staus_prim_simp_pack;
open C_multpl_prim_pack_exist (rec_c_item.L_item);
fetch C_multpl_prim_pack_exist into L_mupl_prim_pack_exist;
close C_multpl_prim_pack_exist ;
IF to_number(trim(L_mupl_prim_pack_exist)) > 1 THEN
L_mupl_prim_pack_exist:='Y';
ELSE
L_mupl_prim_pack_exist:='N';
END IF;
open C_prim_supp_prim_simpl_pack (trim(L_prim_simp_pack));
fetch C_prim_supp_prim_simpl_pack into L_prim_supp_prim_simpl_pack;
close C_prim_supp_prim_simpl_pack ;
open C_prim_sim_supp_to_TPNB (rec_c_item.L_item,to_number(trim(L_prim_supp_prim_simpl_pack)));
fetch C_prim_sim_supp_to_TPNB into L_prim_sim_supp_to_TPNB;
close C_prim_sim_supp_to_TPNB ;
open C_item_descretion_SEL (rec_c_item.L_item);
fetch C_item_descretion_SEL into L_sel1,L_sel2,L_sel3;
close C_item_descretion_SEL ;
open C_item_till_descretion (rec_c_item.L_item);
fetch C_item_till_descretion into L_item_till_desc;
close C_item_till_descretion ;
open C_EA (rec_c_item.L_item,to_number(trim(L_prim_supp_prim_simpl_pack)));
fetch C_EA into L_lengh1,L_width1,L_height1;
close C_EA ;
open C_CS (rec_c_item.L_item,to_number(trim(L_prim_supp_prim_simpl_pack)));
fetch C_CS into L_lengh2,L_width2,L_height2;
close C_CS ;
open C_TRAY (rec_c_item.L_item,to_number(trim(L_prim_supp_prim_simpl_pack)));
fetch C_TRAY into L_lengh3,L_width3,L_height3;
close C_TRAY ;
L_buff_line := TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_item), TRUE)||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_status))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_item_desc))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_item_type))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_dept))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_class))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_subclass))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_CW_item_order_type))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_CW_item_sale_type))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_standard_uom))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_selling_UOM)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(rec_c_item.L_tsl_base_item))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_prim_bar_code)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_status_pri_bar)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_multpl_bar_exist)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_multpl_prim_bar_exist)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_prim_simp_pack)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_staus_prim_simp_pack)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_mupl_prim_pack_exist)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_prim_supp_prim_simpl_pack)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_prim_sim_supp_to_TPNB)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_sel1)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_sel2)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_sel3)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_item_till_desc)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_lengh1)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_width1)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_height1)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_lengh2)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_width2)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_height2)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_lengh3)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_width3)))||
TSC_RPT_GRS_EXL_GEN.PAD_COMMA(to_char(trim(L_height3)));
TSC_RPT_GRS_EXL_GEN.PUT_LINE(L_buff_line);
L_selling_UOM :=NULL;
L_prim_bar_code :=NULL;
L_status_pri_bar :=NULL;
L_multpl_bar_exist :=NULL;
L_multpl_prim_bar_exist :=NULL;
L_prim_simp_pack :=NULL;
L_staus_prim_simp_pack :=NULL;
L_mupl_prim_pack_exist :=NULL;
L_prim_supp_prim_simpl_pack :=NULL;
L_prim_sim_supp_to_TPNB :=NULL;
L_sel1 :=NULL;
L_sel2 :=NULL;
L_sel3 :=NULL;
L_item_till_desc :=NULL;
L_lengh1 :=NULL;
L_width1 :=NULL;
L_height1 :=NULL;
L_lengh2 :=NULL;
L_width2 :=NULL;
L_height2 :=NULL;
L_lengh3 :=NULL;
L_width3 :=NULL;
L_height3 :=NULL;
END LOOP;
TSC_RPT_GRS_EXL_GEN.close_file;
return TRUE;
EXCEPTION WHEN OTHERS THEN
ERR_DESC := '['||SQLCODE||']-'||SUBSTR(SQLERRM,1,200);
return FALSE;
END TSC_OM_AUDIT;
Please suggest something on this
Regards,
Shamed HHi Shamid,
This forum is only for questions regarding the SQL Developer tool. Please post in Forum Home > Database > SQL and PL/SQL:
PL/SQL
Regards,
Gary
SQL Developer Team -
Hi,
maybe execute the expdp for some rows (for example 100) for all tables in one schema?
I know that I can execute this for all rows, but not for a subset of rows.
many thanks to all.
LainLain wrote:
you mean this?
QUERY Predicate clause used to export a subset of a table.I want export all the first 100rows of each table in the schema USERS
many thanksYes,
And your expdp query should be like
expdp username/password schemas=<schema> directory=temp_dir query=\"where rownum \< 1 \"Regards
Anurag -
Joining query with single row result
dear all,
i have two tables
create table item(item_id number primary key,
item_desc varchar2(200));
create table item_properties(item_id number references item(item_id),
property_name varchar2(20),
property_value varchar2(100));i insert the following records
insert into items values(1,'CPU');
insert into item_properties values(1,'RAM','2gb');
insert into item_properties values(1,'PROCESSOR','2ghz');
insert into item_properties values(1,'HARDDISK','2ghz');
commit;now i want a query which produce the following results
item_id RAM PROCESSOR HARDDISK
1 2gb 2ghz 2TBHow to generate this result?
i have create a query but it generate multiple rows, instead i need in a single row like above.
select i.item_id,p.property_value from items i , item_properties p
where i.item_id=p.item_id and i.item_id=1;Kind thanks.
Edited by: Maahjoor on May 7, 2013 12:22 AMselect i.item_id,
max(decode(p.property_name,'RAM',p.property_value)) ram,
max(decode(p.property_name,'PROCESSOR',p.property_value)) processor,
max(decode(p.property_name,'HARDDISK',p.property_value)) hd
from items i , item_properties p
where i.item_id=p.item_id
and i.item_id=1
group by i.item_id;Or pivot in 11g
with details as
select i.item_id,p.property_name,p.property_value
from item i , item_properties p
where i.item_id=p.item_id
and i.item_id=1
select *
from details
pivot
max(property_value) for property_name in ('RAM','PROCESSOR','HARDISK')
);Edited by: jeneesh on May 7, 2013 1:04 PM -
How to write multi row sub query with the row containing range of values?
Hi all,
I have to include a column which contains weight ranges and it should come fom table called "report_range_parameters"
The following query will reutrn those weight ranges.
select report_parameter_min_value || ' -> ' || report_parameter_max_value
from report_range_parameters
WHERE report_range_parameters.report_parameter_id = 2359
and report_range_parameters.report_parameter_group = 'GVW_GROUP'
and report_range_parameters.report_parameter_name = 'GVW_NAME'
The below query should return the values group by those weight ranges.
How could I write that sub query?
select SUM(NVL("Class 0", 0)) "Class 0" ,
SUM(NVL("Class 1", 0)) "Class 1" ,
SUM(NVL("Class 2", 0)) "Class 2" ,
SUM(NVL(" ", 0)) "Total"
FROM (
SELECT report_data.bin_start_date_time start_date_time,
SUM(DECODE(report_data.gvw, 0, report_data.gvw_count, 0)) "Class 0" ,
SUM(DECODE(report_data.gvw, 1, report_data.gvw_count, 0)) "Class 1" ,
SUM(DECODE(report_data.gvw, 2, report_data.gvw_count, 0)) "Class 2" ,
SUM(NVL(report_data.gvw_count, 0)) " "
FROM report_data
GROUP BY report_data.bin_start_date_time
) results
RIGHT OUTER JOIN tmp_bin_periods
ON results.start_date_time >= tmp_bin_periods.bin_start_date_time
AND results.start_date_time < tmp_bin_periods.bin_end_date_time
GROUP BY tmp_bin_periods.bin_start_date_time,
tmp_bin_periods.bin_end_date_time Thanks.
Edited by: user10641405 on Jun 15, 2009 3:14 PM
Edited by: user10641405 on Jun 15, 2009 3:17 PMHi,
Assuming the following 4 things:
(1) report_range_parameters contains data like this, from your [previous thread|http://forums.oracle.com/forums/message.jspa?messageID=3541079#3541079]
id group name min_value max_value
1 gvw_group gvw_name 0 5
2 gvw_group gvw_name 5 10
3 gvw_group gvw_name 10 15(2) max_value is actually outside the range (that is, a value of exactly 5.000 is counted in the '5->10' range, not the '0->5' range)
(3) the range has to match some column x that is in one of the tables in your main query
(4) You want to add that column x to the GROUP BY clause
then you shopuld do somehting like this:
select SUM(NVL("Class 0", 0)) "Class 0" ,
SUM(NVL("Class 1", 0)) "Class 1" ,
SUM(NVL("Class 2", 0)) "Class 2" ,
SUM(NVL(" ", 0)) "Total"
, report_parameter_min_value || ' -> ' || report_parameter_max_value AS weight_range -- New
FROM (
SELECT report_data.bin_start_date_time start_date_time,
SUM(DECODE(report_data.gvw, 0, report_data.gvw_count, 0)) "Class 0" ,
SUM(DECODE(report_data.gvw, 1, report_data.gvw_count, 0)) "Class 1" ,
SUM(DECODE(report_data.gvw, 2, report_data.gvw_count, 0)) "Class 2" ,
SUM(NVL(report_data.gvw_count, 0)) " "
FROM report_data
GROUP BY report_data.bin_start_date_time
) results
RIGHT OUTER JOIN tmp_bin_periods
ON results.start_date_time >= tmp_bin_periods.bin_start_date_time
AND results.start_date_time < tmp_bin_periods.bin_end_date_time
LEFT OUTER JOIN report_range_parameters -- New
ON x >= report_parameter_min_value -- New
AND x < report_parameter_max_value -- New
AND report_range_parameters.report_parameter_id = 2359 -- New
and report_range_parameters.report_parameter_group = 'GVW_GROUP' -- New
and report_range_parameters.report_parameter_name = 'GVW_NAME' -- New
GROUP BY tmp_bin_periods.bin_start_date_time,
tmp_bin_periods.bin_end_date_time
, x -- New -
I Have Macbook Pro with Snow Leopard and all the softwares are updated. Safari works in the sites that Firefox doesn't work.
Hi,
You can try the latest in the [https://www.mozilla.org/en-US/firefox/all-older.html 3.6 series] which is still supported. -
Repeating frame not visible when the query returns no rows
I've developed a report whose output looks like this:
Subinventory | Part Code |Part Description |Ordered Qty | Received Qty
Mentone St | BATT | non serialised item | |
Mentone St | SONY | spare parts MIN MAX | 30| 0
In the above report
subinventory, Part Code, Part description are in one repeating frame and Ordered and received qty are in other repeating frame.
for a perticular part code there may not be ordered or received quantities. Means the seond query fetches no rows for the perticulat partcode. In that case report is showing null(blank) but I want to print ZERO there.
If I use NVL in the query it'll effect only when the query fetches some rows.
I've tried with formula columns. for example in the formula column
IF :ordered_qty IS NULL THEN
v_ordered_qty :=0;
ELSE
v_ordered_qty := :ordered_qty;
END IF;
return(v_ordered_qty);
I've assigned this formula column as source to the Ordered Qty Filed. Then also its not working.
Any help in this regards is highly apprecialted
regards,
Vijmay be you can modify your code like below:
SELECT i.subinventory, i.part_code, i.part_description, i.min_qty, i.max_qty,
NVL (j.quantity, 0) ordered_qty,
NVL (j.quantity_delivered, 0) received_qty
FROM (SELECT DISTINCT c.secondary_inventory subinventory,
b.segment1 part_code, b.description part_description,
c.min_minmax_quantity min_qty,
c.max_minmax_quantity max_qty, b.inventory_item_id,
b.organization_id
FROM mtl_system_items_b b,
mtl_item_sub_inventories_all_v c
WHERE b.inventory_item_id = c.inventory_item_id
AND b.organization_id = c.organization_id
AND UPPER (c.secondary_inventory) =
NVL (UPPER (DECODE (:p_sub_inv,
'ALL', '',
:p_sub_inv
UPPER (c.secondary_inventory)
)) i,
(SELECT mtrl.inventory_item_id, mtrl.organization_id,
mtrl.to_subinventory_code,
NVL (SUM (mtrl.quantity), 0) quantity,
NVL (SUM (mtrl.quantity_delivered), 0) quantity_delivered
FROM mtl_txn_request_lines mtrl, mtl_system_items_b msi
WHERE mtrl.inventory_item_id = msi.inventory_item_id
AND mtrl.organization_id = msi.organization_id
AND mtrl.reference_type_code = 2
AND UPPER (mtrl.to_subinventory_code) =
NVL (UPPER (DECODE (:p_sub_inv, 'ALL', '', :p_sub_inv)),
UPPER (mtrl.to_subinventory_code)
AND TRUNC (mtrl.creation_date)
BETWEEN NVL (TRUNC (TO_DATE (:p_from_date,
'yyyy/mm/dd hh24:mi:ss'
TRUNC (mtrl.creation_date)
AND NVL (TRUNC (TO_DATE (:p_to_date,
'yyyy/mm/dd hh24:mi:ss'
TRUNC (mtrl.creation_date)
GROUP BY mtrl.inventory_item_id,
mtrl.organization_id,
mtrl.to_subinventory_code) j
WHERE i.inventory_item_id = j.inventory_item_id(+)
AND i.organization_id = j.organization_id(+) -
MVC Event Handling with different rows of same table view
Hello friends,
I have a tableview with some rows.I have some columns in the tableview.First column contains the drop down list box and other columns are output fields.
I am allready able to populate the columns according to the selection of a value in the drop down listbox of the same row.
In the layout of view for the selectionmode attribute of tableview i have given 'lineedit'.
In the do_handle_event i am also able to get the current selected row of the tableview.
DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
selection = tv_data->selectedrowindex.
Scenario:I have selected the first row then i am selecting a value in the dropdown and able to populate their corresponding value in the corresponding output field of same row.
So the first row has the selected value in drop down listbox also the corresponding outputfield of same row also has the value.This i am doing by inserting it to the final internal table for the tableview according to currrent selected row .
Now i am going to select the second row.then i am selecting someother value in the dropdown listbox of the second row and filling the other columns correspondigly.I am able to do this for the secondrow.What i now need to do is i also want to see the first row with slected values correspondingly when the final view comes.ie i need both rows with corresponding values.
Similarly when selecting third row and other rows so on.
how to do this?
Thanks & Regards,
Renju.Hi Renju,
Try using MULTILINEDIT - this is used when you want to edit multiple rows all at once.
Cheers -
Huge difference in Execution time in same Query with different Parameter
Hi Experts,
We are facing an unique problem once we are executing the query in HANA SQL prompt. This Query was generated from BObj and executing in HANA system. Once this query running with following condition, it is taking almost 7-00 minute to execute and returning around 924 rows.
<< WHERE
Table__1."LOGSYS" IN ('RKGCLNT102')
AND
Table__1."CompanyCode" IN ('7240','7245')
AND
Table__1."Plant" IN ……………… >
However if we run the same query with some different plant, It is taking only 2 second. Please find the Query here.
<< WHERE
Table__1."LOGSYS" IN ('RKGCLNT102')
AND
Table__1."CompanyCode" IN ('7245','7600')
AND
Table__1."Plant" IN ……………… >
This is really an unexpected behavior and we are not able to get the actual reason why it is behaving like this.
Could anyone please help to analyze this issue to fine the root cause.
Thanks in Advance.
Regards
Satrajit.Hi there
Unfortunately you provided too few information to analyze the issue.
Maybe the underlying tables have very skew data and the first select has to read a larger share of the base tables.
Maybe the columns had been unloaded before and the first query had to load them into memory first.
Is the runtime always bad with the one and always good with the other set of parameters?
Have you checked the PlanViz for both versions? How do these differ?
- Lars -
Issue with SQL Query with Presentation Variable as Data Source in BI Publisher
Hello All
I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
select TILE4,max(APPTS), 'Top Count' from
SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0)) AS TILE4,
c4 as dept,c6 as month FROM
select sum(case when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
sum(case when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
T802.NAME_LEVEL_6 as c3,
T802.NAME_LEVEL_1 as c4,
T6172.CALENDARMONTHNAMEANDYEAR as c5,
T6172.CALENDARMONTHNUMBERINYEAR as c6,
T802.DEPT_CODE as c7
from
DW_date_DIM T6736 /* z_dim_date */ ,
DW_MONTH_DIM T6172 /* z_dim_month */ ,
DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
where ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 = '@{PV_D}{RSD}'
and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6) and substr('@{Month_END}',8,13))
and (T6736.TYPE in ('Call Center', 'LSM')) )
group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
order by c4, c3, c6, c7, c5
))where tile4=3 group by tile4
When I try to view data after creating the data set, I get the following error:
Failed to load XML
XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
So I know it is the PV that's causing this error.
How can I work around it?
There is no way to create equivalent report without using the direct sql..
Thanks in advanceI have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
or more descriptive errors.
//Jonas -
Need help with writing a query with dynamic FROM clause
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
Any pointers will be appreciated.
Thanks
rogers42Hi,
rogers42 wrote:
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'
Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
-- Preliminary Query:
COLUMN my_table_name_col NEW_VALUE my_table_name
SELECT table_name AS my_table_name_col
FROM all_tables
WHERE owner = 'SCOTT'
AND table_name LIKE 'E%';
-- Main Query:
SELECT COUNT (*) AS cnt
FROM scott.&my_table_name
;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
Edited by: Frank Kulash on Aug 11, 2011 2:30 PM -
Report on BEx query with 2 structures (one in rows and one in columns)
Hi, experts! I have to make Crystall report on BEx query with 2 structures, one in columns (with KF's), and one in rows. Is it possible to create such report? Because when I create such report, I cant see fields in structures, only characteristics fields.
Ok, I found samr problem in another thread. Sorry.
Edited by: Mikhail Sychev on Dec 5, 2009 9:53 PMHey Flora,
Happy to hear that its working now.
Answering your question, again its upto the connection and report format you are using. Based on your question i hope you your report output should be like this.
You cannot map to two labels for the series, again this report format is possible only in cross tab through Webi. I would suggest you to concatenate the material and month in a dimension in webi like below.
I have done the concatenation in excel level, i would suggest you to do that in webi. Try to reduce the formula as much in excel.
or
If you are using Query browser connection, then i would suggest you to create a separate report which will display the actual vs plan material wise, here you need to pass the material as a prompt.
Hope this helps in clear, please revert me for any clarification. -
Need help in optimizing the query with joins and group by clause
I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
CREATE TABLE FILE_STATUS
(FILE_ID VARCHAR2(14),
FILE_NAME VARCHAR2(20),
CARR_CD VARCHAR2(5),
TOT_REC NUMBER,
TOT_SUCC NUMBER);
CREATE TABLE COMM
(SRC_FILE_ID VARCHAR2(14),
REC_ID NUMBER,
STATUS CHAR(1));
INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
INSERT INTO COMM VALUES ('12345678', 1, 'T');
INSERT INTO COMM VALUES ('12345678', 3, 'T');
INSERT INTO COMM VALUES ('12345678', 4, 'P');
INSERT INTO COMM VALUES ('12345678', 5, 'P');
COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
SELECT
FS.CARR_CD
,FS.FILE_NAME
,FS.FILE_ID
,FS.TOT_REC
,FS.TOT_SUCC
,NVL(C.TOT_TRANS, 0) TOT_TRANS
FROM FILE_STATUS FS
LEFT JOIN
SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
FROM COMM
WHERE STATUS = 'T'
GROUP BY SRC_FILE_ID
) C ON C.SRC_FILE_ID = FS.FILE_ID
WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
from (select fs.carr_cd,
fs.file_name,
fs.file_id,
fs.tot_rec,
fs.tot_succ,
count(case
when c.status = 'T' then
1
else
null
end) over(partition by c.src_file_id) tot_trans,
row_number() over(partition by c.src_file_id order by null) rn
from file_status fs
left join comm c
on c.src_file_id = fs.file_id
where carr_cd = 'LIBM')
where rn = 1;
CARR_CD FILE_NAME FILE_ID TOT_REC TOT_SUCC TOT_TRANS
LIBM CM_LIBM.TXT 12345678 5 4 2
LIBM CM_LIBM.TXT 12345677 10 0 0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
select fs.carr_cd,
fs.file_name,
fs.file_id,
fs.tot_rec,
fs.tot_succ,
count(case
when c.status = 'T' then
1
else
null
end) over(partition by c.src_file_id) tot_trans,
row_number() over(partition by c.src_file_id order by null) rn
from file_status fs
left join comm c
on c.src_file_id = fs.file_id
where carr_cd = 'LIBM';
CARR_CD FILE_NAME FILE_ID TOT_REC TOT_SUCC TOT_TRANS RN
LIBM CM_LIBM.TXT 12345678 5 4 2 1
LIBM CM_LIBM.TXT 12345678 5 4 2 2
LIBM CM_LIBM.TXT 12345678 5 4 2 3
LIBM CM_LIBM.TXT 12345678 5 4 2 4
LIBM CM_LIBM.TXT 12345677 10 0 0 1 -
A filter value for Query is set with some value automatically
Hello SAP sourcing Guru!
I created a query which has several filters.
Some of Filter's type is VLV.
When I preview the query somehow the filter values are already set with some value even though I did not set the default value.
For example, filter name is Region and there are four regions: Asia, NA, Europe, and SA.
I want to select one of them from drop-down menu. But Asia was already selected when I clicked the preview button for the query. I want to see "Please Select" instead of Asia from drop-down menu. I did not select "Prefill value from cache" for the filter. I made the filter Optional only. I did not set Default Value either for the filter.
Any clues?
Thank you for your response in advance.Hi,
In the Default value field of the filter prompts, you need to mention the Class Reference ID of the corresponding field. E.g., if you have Contract document phase as a filter, then in that if you want to display a blank or none value, then you should use null:2016.
Similarly for vlv type, the system has a value 616. Hence if you want to display a None value insteead of Asia, use the following in the Default value field:
0:616:null.
The way to find the class reference ID is to goto the RG > Class Reference > Look for the field that you are attempting to default on.
Hope this helps,
Vikram -
How to insert some strings in a query with the clausule 'in' in a procedure
Hello fellows.
Do you know how to insert some strings in a query with the clausule 'in' in a procedure (with a variable)?.
I tell us my problem with an example:
I want to use this select but introducing a variable instead the 'value1', 'value2':
select * from table1 where field1 in ('value1', 'value2');
if I declare the variable var1 as:
TC_VAR1 CONSTANT VARCHAR2(50) := '''value1'',''value2'''
and I use it as:
select * from table1 where field1 in (TC_VAR1);
It doesn't work because Oracle takes TC_VAR1 as an all string. I think Oracle takes it as this:
select * from table1 where field1 in ('value1, value2');
If I use the data type TABLE, I don't know how to use well:
TYPE varchar2_table IS TABLE OF VARCHAR2(10);
tb_var varchar2_table;
select * from table1 where field1 in (tb_var);->It returns an error and there ins't an method that it returns all values.
A curious case is that if I have a sql script (for example script1.sh) with this query:
select * fromt able1 where field1 in (&1)
and I invoke this script as
script1.sh "'''value1'',''value2'''". It works
Can anybody helps me?.
Thanks.Thanks to all. Really.
First, sorry for my English. It's horrible. Thank to all for understand it (my English).
I've resolved my problem with these links:
ORA-22905: cannot access rows from a non-nested table item
and
http://stackoverflow.com/questions/896356/oracle-error-ora-22905-cannot-access-rows-from-a-non-nested-table-item
At last, I have used someting like this:
DECLARE
number_table_tmp NUM_ARRAY:=NUM_ARRAY(410673, 414303, 414454, 413977, 414042, 414115, 413972, 414104, 414062);
BEGIN
FOR c1 IN (SELECT par_id, 1 acc_vdo_id FROM SIG_VIS_CAM
WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))
UNION ALL
SELECT par_id, 2 acc_vdo_id FROM SIG_ACCAO a
WHERE par_id IN (SELECT * FROM TABLE(number_table_tmp))) LOOP
NULL;
END LOOP;
END;
but first I had to create the type NUM_ARRAY like this:
CREATE TYPE subjectid_tab AS TABLE OF NUMBER INDEX BY binary_integer;
THANK YOU, GUYS. YOU ARE THE BESTS. ;-)
Edited by: user12249099 on 08-sep-2011 7:37
Edited by: user12249099 on 08-sep-2011 7:37
Maybe you are looking for
-
Keep getting "Account Locked" message every time I try to access iTunes.
Every time I attempt to access iTunes from my iPod Touch, I get a box popup telling me my account has been locked. This is getting really annoying. I have a Droid 2 and never have account problems like this. What is up with Apples ignorance on this
-
Issue with getting the entire spooled job into the pdf document
Hi All, My scheduled job runs fine and completes successfully but it appears to have some issues with getting the entire spooled job into the pdf document which it sends to a an end user.Has anyone encountered it before.Your kind assistance would be
-
Let's say I have an XML data looking like this: <VFPData> <issuedetails> <id>26</id> <custno>04000</custno> </issuedetails> <sku35576> <action>Audit Existing Inventory</action> <selected>false</selected> </sku35576> </VFPData>
-
Windows Internet Explorer 9 will not allow me to download Firefox. How can I fix this?
Running Windows Vista with Internet explorer 9. Need to download Mozilla Firefox. I get to the Firefox download page, click on the Download button. I get at message asking if I would like to save the Firefox Setup Stub, which I did. A small extra win
-
Hi, We are doing EHP4 Upgrade from a EHP4 Ready SR1 system on AIX 5.3/DB2 UDB. While running EHPi with SDT version 7.00 and using the command ./STARTUP guistart=on it is invoking the SDT Gui initial screen(the famous SAPinst Gui first screen with fac