1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 28 March 2023 12:20 PM UTC

Hi all,

Another strange one.  I've got a window with a dw on it, inherited from PFC u_dw. I've got code for the dw that has 3 user events.  ue_cut_rows, ue_copy_rows, ue_paste_rows.

I can cut/copy rows, then paste rows, works fine.  But, when I save the dw, I get a dw error:

If I then close the window, then reopen the window, the dw did indeed save the dw with the correct cal_points.id value.  So why am I getting the error in the first place?

I copied all code from the last version of my software.  It works as expected in that version.  Previous version was PB2019 R3 Build 2728 (not sure of PFC version). I am currently using PB2021 Build 1509, PFC 12.

Here's the code I've got for the pfc_preupdate event... I've tried putting this in the pfc_update event instead... same result.

// Over-ride ancestor...
long ll_NewRows, ll_CalPointID, ll_ThisRow, ll_RowCount

// Assign ID#'s for new rows...
ll_RowCount = this.RowCount()

if ll_RowCount > 0 then
	ll_NewRows = this.GetItemNumber( ll_RowCount, "cf_nullrows" )
	MessageBox("Null IDs", ll_NewRows)
	if ll_NewRows > 0 then
		ll_CalPointID = f_get_calpoint_id ( ll_NewRows )
		if ll_CalPointID <= 0 then return -1
		ll_ThisRow = this.Find("IsNull(id)", 1, ll_RowCount)
		MessageBox("First Null Row", ll_ThisRow)
		DO WHILE ll_ThisRow > 0
			this.SetItem( ll_ThisRow, "id", ll_CalPointID )
			MessageBox("ID", "Row: " + string(ll_ThisRow) + " ID: " + string(ll_CalPointID))
			ll_CalPointID++
			ll_ThisRow = this.Find("IsNull(id)",ll_ThisRow, ll_RowCount)
		LOOP
	end if
end if

return 1

The MessageBox's are only there for trouble-shooting... all values are correct, every time. cf_nulls is a computed field on the dw, summary band.

This application is already in production with a couple customers, so it's a report bug.

TIA,
~~~Tracy

 

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 29 March 2023 11:08 AM UTC
  2. PowerBuilder
  3. # Permalink

JEEZ! I fixed the problem.  Turns out the culprit was an invisible DW on same window that uses the same dw object as the visible DW the user is editing.  I use the invisible DW as a holding buffer for rows that are cut or copied.  Then when the rows are pasted, I clear that buffer.  I forgot to set the updateable property to false. Bad, bad programmer! 

In the buffer dw's constructor event, I put the following:

this.of_setupdateable( FALSE )

Sure wish that error window I kept getting would tell me which datawindow was causing the error... sure wish I had thought of this 15 minutes into troubleshooting, instead of 4 hours, lol! It really should have occurred to me earlier because even though I was getting the error, the data was clearly saving correctly to the database.

Thanks to all who offered helpful feedback/ideas.

~~~Tracy

Comment
  1. Miguel Leeuwe
  2. Wednesday, 29 March 2023 11:11 AM UTC
Glad you solved it! To get more information, you might be able to include a messagebox in the u_dw dberror event. Using "this.Classname()" and / or "this.dataobject" to get more information.

Well done!
  1. Helpful 2
  1. Tracy Lamb
  2. Wednesday, 29 March 2023 22:36 PM UTC
FANTASTIC IDEA! I just added script to the ancestor object u_dw dberror event:

MessageBox("Database Error", this.ClassName())

Pops up an extra messagebox, but that's ok. Shouldn't happen very often!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 28 March 2023 12:56 PM UTC
  2. PowerBuilder
  3. # 1

Hi,

Just in case: Are you doing this in the pfc_preupdate of the datawindow control, or the one of the window? It has to be the one of the dw.

regards.

Comment
  1. Tracy Lamb
  2. Tuesday, 28 March 2023 13:01 PM UTC
It's the pfc_preupdate on the dw.
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 28 March 2023 15:13 PM UTC
Things I can think of:

- temporarily use Disablebind=1 in your dbparm setting for SQLCA. That way you can see the values instead of question marks in the SQL

- run the application in trace mode: precede your SQLCA.DBMS value with TRACE (followed by a space, and whatever value you have in there at the moment).

- put a debug stop in the u_dw.dberror event. If there's no code, then put the stop in its ancestor dberror event. Debug the application, when you hit the debug stop, step out of the event. That way you can trace back what function or event triggered the error.

regards
  1. Helpful 1
  1. Miguel Leeuwe
  2. Tuesday, 28 March 2023 15:14 PM UTC
Could some insert trigger be involved ?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.