Count of selected rows
i want to count the selected rows or count of this executed query
error as Column Ambiguously defined
SELECT hp.party_name CustomerName,
COUNT(csi.incident_number) SRNumbercount,
csi.incident_number SRNumber,
csi.incident_date SRDate,
csi.close_date SRCloseDate,
csi.summary Summary,
csi.problem_code,
csi.incident_address SRAddress,
count(rowid)
FROM hz_parties hp,
hz_cust_accounts hca,
hz_contact_points hc,
cs_incidents_all_b csi,
ar_lookups arl
WHERE hca.cust_account_id =csi.account_id
AND hp.party_type IN ('PERSON','ORGANIZATION')
AND hp.status ='A'
AND hp.party_id = hca.party_id
AND hca.status ='A'
AND hp.party_id =hc.owner_table_id(+)
AND hc.owner_table_name(+) ='HZ_PARTIES'
AND hp.party_id =hca.cust_account_id
AND hc.contact_point_type(+)='PHONE'
AND hc.primary_flag(+) ='Y'
AND hc.status(+) ='A'
AND arl.lookup_type(+) = 'PHONE_LINE_TYPE'
AND arl.lookup_code(+) = hc.phone_line_type
AND hp.party_name LIKE :partyName
AND csi.incident_date BETWEEN to_date('01-JAN-2005','DD-MON-YYYY') AND to_date(:fromsrdate,'DD-MON-YYYY')
GROUP BY hp.party_name,csi.incident_number,csi.incident_date,csi.close_date,csi.summary,csi.problem_code,csi.incident_address
hi,
SELECT hp.party_name CustomerName,
COUNT(csi.incident_id) SRNumbercount,
csi.incident_number SRNumber,
csi.incident_date SRDate,
csi.close_date SRCloseDate,
csi.summary Summary,
csi.problem_code,
csi.incident_address SRAddress
FROM hz_parties hp,
hz_cust_accounts hca,
hz_contact_points hc,
cs_incidents_all_b csi,
ar_lookups arl
WHERE hca.cust_account_id =csi.account_id
AND hp.party_type IN ('PERSON','ORGANIZATION')
AND hp.status ='A'
AND hp.party_id = hca.party_id
AND hca.status ='A'
AND hp.party_id =hc.owner_table_id(+)
AND hc.owner_table_name(+) ='HZ_PARTIES'
AND hp.party_id =hca.cust_account_id
AND hc.contact_point_type(+)='PHONE'
AND hc.primary_flag(+) ='Y'
AND hc.status(+) ='A'
AND arl.lookup_type(+) = 'PHONE_LINE_TYPE'
AND arl.lookup_code(+) = hc.phone_line_type
AND hp.party_name LIKE :partyName
AND csi.incident_date BETWEEN to_date('01-JAN-2005','DD-MON-YYYY') AND to_date(:fromsrdate,'DD-MON-YYYY')
GROUP BY hp.party_name,csi.incident_number,csi.incident_date,csi.close_date,csi.summary,csi.problem_code,csi.incident_address
below is the output of above query here the output row-count is 116 rows
Business World 1 38560 29-JAN-09
Business World 1 38066 04-AUG-08
Business World 1 38564 29-JAN-09
Business World 1 38578 29-JAN-09
Business World 1 39646 31-MAY-09
Business World 1 39638 30-MAY-09
Business World 1 39810 17-AUG-09
Business World 1 39558 30-MAY-09
Business World 1 39588 30-MAY-09
Business World 1 39640 31-MAY-09
Business World 1 39680 31-MAY-09
Business World 1 39564 30-MAY-09
Business World 1 39824 19-AUG-09
Business World 1 39848 20-AUG-09
Business World 1 38674 31-JAN-09
Business World 1 38590 29-JAN-09
Business World 1 38678 02-FEB-09
Business World 1 38536 28-JAN-09
Business World 1 39664 31-MAY-09
Business World 1 39678 31-MAY-09
Business World 1 39560 30-MAY-09
Business World 1 39580 30-MAY-09
Business World 1 39618 30-MAY-09
Business World 1 39636 30-MAY-09
Business World 1 39554 20-MAY-09
Business World 1 39650 31-MAY-09
Business World 1 39660 31-MAY-09
Business World 1 39528 19-MAY-09
Business World 1 38666 31-JAN-09
Business World 1 39586 30-MAY-09
Business World 1 39604 30-MAY-09
Business World 1 39622 30-MAY-09
Business World 1 39630 30-MAY-09
Business World 1 39644 31-MAY-09
Business World 1 39652 31-MAY-09
Business World 1 39656 31-MAY-09
Business World 1 39648 31-MAY-09
Business World 1 39658 31-MAY-09
Business World 1 39202 16-MAR-09
Business World 1 39628 30-MAY-09
Business World 1 39674 31-MAY-09
Business World 1 39676 31-MAY-09
Business World 1 38704 02-FEB-09
Business World 1 38592 29-JAN-09
Business World 1 39614 30-MAY-09
Business World 1 39642 31-MAY-09
Business World 1 39662 31-MAY-09
Business World 1 39812 17-AUG-09
Business World 1 39590 30-MAY-09
Business World 1 39600 30-MAY-09
Business World 1 39602 30-MAY-09
Business World 1 39612 30-MAY-09
Business World 1 39620 30-MAY-09
Business World 1 39634 30-MAY-09
Business World 1 39826 19-AUG-09
Business World 1 39874 25-AUG-09
Business World 1 39828 19-AUG-09
Business World 1 39850 20-AUG-09
Business World 1 38720 03-FEB-09
Business World 1 38660 31-JAN-09
Business World 1 38682 02-FEB-09
Business World 1 38676 02-FEB-09
Business World 1 38698 02-FEB-09
Business World 1 38656 31-JAN-09
Business World 1 39574 30-MAY-09
Business World 1 39584 30-MAY-09
Business World 1 39578 30-MAY-09
Business World 1 39562 30-MAY-09
Business World 1 39672 31-MAY-09
Business World 1 39550 19-MAY-09
Business World 1 39822 19-AUG-09
Business World 1 24354 24-MAY-05
Business World 1 38588 29-JAN-09
Business World 1 38670 31-JAN-09
Business World 1 38680 02-FEB-09
Business World 1 38570 29-JAN-09
Business World 1 39596 30-MAY-09
Business World 1 39610 30-MAY-09
Business World 1 39592 30-MAY-09
Business World 1 39872 25-AUG-09
Business World 1 39852 20-AUG-09
Business World 1 39866 24-AUG-09
Business World 1 38546 29-JAN-09
Business World 1 38684 02-FEB-09
Business World 1 38668 31-JAN-09
Business World 1 38534 28-JAN-09
Business World 1 38088 07-AUG-08
Business World 1 38548 29-JAN-09
Business World 1 39556 21-MAY-09
Business World 1 39594 30-MAY-09
Business World 1 39654 31-MAY-09
Business World 1 39668 31-MAY-09
Business World 1 39522 18-MAY-09
Business World 1 39632 30-MAY-09
Business World 1 39570 30-MAY-09
Business World 1 39572 30-MAY-09
Business World 1 39582 30-MAY-09
Business World 1 39626 30-MAY-09
Business World 1 39552 19-MAY-09
Business World 1 39524 18-MAY-09
Business World 1 39854 20-AUG-09
Business World 1 39926 26-AUG-09
Business World 1 38696 02-FEB-09
Business World 1 38558 29-JAN-09
Business World 1 38456 19-JAN-09
Business World 1 38654 30-JAN-09
Business World 1 39566 30-MAY-09
Business World 1 39576 30-MAY-09
Business World 1 39606 30-MAY-09
Business World 1 39616 30-MAY-09
Business World 1 39624 30-MAY-09
Business World 1 39666 31-MAY-09
Business World 1 39568 30-MAY-09
Business World 1 39598 30-MAY-09
Business World 1 39670 31-MAY-09
Business World 1 39846 20-AUG-09 i want the count column should be the number of rows we get as output
Similar Messages
-
Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows
Dear All,
Good morning. Need your advices. We had a view which is running and producing output to excel files. But recently after one of ours database migration, it were producing differ result: Select Count(*) and actual row are differ: 136 rows vs 65k x 7 rows. Error happen when we export out the row to csv file is produced 65000 rows x 7 worksheep. But when perform select count(*) from RTNEWWIP, result return: 136 rows.
Is there any way to trace below sql to find where go wrong?
The Veiw as below:
CREATE OR REPLACE VIEW RTNEWWIP
(FAB_ID, PO, PRD_NO, SHP_PRD_NO, LOT,
WIP_QTY, ROUTEDESC, IN_TIME, STAY_DAY, BACK_DAY,
WO_FCST_DATE, SHIP_FCST_DATE, SHIP_CONF_DATE, WS_DATE, ROUTERATIO,
PROCESS, LOTSTATUS, LOTTYPE, RETICLEVERSION, PROCESSVERSION,
ROUTESEQUENCE, PRIORITY, PROCESSGEN, PROCESSFAMILY)
AS
select
--ord.order_no,
'SILTERRA' FAB_ID,
wip.PO_NUMBER PO,
wip.FW_DEVICE PRD_NO,
wip.USER_ITEM_DESCRIPTION SHP_PRD_NO,
wip.LOT_ID LOT,
wip.CURR_QTY WIP_QTY,
wip.STEP_DESC ROUTEDESC,
to_char(wip.RECORD_START_DATE,'DD-MON-YYYY HH24:MI:SS') IN_TIME,
to_char((sysdate - wip.RECORD_START_DATE),'9999D99') STAY_DAY,
to_char((wip.SCHEDULED_COMPLETE_DATE - sysdate),'9999D99') BACK_DAY,
-- (sysdate - wip.RECORD_START_DATE) STAY_DAY,
-- (wip.SCHEDULED_COMPLETE_DATE - sysdate) BACK_DAY,
to_char(wip.SCHEDULED_COMPLETE_DATE,'DD-MON-YYYY') WO_FCST_DATE,
to_char((wip.SCHEDULED_COMPLETE_DATE + 1),'DD-MON-YYYY') SHIP_FCST_DATE,
--nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
to_char(wip.LOT_START_DATE,'DD-MON-YYYY') WS_DATE,
--wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
'''' ||wip.MASK_NO || '/' || wip.MASK_TOTAL ROUTERATIO,
wip.PLAN_NAME_ACTIVE PROCESS,
wip.LOT_STATUS LOTSTATUS,
wip.LOT_TYPE LOTTYPE,
0 RETICLEVERSION,
wip.PLAN_VERSION_ACTIVE PROCESSVERSION,
0 ROUTESEQUENCE,
wip.PRIORITY PRIORITY,
' ' PROCESSGEN,
' ' PROCESSFAMILY
from wip_report wip, lot_fact lf, order_fact orf, order_dim ord,
apps.oe_order_headers_all@prod_myfabetl oeh,
apps.oe_order_lines_all@prod_myfabetl oel
where wip.CUSTNAME like 'Realtek%'
--AND WIP.FW_DEVICE like '%R25C'
and wip.ACTIVE_FACT_KEY = lf.RECORD_KEY
and lf.ORDER_FACT_KEY = orf.RECORD_KEY
and orf.ORDER_KEY = ord.RECORD_KEY
and ord.ORDER_NO = to_char(oeh.order_number)
and oeh.header_id = oel.header_id
and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
and orf.ITEM_SCHEDULE = to_char(oel.shipment_number)
and wip.LOT_TYPE in ('ENX','PRA','PRD','PRT','CSK','MPW')
union all
select --od.order_no,'
'SILTERRA' FAB_ID,
od.CUST_PO PO,
imd.FW_DEVICE_ID PRD_NO,
nvl(orf.USER_ITEM_DESCRIPTION, nvl(imd.CUST_DEVICE_ID, imd.FW_DEVICE_ID)) SHP_PRD_NO,
sfl.LOTID LOT,
sfl.currentcompqty WIP_QTY,
'CREATED' ROUTEDESC,
to_char(to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'), 'DD-MON-YYYY HH24:MI:SS') IN_TIME,
--sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss') STAY_DAY,
--to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate BACK_DAY,
to_char(sysdate - to_date(substr(recordstartdate,1, 14), 'yyyymmddhh24miss'),'9999D99') STAY_DAY,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') - sysdate,'9999D99')BACK_DAY,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd'),'DD-MON-YYYY') WO_FCST_DATE,
to_char(to_date(sfl.scheduledcompletedate,'yyyymmdd') + 1, 'DD-MON-YYYY') SHIP_FCST_DATE,
--nvl(oel.attribute15, to_char(sysdate+3650,'DD-MON-YYYY')) SHIP_CONF_DATE,
to_char(nvl(to_date(oel.attribute15,'DD-MON-YYYY'), sysdate+3650),'DD-MON-YYYY') SHIP_CONF_DATE,
to_char(to_date(sfl.startdate,'yyyymmdd'), 'DD-MON-YYYY') WS_DATE,
' ' ROUTERATIO,
sfl.tempprocessplan PROCESS,
sfl.currentstatus LOTSTATUS,
sfl.currenttype LOTTYPE,
0 RETICLEVERSION,
0 PROCESSVERSION,
0 ROUTESEQUENCE,
' ' PRIORITY,
' ' PROCESSGEN,
' ' PROCESSFAMILY
from SIL_FW_LOTCREATED_VIEW sfl, order_dim od, order_fact orf, item_master_dim imd,
apps.oe_order_headers_all@prod_myfabetl oeh,
apps.oe_order_lines_all@prod_myfabetl oel
where substr(sfl.salesorderno,1,instr(sfl.salesorderno,'-',1,1)-1)= to_char(od.ORDER_NO)
and od.RECORD_KEY = orf.ORDER_KEY
and od.RECORD_CURRENT_FLAG = 1
and orf.RECORD_CURRENT_FLAG =1
and to_char(orf.LINE_ITEM_NUMBER) = substr(sfl.salesorderno,instr(sfl.salesorderno, '-',1,1) +1, (instr(sfl.salesorderno, '.',1,1) -1) - instr(sfl.salesorderno, '-',1,1))
and to_char(orf.ITEM_SCHEDULE) = substr(sfl.salesorderno,instr(sfl.salesorderno, '.',1,1) +1, length(salesorderno) - instr(sfl.salesorderno, '.',1,1))
and orf.ITEM_MASTER_KEY = imd.RECORD_KEY
and sfl.customername = 'Realtek'
and od.ORDER_NO = to_char(oeh.order_number)
and oeh.header_id = oel.header_id
and orf.LINE_ITEM_NUMBER = to_char(oel.line_number)
and orf.ITEM_SCHEDULE = to_char(oel.shipment_number);
select count(*) from rtnewwip;
COUNT(*)
136
1 row selectedquery might be referring to different environment/schema as you are using database link to access some tables.
getting result/count from view means executing query which forms that view. try to run that query separately and see the output.
it may help you to debug -
Interactive Report count selected rows
I have a I/R report with a checkbox is column 1 of each row using:
HTMLDB_ITEM.CHECKBOX
(1,R.RESEARCH_ID,
decode(:Pxx_SELECT_ALL_ROWS,'Y','CHECKED',
decode(instr(nvl(:Pxx_SELECTED_IDS,0),R.RESEARCH_ID),0,NULL,'CHECKED'))
AS select_flag
I want to use Javscript or a Dynamic Action to "count" how many selected rows there are, when a UPDATE button is pressed.
Right now, the UPDATE button "submits" the page, then a page item computation runs the following code to get a count:
DECLARE
v_cnt number(9);
BEGIN
v_cnt := 0;
FOR i in 1..htmldb_application.g_f01.count
LOOP
v_cnt := v_cnt + 1;
END LOOP;
return v_cnt;
This works... but I dont want to submit (and rerun the report) just to get this count.
I have copied this loop into a Dynamic Action using the Click action of the UPDATE button, but it doesnt seem to recognize htmldb_application.g_f01.count .. so my value returns as 0.
Any ideas - thanks!I am not that strong in javascript, so I put a few alerts in the function you provided, to try to understand it better.
My example query returns 2 rows.
document.wwv_flow.f01.length returns a value = 2.
I checked both rows, then called the function.
I put an Alert inside the FOR loop in your example, it never executed.
The FOR loop in your example used a “>” sign, which never would evaluate as true, since i=0 > 2 is immediately false.
I changed the operator in the FOR loop to “<”.
The loop executed 2 times,
I displayed the with variable i : values = 0, 1
I displayed the value of document.wwv_flow.f01.id, it was NULL both iterations.
The $x(curr_id).checked is never true, so count remains = 0
function f_count_checked ()
var counter = 0;
for (var i = 0; i > document.wwv_flow.f01.length; i++) ---- I changed this to “<”
{var curr_id = document.wwv_flow.f01[i].id;
if ($x(curr_id).checked==true)
{counter = counter + 1;}}
alert ('You have checked: '+counter+' rows.'); -
Hi,
I have a multi-row select report with checkboxes. I would like to have it so you can check off your desired rows and click a button to have another window popup with the row information displayed in a different layout. The reason I am doing this is because I want to print specific rows (3 at a time, actually) in a particular format (ie not horizontally). I can get this to work with static fields in the region but cannot make the leap to multi-row select.
I'm thinking it's a combination of passing htmldb_application.g_f01 to pick the checked rows and then have javascript loop through the values in the report and place them in fields on the pop up. I found other postings, but they were for update of the multiple rows: I'm looking to just copy the text from the rows themselves to another window.
Is this possible?
I want a specific format to print out data in non-row fashion for a select set of data.
Does this make sense?
Thank you,
DeanI believe I was getting caught up because I was trying to mix server side and client side functions.
I ended up doing two things slightly different.
Created a new small table to house my selections:my_print.
I had check boxes on the rows and an after submit process that would delete the rows in the selection table and insert the key values of those selected.
BEGIN
DELETE from MY_PRINT;
FOR i in 1..HTMLDB_APPLICATION.G_F01.count
LOOP
INSERT INTO MY_PRINT (CARD_ID) VALUES (HTMLDB_APPLICATION.G_F01(i));
END LOOP;
END;
Then when I added a Submit "Print" button that took you to another page. That page was a print-friendly formatted report which selected the rows off the my_print keys. To get the format I ended up modifying the report template behind the page. This required a little trial and error with the different template types but I got what I wanted with a vertical named template and custom HTML tagging on the Row Template to build the page like a table.
It's all server side now and loads within the page, rather than a pop-up.
It accomplished the ultimate goal of being able to print selected rows in a format I liked. Plus, doing it this way was way easier than trying to code it all with a pop-up.
good luck
dean -
Introduction
We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
Solution
We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
“@[User::FilePath]”.
(I) Execute SQL Task Method:
In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
DECLARE @InsertRowCnt INT,
@TotalRowCnt INT
SET @InsertRowCnt=?
SET @TotalRowCnt=?
SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
SELECT TotalRowCnt=@TotalRowCnt
On to parameter 1.
On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
(II) Script Task Method:
In the Control Flow, drag a Script Task under the Data Flow Task and join them.
In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
Edit the Main method as follows (C#):
public void Main()
// TODO: Add your code here
int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
TotalRowCnt = TotalRowCnt + InsertRowCnt;
Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
Dts.TaskResult = (int)ScriptResults.Success;
Or (VB)
Public Sub Main()
' Add your code here
Dim InsertRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
Dim TotalRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
TotalRowCnt = TotalRowCnt + InsertRowCnt
Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
Dts.TaskResult = ScriptResults.Success
End Sub
Applies to
Microsoft SQL Server 2005
Microsoft SQL Server 2008
Microsoft SQL Server 2008 R2
Microsoft SQL Server 2012
Microsoft SQL Server 2014
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
I'm trying to get the count for each row to total count for each month
Something like this
Hardware | Jan
Monitors | 5
Processors | 137
Printers | 57
etc........
How can I write a query for this. I can get the Hardware column but don't know how to get the next column.If you can provide more data like sample input DML statements it would have been wonderful..
Assuming is , you need a pivot. Here is an article on basic Pivot..
http://sqlsaga.com/sql-server/how-to-use-pivot-to-transform-rows-into-columns-in-sql-server/
something like this may be..
DECLARE @Input TABLE
Hardware VARCHAR(20),
[Date] VARCHAR(20)
INSERT INTO @Input VALUES('Monitor', '01/01/2014'), ('CPU', '01/01/2014'), ('Monitor', '01/03/2014')
, ('ABC', '01/01/2014'),('Monitor', '02/01/2014')
;WITH CTE AS
SELECT Hardware, LEFT(DATENAME(M, [Date]),3) AS [MonthName] FROM @Input
SELECT *
FROM
SELECT Hardware, [MonthName], COUNT(Hardware) AS Count FROM CTE GROUP BY Hardware, [MonthName]) a
PIVOT (MAX([Count]) FOR [MonthName] IN ([Jan], [Feb])) pvt
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
Mass Updating of Selected Rows
(As you can see from my low number of posts I'm new to ApEx, so any information you can provide is appreciated.)
Hi,
I've been asked to include what I consider a heavy duty feature on a report. It has been requested that there is a form region above a report region. The form will have some fields on it to be used to mass update selected rows.
For instance, let's say the report is a list of employees and their dept and the form has a dropdown dept field that contains a list of depts. They want to be able to select certain employees on the report, then select a dept from the form and then click an Update Rows button. They want the selected rows to be updated with the selected dept. * Also, they don't want the report to be editable. * The only way to update any rows is thru the Update Row button.
I'm new to ApEx and can code in JavaScript, but am not an expert in either. And, I'm still trying to figure out what JavaScript syntax works in Element Attributes, etc. fields. But, I digress.
I have looked over several threads, and went to several demo pages, and have learned some things. Hopefully they are correct. If not, please correct me.
- Using the Row Selector is tricky.
- You can get the Row Selector on a regular SQL report by changing it to Updateable SQL, adding the Row Selector type, and changing it back.
- You can only see row information on a column if the column is editable.
I now have a report that is NOT editable and has NO editable columns. And the report has the Row Selector. Also, the ID (key) of each row is the first column of each row. (It's a link field that populates another page.) With the ID I can populate the correct record. I'm thinking I need to populate the ID again in another column into a text field and then be able to access that value on the selected rows.
Here's my dilemma. (That is, if I'm on the right track.) I need to know which rows are selected and then access the ID (key value) of that row. After that I can let my PL/SQL do the work.
- - 1. How does the 2nd ID need to be defined such that people can't edit it, but the value can be retrieved? And, how is this done? I assume something can be put in the Element Attributes. If so, will you please provide the code?
- - 2. What is the trick to knowing which rows are selected? An example snippet of code would be great here too.
- - 3. Also, tell me if I'm on the wrong track and need to provide a solution in a different way.
Sorry for the novel, but I wanted you to have a good idea of what I'm trying to accomplish so you may provide appropriate answers.
Thanks much, TonyHi Tony,
check out the following threads:
Re: Reference a value within a report????
Re: MRU - trying to restrict UPDATE to only certain users - everyone INSERT
BTW, you don't have to use any JavaScript. When you write your "Update pl/sql process" for the tabular form, just reference you page item which contains the department for your mass update.
eg.
FOR ii IN 1 .. Apex_Application.g_f01.COUNT
LOOP
UPDATE EMPLOYEES
SET DEPARTMENT_ID = :P4_NEW_DEPARTMENT_ID
WHERE EMPLOYEE_ID = Apex_Application.g_f02(Apex_Application.g_f01(ii))
END LOOP;Hope that gives you a direction how to solve that
Patrick
Check out my APEX-blog: http://inside-apex.blogspot.com
Check out the ApexLib Framework: http://apexlib.sourceforge.net -
File Count with selected date range
Hi,
Our requirement is to get the file count with selected date by the user from two sharepoint date time controls i.e. dtp1 and dtp2 into the data table. I am able to get the file count of specific folder from Pages library through below code. Now need to get
the selected date range from two date time picker controls and check with the item created by is within the date range. If yes I need to get the file count.
So please share your ideas/thoughts to do the same.
SPList list =
wikiweb.Lists["Pages"];
SPFolderCollection oFolders
= list.RootFolder.SubFolders["foldername"].SubFolders;
DataTable dt
= new DataTable();
dt.Columns.Add("Column1");
DataRow dr;
if (oFolders.Count
> 0)
foreach (SPFolder oFolder in oFolders)
if (!oFolder.Name.Equals("Forms"))
dr
= dt.NewRow();
dr["Column1"] = oFolder.ItemCount.ToString();
dt.Rows.Add(dr);
Regards,
Sudheer
Thanks & Regards, SudheerHi,
I have modified the code as below
if((DateTime)(oFolder.Item.File.TimeCreated>dtFromDate.SelectedDate)&&(DateTime)(oFolder.Item.File.TimeCreated<dtToDate.SelectedDate))
But still it is throwing the error.
Please share your ideas on the same.
Regards,
Sudheer
Thanks & Regards, Sudheer -
"select count(*)" and "select single *" returns different result
Good day!
product version SAP ECC 6.0
oracle10
data transfers from external oracle db into customer tables using direct oracle db link
sometimes I get case with different results from 2 statements
*mytable has 10 rows
*1st statement
data: cnt type I value 0.
select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
*cnt returns 10 - correct
*2nd statement
select single * from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
*sy-dbcnt returns 0
*sy-subrc returns 4 - incorrect, 10 rows are "invisible"
but
1. se16 shows correct row number
2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
can not understand why
thank you in advance.Thank you, Vishal
but,
general problem is that
1. both statements have the same WHERE conditions
2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
Dataset to process is the same, WHERE conditions are equal...
I think the problem is that how ABAP interperets select count(*) and "select single *".
Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
se16 shows all records.
And why after simple manual update of just one record using se16 "select single *" returns 1?
I've just marked one row to update, didn't change any data, then pressed "save". -
I want a count of distinct rows in a table
I want a count of distinct rows in a table through a single query -- is it possible?
eg.
table-
create table ch1 (a int, b int, c int, d int)
insert ch1 values (1,1,1,1)
insert ch1 values (2,2,2,2)
insert ch1 values (1,1,1,1)
insert ch1 values (2,2,2,2)
insert ch1 values (1,3,4,5)hi,
create table ch1 (a int, b int, c int, d int) ;
insert into ch1 values (1,1,1,1);
insert into ch1 values (2,2,2,2);
insert into ch1 values (1,1,1,1);
insert into ch1 values (2,2,2,2);
insert into ch1 values (1,3,4,5);
SQL> select * from ch1;
A B C D
1 1 1 1
2 2 2 2
1 1 1 1
2 2 2 2
1 3 4 5
SQL> select distinct * from ch1;
A B C D
1 1 1 1
1 3 4 5
2 2 2 2
SQL>
1* select count(*) from( select distinct * from ch1)
SQL> /
COUNT(*)
3
SQL> ed
Wrote file afiedt.buf
1 select count(*) from (select a,b,c,d from ch1
2* group by a,b,c,d)
SQL> /
COUNT(*)
3
SQL> Thanks,
P Prakash -
Need help to count number of rows and display in file
Hello,
my scenario is IDOC to File......i am using XSLT mapping and using FCC parameters to convert the flat file.
now new requirement is i need to count number of rows and add count value last of the file.
Please let me know how to do it,
thanks in advance for your help.
Regards,
Chinnathanks again, one more Q.
in XSLT mapping i have written for loop for complete structure.
example : <Details>
<node1>
<node2>
</details>
in XSLT mapping
<xsl:for-each select="ZMATMAS_01/IDOC/E1MARAM">
<Details>
</Details>
</xsl:for-each>
if i add the field at target side....then i will come under details node and it will be repeated.
how to declare in XSLT mapping. -
How to reference the selected row on a report by click a radiobox
I created a report with a column displayed as a radiobox.The report source is like "select htmldb_item.radiogroup(1,.....),rec_id,....from .... where ....",after click one radiobox,i want to get other column's value in the selected row in the after submit process ,can anyone help me?????? how to reference "rec_id" of the selected row?
Hello,
First, please tell us your first name, and update your forum handle. It’s make it easier to track your threads, and help you.
>> apex_application.g_f01(1)" only return the first record's rec_id,if i click radiobox in other rows,it returns the same result as click radiobox in the first row?
The ‘G_F01’ is an array of values, so apex_application.g_f01(1) will always bring you the first element of this array. If you want to retrieve other values from this array, which will include the values of the radiogroup value of the other lines, you need to use a loop. Something like that should work:
for i in 1.. apex_application.g_f01.count loop
… apex_application.g_f01(i) …
end loop;
>> after click one radiobox,i want to get other column's value in the selected row in the after submit process
That means that the value of your radiogroup item should include some indication to the line you are on. If, like in Andy’s example, you can retrieve your record from a table, based on a PK, your radiogroup can return this kind of information. However, if the data on the other columns of the select raw, were just entered/updated by the user (like in a tabular form), the radiogroup item should include information about the row you are in, in order for you to be able to access the corresponding array elements – other G-Fxx arrays – of the other columns in the row. In this case, I believe using checkboxes is preferable.
Regards,
Arie. -
Hi everybody,
How can I know which row is selected in a grid?
I can know it with pval.row when I work with the gridself, but how I can Know with a button?
Is there some property similar selectedRow that returns de number of row?
Thanks
CarlesYou can access it two ways.
1. oGrid.Rows.SelectedRows which returns you all the selected rows in a collection
or
2. do a loop and check
int selectedrow=0;
for(int i =0; i<oGrid.Rows.Count; i++)
(if oGrid.Rows.IsSelected(i) == true)
selectedrow = i;
break; -
Procudure to count all the rows in a all tables in the schema
When I run the following store procedure to count all the rows in all the tables I crash my sql Plus editor:
CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT(OWNER IN varchar2)
IS
row_count number;
cursor get_tab is
select table_name, num_rows
from all_tables
where owner='MAXDEV';
begin
dbms_output.put_line('Checking Record Counts for schema maxdev ');
FOR get_tab_rec IN get_tab LOOP
BEGIN
EXECUTE IMMEDIATE 'select count(*) from '||get_tab_rec.table_name
INTO row_count;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Error counting rows for table '
||get_tab_rec.table_name);
END;
END LOOP;
END;
What am I doing wrong.
Thanks for any help TonyThe boss gave me 5 pages of tables and wants to know how many row there are in each table. There is a problem of one DB being out of sync with another.
But I have managed to work the problem though.
here is the working code:
CREATE OR REPLACE PROCEDURE TC_TABLEROWCOUNT (
TableOwner IN varchar2)
IS
row_count number;
vTable varchar2(30);
v_sqlstmt varchar2(100);
cursor get_tab is
select table_name, num_rows
from all_tables
where owner = TableOwner;
begin
dbms_output.put_line('Checking Record Counts for schema maxdev ');
FOR get_tab_rec IN get_tab LOOP
vTable := get_tab_rec.table_name;
v_sqlstmt := 'SELECT count(*) from '||vTable;
EXECUTE IMMEDIATE v_sqlstmt into row_count;
dbms_output.put_line('Table '|| get_tab_rec.table_name || ' Row ' || row_count);
END LOOP;
END; -
Count of records/rows in a Table
Hi
This could be a basic question , but i don't have an idea how to do that .
Could you please tell me , how get an count of records/rows in a specific table ?
Thank you
Lukesb92075 wrote:
It takes time to get count of records if the table size is hugCan YOU count to 1000000000000000000 as quickly as you count to 10?????????????????????????
If it takes you longer to count many things, why do you expect Oracle to do better than you?Really??
Let's try some counts and see.
First off, let's count a few 1000 rows.
SQL> set timing on
SQL> select count(*) from all_objects;
COUNT(*)
45045
Elapsed: 00:00:17.08So 17 seconds for 45,000 rows.
Now if you're logic is correct, counting let's say a few billion rows, should take an hour? Perhaps more?
Here's what I see on one of my larger tables:
SQL> select count(*) from daily_xxxxxxx;
COUNT(*)
2569780329
Elapsed: 00:00:10.03Oops... it is faster.
Get a clue!I hereby sincerely apologise that my database does not adhere to your fine logic that says it should take a few hours - I will speak disapprovingly to the CBO for allowing the 2nd select count (on the same database) to be faster than the 1st select count. I will even use the backchannel to inform Larry that this is not acceptable.
Of course, this is assuming that you do not have your head stuck up somewhere and are indeed correct that it takes a "+looooonnngggg+" time to count lots of rows.
!http://smileyicons.net/smilies/actions1.gif!
Maybe you are looking for
-
MSI GT70 2PC Dominator, how to know if all cores are at their 100%
Hi, i would like to know (for gaming proposes) if all my CPU cores are running at the their 100%? ive been having some issues with games, and a friend told me if there is no powersaving features enabled on your notebook, i have checked power options
-
Is there any way to sync apps from different computers in one ipod touch?
Hi So, I have synced my iPod touch with iTunes in my mac and now I want to install some applications that my brother has in his computer. *Is there any way I can sync applications in my iPod touch using different computers, without losing the apps th
-
IE11 restricted users opens links in new window instead new tab
Hello, Have a problem. All restricted users, on several machines when try to open link in new tab, link opens in new window instead new tab. Pressing ctrl+K or ctrl+T works fine. Resetting browser setting didn't help. Red cross near resetting user cu
-
Hardware test question re:FCP4.5 on 10.4.3
Upgraded to 10.4.3 - QT 7.0.3 running FCP4.5 In DV25 sequence, loaded a few clips on single layer [video 1] the time line (plenty of handle, all clips) applied a transition between ALL clips, dissolve. On a NTSC monitor. Safe RT - Playback HIGH - Out
-
Storing objects in List ?
I've created a List<?> list; but when I want to add any object for ex. list.add(new Integer(5)); there's an error 'The method add(capture-of ?) in the type List<capture-of ?> is not applicable for the arguments (Integer)' How should I add objects to