Not able to select the 2nd row in a webtable usng description lanugauge in UFT - hp-uft

I have written the below piece of code to pick a row from web table to process it. The code picks/opens the first row successfully, however, when it is trying to double click the second row, it errors out with an error "Unspecified error". The web table has 7 rows, nevertheless, it is failing. Can some one point out what could be the reason for the failure please?
Set objDesc = Description.Create
objDesc("micclass").Value = "WebTable"
objDesc("html tag").Value = "Table"
Set objList = Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").ChildObjects(objDesc)
oCount = objList.Count
For k =0 To oCount - 1
colName = objList(k).GetRoproperty("cols")
If Trim(colName) = 21 Then 'This is the right table
objList(k).Highlight
rows= objList(k).GetROProperty("rows")
For i = 1 To rows
x = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_x")
y = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_y")
Wait(2)
Set obj = CreateObject("Mercury.DeviceReplay")
obj.MouseDblClick x,y,LEFT_MOUSE_BUTTON
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebEdit("ben_elig_dte"), "ben_elig_dte", "WebEdit", Parameter("elig_date"))
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebList("emp_state_withd_opt_decode"), "emp_state_withd_opt_decode", "WebList", Parameter("withhold_ind"))
Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebButton("Save").Click
Next
Exit For
End If
Next

Related

grid does not refresh

This is the code of the init of the form
if !used if !used ("supplier_temp")
SELECT supplier
afields(structure)
CREATE cursor supplier_temp from array structure
else
SELECT supplier_temp
for re = 1 to reccount()
SELECT supplier_temp
go re
_id = supplier_temp.id
_name = supplier_temp.name
_dir = supplier_temp.dir
_cel = supplier_temp.cellphon
_em = supplier_temp.email
scan
update provider set name=_name, address=_dir, cell=_cel, email = _em where control = 1 and id = _id
end scan
end for
delete all
endif
SELECT supplier_temp
APPEND FROM supplier for dispatched = 1
GO TOP
Thisform.Suppliers.RecordSource = "supplier_temp"
Thisform.Suppliers.column1.ControlSource = "supplier_temp.name"
Thisform.Proveedores.column2.ControlSource = "supplier_temp.direntre"
Thisform.Proveedores.column3.ControlSource = "provider_temp.cellphon"
Thisform.Suppliers.column4.ControlSource = "supplier_temp.email"
This is the code for the process button
If thisform.Proveedores.Column1.Check2.Value = 1
thisform.Preclientes.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 2
locate for supplier_temp.control = 2
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
This is the code for the reject button
If thisform.Suppliers.Column1.Check2.Value = 1
if !empty(suppliers_temp.obs)
thisform.Suppliers.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 3
locate for supplier_temp.control = 3
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
endif
The grid is not refresh despite having in the init and in the buttons the commands Thisform.Suppliers.refresh,thisform.Suppliers.setfocus() and
thisform.refresh. When the form is closed and reopened, the grid is refreshed
&& reset the grid control because init() executed twice
Thisform.Suppliers.RecordSource = ""
CREATE cursor supplier_temp from array structure
Thisform.Suppliers.RecordSource = "supplier_temp"

GORM hangs with parameter

The below queries hangs exactly after 5 calls every time,
tx := db.Raw("select count(*) as hash from transaction_logs left join blocks on transaction_logs.block_number = blocks.number"+
" where (transaction_logs.address = ? and transaction_logs.topic0 = ?) and blocks.total_confirmations >= 7 "+
"group by transaction_hash", strings.ToLower("0xa11265a58d9f5a2991fe8476a9afea07031ac5bf"),
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef").Scan(&totalIds)
If we replace it without the arguments it works
db.Raw("select count(*) as hash from transaction_logs left join blocks on transaction_logs.block_number = blocks.number"+
" where (transaction_logs.address = #tokenAddress and transaction_logs.topic0 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef') and blocks.total_confirmations >= 7 "+
"group by transaction_hash", sql.Named("tokenAddress", strings.ToLower("0xa11265a58d9f5a2991fe8476a9afea07031ac5bf"))
Tried even with named parameter, same result
Can anyone help here

ORA-00904: "S"."AIR_TIME": invalid identifier

Why does this code show invalid identifier when sum is used in distance and air_time column?
When sum is not used this statement process successfully but using sum I get error? I need to use sum for this statement.
MERGE INTO FACT_COMPANY_GROWTH F
USING (SELECT DISTINCT TIME_ID, FLIGHT_KEY, AEROPLANE_KEY, SUM(DISTANCE) AS TOTAL_DISTANCE, SUM(AIR_TIME) AS TOTAL_AIRTIME
FROM TRANSFORM_FLIGHT T
INNER JOIN TRANSFORM_AEROPLANE A
ON T.FK_AEROPLANE_KEY = A.AEROPLANE_KEY
INNER JOIN DIM_TIME D
ON D.YEAR = T.YEAR
AND D.MONTH = T.MONTH
GROUP BY TIME_ID, FLIGHT_KEY, AEROPLANE_KEY) S
ON (F.FK1_TIME_ID = S.TIME_ID
AND F.FK2_FLIGHT_KEY = S.FLIGHT_KEY
AND F.FK3_AEROPLANE_KEY = S.AEROPLANE_KEY
)
WHEN MATCHED THEN
UPDATE SET
F.TOTAL_AIRTIME = S.AIR_TIME,
F.TOTAL_DISTANCE = S.DISTANCE,
F.TOTAL_NO_OF_FLIGHTS = S.FLIGHT_KEY,
F.TOTAL_NO_OF_AEROPLANE = S.AEROPLANE_KEY
WHEN NOT MATCHED THEN
INSERT(FACT_ID, FK1_TIME_ID, FK2_FLIGHT_KEY, FK3_AEROPLANE_KEY, TOTAL_DISTANCE, TOTAL_AIRTIME, TOTAL_NO_OF_FLIGHTS, TOTAL_NO_OF_AEROPLANE)
VALUES
(NULL, S.TIME_ID, S.FLIGHT_KEY, S.AEROPLANE_KEY, S.DISTANCE, S.AIR_TIME, S.FLIGHT_KEY, S.AEROPLANE_KEY);
USING(
SELECT DISTINCT
TIME_ID,
FLIGHT_KEY,
AEROPLANE_KEY,
SUM(DISTANCE) AS TOTAL_DISTANCE,
SUM(AIR_TIME) AS TOTAL_AIRTIME
...) S
The problem is at UPDATE SET F.TOTAL_AIRTIME = S.AIR_TIME. There are 5 fields defined in S and none is named AIR_TIME.
UPDATE SET
F.TOTAL_AIRTIME = S.TOTAL_AIRTIME,
F.TOTAL_DISTANCE = S.TOTAL_DISTANCE,

CT_FETCH error in PowerBuilder Program

I'm still learning PowerBuilder and trying to get familiar with it. I'm receiving the following error when I try to run a program against a specific document in my database:
ct_fetch(): user api layer: internal common library error: The bind of result set item 4 resulted in an overflow. ErrCode: 2.
What does this error mean? What is item 4? This is only when I run this program against a specific document in my database, any other document works fine. Please see code below:
string s_doc_nmbr, s_doc_type, s_pvds_doc_status, s_sql
long l_rtn, l_current_fl, l_apld_fl, l_obj_id
integer l_pvds_obj_id, i_count
IF cbx_1.checked = True THEN
SELECT dsk_obj.obj_usr_num,
dsk_obj.obj_type,
preaward_validation_doc_status.doc_status,
preaward_validation_doc_status.obj_id
INTO :s_doc_nmbr, :s_doc_type, :s_pvds_doc_status, :l_pvds_obj_id
FROM dbo.dsk_obj dsk_obj,
preaward_validation_doc_status
WHERE dsk_obj.obj_id = :gx_l_doc_obj_id
AND preaward_validation_doc_status.obj_id = dsk_obj.obj_id
using SQLCA;
l_rtn = sqlca.uf_sqlerrcheck("w_pdutl095_main", "ue_run_script", TRUE)
IF l_rtn = -1 THEN
RETURN -1
END IF
//check to see if document (via obj_id) exists in the preaward_validation_doc_status table.
SELECT count(*)
into :i_count
FROM preaward_validation_doc_status
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF i_count = 0 THEN
//document doesn't exist
// messagebox("Update Preaward Validation Doc Status", + gx_s_doc_nmbr + ' does not exist in the Preaward Validation Document Status table.', Stopsign!)
//MC - 070815-0030-MC Updating code to insert row into preaward_validation_doc_status if row doesn't already exist
// s_sql = "insert into preaward_validation_doc_status(obj_id, doc_status) values (:gx_l_doc_obj_id, 'SUCCESS') "
INSERT INTO preaward_validation_doc_status(obj_id, doc_status)
VALUES (:gx_l_doc_obj_id, 'SUCCESS')
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number ' + gx_s_doc_nmbr + ' has been inserted and marked as SUCCESS for PreAward Validation.')
return 1
Else
//Update document status in the preaward_validation_doc_status table to SUCCESS
Update preaward_validation_doc_status
Set doc_status = 'SUCCESS'
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number '+ gx_s_doc_nmbr + ' has been marked as SUCCESS for PreAward Validation.')
End IF
update crt_script
set alt_1 = 'Acknowledged' where
ticket_nmbr = :gx_s_ticket_nmbr and
alt_2 = 'Running' and
doc_nmbr = :gx_s_doc_nmbr
USING SQLCA;
Return 1
ElseIF cbx_1.checked = False THEN
messagebox("Update Preaward Validation Doc Status", 'The acknowledgment checkbox must be selected for the script to run successfully. The script will now exit. Please relaunch the script and try again . ', Stopsign!)
Return -1
End IF
Save yourself a ton of headaches and use datawindows... You'd reduce that entire script to about 10 lines of code.
Paul Horan gave you good advice. This would be simple using DataWindows or DataStores. Terry Voth is on the right track for your problem.
In your code, Variable l_pvds_obj_id needs to be the same type as gx_l_doc_obj_id because if you get a result, it will always be equal to it. From the apparent naming scheme it was intended to be long. This is the kind of stuff we look for in peer reviews.
A few other things:
Most of the time you want SQLCode not SQLDbCode but you didn't say what database you're using.
After you UPDATE crt_script you need to check the result.
I don't see COMMIT or ROLLBACK. Autocommit isn't suitable when you need to update multiple tables.
You aren't using most of the values from the first SELECT. Perhaps you've simplified your code for posting or troubleshooting.

VB6 MSFlexGrid - Unable to set columns and rows count at runtime

I have a Visual Basic 6 form with a MSFlexGrid control inside, which takes data from a record set(ADODB) and displays them.
Before starting the copy of data to the FlexGrid, I'm trying to set the rows count, depending on records count. Also I have a collection which contains columns' names, then I can get the number of columns from here.
The following is a code snippet:
v_colsCount = UBound(aCols) + 2 // aCols = array with columns' names
v_regCount = rs.RecordCount // rs = my ADODB record set
myFlexGrid.Rows = 0 // for cleaning rows from a previous display
myFlexGrid.Rows = IIf(v_regCount > 0, v_regCount + 1, 2)
myFlexGrid.Cols = v_colsCount
myFlexGrid.FixedRows = 1
myFlexGrid.FixedCols = 0
There are 7532 rows and 52 columns. The problem comes when I run the application and try to execute this part of the code (fill the FlexGrid with data from the record set):
For iRow = 1 To v_regCount
For iCol = 0 To v_colsCount -2
sAux = ConvStr(rs.Fields(aCols(iCol)).Value)
myFlexGrid.TextMatrix(iRow, iCol) = sAux
I notice that
v_regCount = 7532 but v_colsCount = 2 ,
and I get an error ("Substring out of range"). If I swap the settings order (i.e. if I set myFlexGrid.Cols after set myFlexGrid.Rows), then
v_regCount = 0 and v_colsCount = 52
I don't understand why I can't set rows and columns count at the same time.
Any ideas?
Thanks in advance

Resources