1. Olan Knight
  2. PowerBuilder
  3. Thursday, 29 April 2021 20:31 PM UTC

PB2019R3, b2703
PostgreSQL database from Enterprise DB, v12.5
Windows 64 bit platform
32 bit, PFC-based application


I'd like to grab the name of the object when a database error occurs:
   1) Embedded SQL = the name of the current window, tab, or tabpage
   2) DS = the name of the datastore whose database operation failed
   3) DW = the name of the datawindow whose database operation failed


Example: 
   A DBERROR event has been triggered and a MessageBox is created in the corp_n_tr.dberror event.
   How can I find the object currently with focus in that dberror event?

Q1:   Does PB have a string that stores the object currently with focus?

The only path I've come up with is to place code into the PFC to capture the object with focus, maybe in a global variable, more likely in gnv_app.is_object_with_focus (or something like that).

Q2:   Is there another way to approach this?


Many Thanks,

Olan

Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Friday, 30 April 2021 07:56 AM UTC
  2. PowerBuilder
  3. # 1

Hi Olan,

assuming you're using the PFC ancestors for Datawindows and Datastores, a simple this.classname() or this.dataobject in the dberror events of u_dw/u_ds should do the trick for those, I guess? Although I'm not sure what the callstack looks like when a DW triggers a dberror.

Not sure how to handle the embedded SQL case, sorry.

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 30 April 2021 13:18 PM UTC
  2. PowerBuilder
  3. # 2

I'd suggest that you extend your transaction object to include another attribute to store the object info.  Then you can create a method to set the value, maybe even extend the SetTransObject method on u_dw and n_ds to set this attribute on the transaction object.  You could create a nvo that executes SQL for your embedded SQL and add a SetTransObject function on that just like you did for u_dw and n_ds.  Then when you get an error, just query your transaction object to get the new attribute.  For dw and ds you can get the parent, maybe create a method to set/get the parent on your new SQL object as well.  That should do it for ya.

 

Kevin

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 30 April 2021 13:36 PM UTC
  2. PowerBuilder
  3. # 3

Thanks for the quick responses, Kevin & Benjamin!

I'm going to combine your suggestions. I'll extend the transaction object to include the object information AND will try to embed getting the classname() of the calling object into the ancestor code of the PFC and then populating the new n_tr fields!

I'll let everyone know how it turns out!


Thank You Again,

Olan

Comment
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.