1. David Vasconcelos
  2. PowerBuilder
  3. Monday, 18 December 2017 16:46 PM UTC

How to dynamically add a column which is not part of the select statement during runtime.  I don't see an option for dw-modify for it, all I see is the table.select which then brings up more issues of if I have to add a column in the select then how to find the last column in the select in order to add/change the sql.  Especially if there could be sub-selects, unions or selects within the where clause.

Thanks

Dave V.

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 18 December 2017 17:54 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi David;

   To add an extra column to the DW's SQL result set, add code to the RetrieveStart event or SQLPreview event to change the SQL statement and amend the extra column(s) that you need. That will extend the DW's Primary Buffer at run-time to include the extra column(s) that you need.

   The second step is to add the column(s) to the DW's appropriate band layer if you need the App user to see it visually. To do this, you would use the Create command within a DW Modify() method, as follows (for example):

.Modify( &
"create  column( id= tabsequence= accelerator='' moveable=<0 - False, 1 - True> resizeable=<0 - False, 1 - True> pointer='' band=, Summary, Trailer., Background, Foreground>"  +  & .

.......

No> edit.autoselect= edit.vscrollbar= edit.name='') ")

HTH

Regards ... Chris

TIP: Use the DW Syntax utility to help you code this.

Comment
  1. Mike S
  2. Monday, 18 December 2017 22:58 PM UTC
"add code to the RetrieveStart event or SQLPreview event to change the SQL statement and amend the extra column(s) that you need. That will extend the DW's Primary Buffer at run-time to include the extra column(s) that you need."



wow, really? that is LOT easier than what i had thought had to be done.  changing the buffer via syntax is such a huge pain .

  1. Helpful
  1. David Vasconcelos
  2. Tuesday, 19 December 2017 12:06 PM UTC
Chris just to make sure I am doing this appropriately.  When you mean "add code:" to RETRIEVESTART or SQLPREVIEW are we talking about a dw modify using TABLE.SELECT (i.e Modify("DataWindow.Table.Select=)  to add the column?  Or is there a better/different way?



Dave V.

  1. Helpful
There are no comments made yet.
Mike S Accepted Answer Pending Moderation
  1. Monday, 18 December 2017 17:48 PM UTC
  2. PowerBuilder
  3. # 1

there is no standard feature for this.  however, it can be done.

You have to modify the datawindow syntax extensively during runtime.  You need to be able to change the sql dynamically to add the column to the select, then add the column definition to the datawindow correctly.  then you add the column to the display portion of the datawindow. 

when this is all done you create the datawindow from the syntax.

 

 

 

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.