1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 5 April 2022 22:57 PM UTC

Hi all,
I'm doing a very simple query window. I can put the dw in query mode, but when I retrieve, my query parameters are ignored and nothing is returned.

Here's the code for the dw:
//Constructor
this.of_SetUpdateable( FALSE )

// First, enable the DW services...
this.of_SetRowSelect( TRUE ) // Row selection service
this.of_SetSort(TRUE) // Sort service
this.of_SetFilter( True ) // Filter Service
this.of_SetQueryMode( TRUE ) // Query Mode service

// Second, set the transaction objects...
this.of_SetTransObject(SQLCA)

// Third, Initialize the DW services
this.inv_rowselect.of_SetStyle( 0 )
this.inv_sort.of_SetColumnNameSource(0) // Use the column names for sorting
this.inv_Sort.of_SetColumnHeader( TRUE ) // Sort when user clicks column header
this.inv_Sort.of_SetStyle( 0 ) // PB's Drag/Drop Sort window
this.inv_Filter.of_SetStyle( 0 ) // PB's Filter window

Here's the code for the window open event:
string ls_querycols[]

ls_querycols[1] = "tmde_noun"
ls_querycols[2] = "tmde_model"
ls_querycols[3] = "tmde_mfr"

dw_1.inv_querymode.of_SetQueryCols( ls_querycols )

// Open in query mode
dw_1.inv_querymode.of_SetEnabled( TRUE )

Here's the code for the Retrieve button:
dw_1.inv_querymode.of_SetEnabled( FALSE )

And the code for the Query button:
dw_1.inv_querymode.of_SetEnabled( TRUE )

Seems pretty simple, but apparently I'm missing something.  Any advice is sincerely appreciated.
~~~Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 6 April 2022 15:18 PM UTC
  2. PowerBuilder
  3. # Permalink

Solved.  I add to put the following code in the dw's pfc_retrieve event:

return this.Retrieve()

~~~Tracy

 

Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 6 April 2022 16:13 PM UTC
Thanks for sharing the solution!
  1. Helpful
  1. Olan Knight
  2. Thursday, 7 April 2022 23:29 PM UTC
One suggestion on coding, based on decades of personal experience:

Please consider separating your commands. While in-line code, like "RETURN this.Retrieve()" minimizes the space required for the code, it maximizes the difficulty if you ever need to debug.



I much prefer using separate lines of code, like this:

ll_rowcount = this.Retrieve()

RETURN ll_rowcount



This way you can put a breakpoint on the line of code that does the actual work easily, if required.

Coding in this manner does not decrease performance because the platform still has to do every step listed.

Remember that 80% of your time will be spent in maintenance, not development.
  1. Helpful 1
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Wednesday, 6 April 2022 03:17 AM UTC
  2. PowerBuilder
  3. # 1

what does the datawindow sql look like.

you should also do a trace to see what is being sent to the database

Comment
  1. Tracy Lamb
  2. Wednesday, 6 April 2022 12:56 PM UTC
Here's the syntax:

SELECT tmde.noun , tmde.model , tmde.mfr , tmde.subcontract , tmde.data_required ,

tmde.type_id , price_code.description , tmde.id

FROM tmde

LEFT OUTER JOIN price_code ON tmde.type_id = price_code.id



The DW is not updatable, all columns have a valid tab order. I use this query window all the time with no trouble in PB 2019. The only difference now is I'm trying to migrate to PB 2021 and the latest PFC libraries.

  1. Helpful
  1. mike S
  2. Wednesday, 6 April 2022 14:20 PM UTC
i would work backwards - if you are using sql server use the profiler tool to see what if anything sql server is getting from the querymode.



you should consider skipping the pfc settings for querymode and just directly do the modify just to make sure it works. that would also narrow down whether it is a pfc issue or something else.



btw, i don't use the pfc so if it is something with the pfc querymode settings i would not be of any help. i do use querymode extensively.







  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.