Site hosted by Angelfire.com: Build your free website today!
 

PowerBuilder - How-to Create an External Datawindow at Runtime


You said you needed to dynamically create a DW at runtime. The syntaxFromSQL is the easiest way to do so. You need to create an SQL SELECT statement having the desired column names and types in a string. For example, if you wanted two numbers and a string in the "external", you might say something like this: You can create an external DW using a dummy SQL (within syntaxFromSQL)..., e.g.

   string ls_sql, &
          ls_style, &
          ls_err, &
          ls_dwCreate
   
   ls_sql = "select 00000, '', 0000 from sys.dummy"
   ls_style = "Style(Type=Grid)"
   ls_dwCreate = SQLCA.syntaxFromSQL(ls_sql,ls_style,ls_err)
   If (ls_err <> "") Then
      // Put your error processing here
      Return
   End If
   dw_1.create(ls_dwCreate, ls_err)
   If (ls_err <> "") Then
      // Put more error processing here
      return
   End If
   // Continue with normal processing

At this point, dw_1 will have a dataObject that has two number columns and a string column. You can use it as if it is external.  Obviously, this example isn't "dynamic", since I hard-coded the SELECT statement in the string. In your program, you should build the string dynamically, using whatever business logic applies. Then, use something like the above to turn it into a dataWindow.