How to loop through a webtable using HP UFT and print the text for each row in column 1 and 2 - hp-uft

Hello can someone help me loop through a web table using HP UFT to read a WebTable and loop through each row, print the text for each row in column 1 and 2 and finally compare the text to whats on the webpage
Set myTable = Browser("page").Page("activity Center").WebTable("readonlygrid-xxxx")
TotalRows = myTable.RowCount
msgbox TotalRows
Total = 0
For i = 2 to TotalRows
For x = 2 to TotalRows
strinbx = myTable.GetCellData(i,1)
strinbx2 = myTable.GetCellData(x,2)
print strinbx & strinbx2
Next
Next

I don't understand why you have two loops for the rows. If you only want the first two columns of each row you need something like this:
For row = 1 to myTable.RowCount
column1 = myTable.GetCellData(row, 1)
column2 = myTable.GetCellData(row, 1)
Print column1 & " - " & column2
Next
I also don't understand what you mean by "compare the text to whats on the webpage", the values you get are what's on the webpage.

Related

SQL*Plus Custom Summary Report

I have a requirement to generate the following summary report that look like the following:
My problem is that,
I have no idea on how do I fill the count data in this custom report.
I do not know how to put it in a table view like the above in a text document. It is not HTML.
So far, I only know how to do the first row, and column without the table view.
Here are my codes.
SET HEADING OFF;
SET LINESIZE 200;
SET SPACE 0;
SET ECHO OFF;
SET FEEDBACK OFF;
SET VERIFY OFF;
SET MARKUP HTML OFF SPOOL OFF;
SET TERMOUT OFF; --Do not show output to the screen.
SET NEWPAGE NONE; --Remove the first blank line at the top of the page and between queries.
TTITLE LEFT "REPORT NAME" RIGHT "PAGE : " SQL.PNO SKIP 1 -
LEFT "--------------------------------" RIGHT "DATE : " _DATE SKIP 1 -
LEFT "A) TOTAL RECORDS " RIGHT total_records; -- Cannot output variable in the title.
LEFT "B) MATCHED RECORDS " RIGHT matched_records; -- Cannot output variable in the title.
LEFT "C) UNMATCHED RECORDS " RIGHT matched_records; -- Cannot output variable in the title.
BTITLE LEFT "E N D";
total_records is an insert into statement.
SELECT COUNT(*) INTO total_records FROM TABLE;
I have not done matched records and unmatched records. But the only way I can think of
Select a statement into a cursor.
Loop into the cursor.
Increase matched count when there is a match.
Once loop finish. unmatched count = total count - matched count.
I don't think this is the most efficient way. But, if you have a better way, let me know.
Does something like this ring a bell? Example is based on Scott's sample schema:
SQL> select 'Total records' name, count(*) cnt
2 from emp
3 union all
4 select 'Matched count', sum(case when deptno = 10 then 1 else 0 end)
5 from emp
6 union all
7 select 'Unmatched count', sum(case when deptno = 10 then 0 else 1 end)
8 from emp;
NAME CNT
--------------- ----------
Total records 14
Matched count 3
Unmatched count 11
SQL>

how to compare listbox items with memo field in a table in foxpro for exact match?

I am having an Inv table having tags as the field containing memo type, Now how to compare list box items with Inv.tags(memo) weather any of the records in inv.tags are matching with listbox items , this is the code i have written,
Create Cursor mycursor(RecordS c(50))
IFExists=.F.
For nCount = 0 To Thisform.list3.ListCount
Append Blank
Replace RecordS With Alltrim(Thisform.list3.List(nCount))
IFExists=.T.
Endfor
Delete From mycursor Where RecordS==""
lcMessage = ""
select mycursor
scan
lcMessage = lcMessage + transform(records) + chr(13)
ENDSCAN
lbMessage = ""
select inv
scan
lbMessage = lbMessage + transform(tags) + chr(13)
ENDSCAN
IF ALLTRIM(lcMessage) == ALLTRIM(lbMessage)
MESSAGEBOX('Success',64,'Status')
ELSE
MESSAGEBOX('Mis Match',16,'Status')
ENDIF
i am getting the result as mismatch even if the records are matching. Thank You!
It seems like it is mismatching, because you start the index of your listbox at 0. In VFP, indexes start at 1 and the listbox control will return an empty string, when referencing "Thisform.list3.List(0)".
Anyways, I could not reproduce the problem either, so this is just a suggestion.

How do I create a ID based on multiple values in different columns in Power Query?

I am trying to create an ID based in multiple values in different columns in Power query.
The idea is to check the following values:
IF
ID_STORE = 1
ID_PRODUCT = 1
ID_CATEGORY = 1
SALE_DATE = 01/01/2018
ID_COSTUMER = 1
THEN CREATE THE SAME ID FOR THE ROWS THAT HAVE THIS INFO.
The idea is to check the rows that have that info (1 and 01/01/2018) in multiple columns (ID_STORE, ID_PRODUCT, ID_CATEGORY etc..).
Thanks in advance.
Obs: This is my first post, so feel free to correct me in any manner.
You need to add an 'AND' clause to your 'OF' statement;
if [ID_STORE] = 1
and [ID_PRODUCT] = 1
and [ID_CATEGORY] = 1
and [SALE_DATE] = Text.ToDate("01/01/2018")
and [ID_COSTUMER] = 1 then
1 else 0

find rows with same value using LINQ

The issue with the image above is that
I want to apply a bonus share to the shareholders based on the TransLog_Date
Because the shareholder in row 1 has already transferred a portion of his shares to the holder in row 3, his new share value is what shows in row 2 column 5 as 100000
I want the bonus share to be calculated based on the value in row 2, column 5 but not on row 1, column 5.
I have tried several codes in LINQ but getting it wrong as the value is multiplied on all the 3 records which is totally wrong.
var transQuery = (from tq in db.TransactionsLogDbSet
where (tq.TransactionType == TransactionType.PurchaseOfShares)
|| (tq.TransactionType == TransactionType.TransferOfShares)
|| (tq.TransactionType == TransactionType.BonusSharesDeclared)
select tq);
var query = from row in db.TransactionsLogDbSet
group row by row.Transholder_ID into g
select new { Count = g.Count() };
OK, i think I finally got what you want.
Is that right?: Group all rows of some TransactionTypes by the Transholder_ID, then from each group select the row with the maximum Translog_Date, giving you the most recent row per Transholder_ID. Once you have the result of that, you can iterate over it to calculate whatever you need.
from t in db.TransactionLogDbSet
where where tq.TransactionType == TransactionType.PurchaseOfShares || tq.TransactionType == TransactionType.TransferOfShares || tq.TransactionType == TransactionType.BonusSharesDeclared
group t by t.Transholder_ID into g
select (from t1 in g orderby t1.Translog_Date descending select t1).First();
EDIT: I'll continue to edit the following part of my answer as long as we finally arrive at the correct query.
From you last comment so far it follows that you just want to select all rows with a TransLog_Date <= a given DateTime qualifiedDate.
from t in db.TransactionLogDbSet
where t.TransactionLog_Date <= qualifiedDate
select t
Is that it?

How to identify duplicate rows having value within data range in oracle

I want to identify rows where value in Name column is same and value in start/ end column lies within range of Start and End value of another row...
for eg. for me row with ID value 4 & 1 are duplicate because they have same value in Name column and value in start column 26 of ID 4 lies within start & End values of ID 1 (24-56)
ID Name Start End
1 Adam 24 56
2 Max 1 5
3 Neil 6 4
4 Adam 26 30
You can use EXISTS for this:
select *
from yourtable y
where exists (
select 1
from yourtable y2
where y.id <> y2.id
and y.name = y2.name
and (y2.startfield between y.startfield and y.endfield
or
y.startfield between y2.startfield and y2.endfield))
SQL Fiddle Demo
I wasn't completely sure from your question if the end range had to be included as well. If so, you'll need to add that to the where criteria:
select *
from yourtable y
where exists (
select 1
from yourtable y2
where y.id <> y2.id
and y.name = y2.name
and ((y2.startfield > y.startfield and y2.endfield < y.endfield)
or
(y.startfield > y2.startfield and y.endfield < y2.endfield)))

Resources