$loadcols $colcount

Martin Obongita martin.obongita at yahoo.com
Mon Apr 18 06:57:19 UTC 2022

 Hi Kelly,
Thank you for your workaround ideas.I could not figure out what you are trying to do in this line:
  Calculate define as con("$definefromsqlclass('",tableName,"',columns,tSessionRef)")
  Do outList.[define]
Is it possible to define a list from another list variable?For example:
Do iDataList.$definefromsqlclass(iTableClassRef,lTableClassColsList)
lTableClassColsList contains the column names of the schema class.sorry, I have noticed that I should name the local variable as schema not table.
Rgds, Martins

    On Monday, April 18, 2022, 02:38:23 AM GMT+3, Kelly Burgess <kellyb at montana.com> wrote:  
 Hi Martin,

Sorry, I can't make sense of your code.  As I said before, this

> For lLineNum from 1 to  lTableClassColsList.$linecount        
>    Do lTableClassColsList.[lLineNum].$loadcols(lCol01,lCol02,lCol03,lCol04,lCol05,lCol06,lCol07)            
> End For        

does nothing but leave the last line's values in the locals.  Every $loadcols() is loading a line which the next iteration overwrites before anything else happens.  I'm not sure what you think is happening there.

I have some code that sets up an export of user-selected columns from a table class.  So I've got a list of the column names with a boolean telling me which columns the user has selected for export.  I go through that list (iSchemaCols) and for each checked column, I add a column to a 'columns' row.

  For fldLine from 1 to iSchemaCols.$linecount step 1
      If iSchemaCols.[fldLine].iIncludeCol    ## if this column is checked for export
        Calculate colName as iSchemaCols.[fldLine].iColName
        Do columns.$cols.$add(colName,kCharacter,kSimplechar)
      End If
  End For

So now I have a row defined the same as the table*, but only the checked columns are included. Then I define my output list using that column subset.

  Calculate define as con("$definefromsqlclass('",tableName,"',columns,tSessionRef)")
  Do outList.[define]

* except that column types are all character, because I'm just exporting to a text file, so numeric types don't need preserving, and I'm not expecting this to have to work with binary columns...

Now I can use outList with sql statments to select only the desired columns.  This illustrates two things, first that you can pass a row as the second parameter to $definefromsqlclass in order to restrict your list to include only the columns you want (the ones included in the row) - a good way to avoid loading large binary columns when you only want a reference list, or to downsize the column set to what the user selected.  The second point is that you can pass parameters to your table class $construct, like I do above with tSessionRef.  $definefromsqlclass's third parameter becomes the first parameter passed to $construct in the table class, and I use that so I can have my base table class assign the session reference:

    Do $cinst.$sessionobjref.$assign(pSessionRef)

I hope that gives you some ideas.

Manage your list subscriptions at https://lists.omnis-dev.com
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 

More information about the omnisdev-en mailing list