How to get Column names from dynamic Datawindow?

Attached is a piece of code that opens a datastore based on a datawindow
which is itself based on a stored procedure that takes two parameters.

There are two records in the dataset. The problem is thus: this code
will be customized in each application but the "linked" list it will be
stored in is part of a PFC service that will not know the number/names
of fields until run time. That code is generic and creates the initial
linked list from records stored in a table that "defines" the
number/names of fields.

Since the code must not make any assumptions about the order of the
fields, I have to cycle through the field (column) names of the
datawindow at run time and based on the column name, store it's value in
the list.

The code below seems straight forward but the "GetColumnName()" function
NEVER returns any names. What's going on? "SetRow()/_Col()" are
returning OK as well, but I have my doubts!
-----------------------
/*
This function is a PLACE holder for a function that must be
re-descended in the actual application.

It opens a datastore for the users rights and then cycles through
the rights linked list and updates the value of the group's rights
field.
*/
integer li_result = 0
long ll_row_index = 0, ll_row_count = 0, li_fld_index = 0, li_fld_count
= 0
long ll_num_errors = 0
boolean lb_result = true
string ls_msg = "", ls_group_name = ""
datastore lo_rights
n_cst_lln_right_group lo_node_found, lo_node_search
//io_lst_right_groups io_lst_right_groups

SetPointer (Hourglass!)

lo_rights = create datastore
lo_rights.dataobject = "d_rights_usps_by_app_user"
lo_rights.settrans (io_tr_appsec)
li_result = lo_rights.retrieve (is_app_name, il_user_login_id)

SetPointer (Arrow!)

if li_result = -1 then // unable to get info
   Messagebox ("Datastore Failure", "Unable to open dataobject (app name
= " + is_app_name + &
    " User ID = " + String(il_user_login_id) + ")", Exclamation!, ok!)
 return false
end if

if lo_rights.RowCount() = 0 then
 Messagebox (is_module_name + " definition error", "Unable to retrieve
user's group information. " + &
    "Contact " + is_app_owner_nds_fqn + " for more information",
Stopsign!, ok!)
 destroy lo_rights
 return false
end if

/* for each record in the datastore, and for each app's record type in
the database,
there will always be two fields as the primary key: App_Name and
Group_Name.
The remaining fields by name correlate to the "right groups"
by name in the linked list. The individual groups are initially set to 0
(no rights);
at this point, given the current numerical value for a given field, OR
it against the
"current" value of the field to create a cumulative value at the end of
the record set.
*/

SetPointer (Hourglass!)

ll_row_count = lo_rights.rowcount ()
ll_row_index = 1
// how many fields in the application's setup?
li_fld_count = Long(lo_rights.object.datawindow.column.count)
lo_node_search = create n_cst_lln_right_group

do while ll_row_index <= ll_row_count

   lo_rights.SetRow (ll_row_index) // move the correct row
 ll_num_errors = 0

   li_fld_index = 3 // start at the first right's field
 do while li_fld_index <= li_fld_count // cycle through all the fields
      SetNull(lo_node_found)
      li_result = lo_rights.SetColumn (li_fld_index)
  // -> currently returns '1' - success
//  Messagebox ("SetColumn", "Returned " + String(li_result) + " for
column " + String(li_fld_index), &
//     Information!, OK!)

    // get the name of the current column and look up it's group in the
list
  ls_group_name = lo_rights.GetColumnName()
  // -> currently returns a blank string indicating an error for some
reason

  lo_node_search.of_setkey (ls_group_name)
    // see if the node is in the list
    li_result = io_lst_right_groups.of_find (lo_node_found,
lo_node_search)
    if li_result <> 1 then
//     Messagebox ("of_load_user_rights", "Unable to find the group node
called " + &
//        ls_group_name, Exclamation!, OK!)
         ll_num_errors++
    else
   // update the group's cumulative value
   lo_node_found.of_update_right (lo_rights.getitemnumber(1,
li_fld_index))
    end if
    li_fld_index++
   loop
 Messagebox ("Number of Errors", String(ll_num_errors) + " out of " +
String(li_fld_count) + &
    " where encountered trying to look up column names", &
    Exclamation!, OK!)
   ll_row_index++
loop
SetPointer (Arrow!)
destroy lo_rights

return lb_result


0
Arnie
3/9/2000 10:16:31 PM
sybase.powerscript 7704 articles. 0 followers. Follow

1 Replies
514 Views

Similar Articles

[PageSpeed] 16

Arnie,

That's because GetColumnName() returns the current column with focus.  While
you iterate through the columns, use Describe() to get the Name property -
i.e. dw_1.Describe("#1.Name").

HTH,
--
Sam Tai
Cotelligent

Arnie Morein <amorein@austin.rr.com> wrote in message
news:38C822BE.B030FFC3@austin.rr.com...
> Attached is a piece of code that opens a datastore based on a datawindow
> which is itself based on a stored procedure that takes two parameters.
>
> There are two records in the dataset. The problem is thus: this code
> will be customized in each application but the "linked" list it will be
> stored in is part of a PFC service that will not know the number/names
> of fields until run time. That code is generic and creates the initial
> linked list from records stored in a table that "defines" the
> number/names of fields.
>
> Since the code must not make any assumptions about the order of the
> fields, I have to cycle through the field (column) names of the
> datawindow at run time and based on the column name, store it's value in
> the list.
>
> The code below seems straight forward but the "GetColumnName()" function
> NEVER returns any names. What's going on? "SetRow()/_Col()" are
> returning OK as well, but I have my doubts!
> -----------------------
> /*
> This function is a PLACE holder for a function that must be
> re-descended in the actual application.
>
> It opens a datastore for the users rights and then cycles through
> the rights linked list and updates the value of the group's rights
> field.
> */
> integer li_result = 0
> long ll_row_index = 0, ll_row_count = 0, li_fld_index = 0, li_fld_count
> = 0
> long ll_num_errors = 0
> boolean lb_result = true
> string ls_msg = "", ls_group_name = ""
> datastore lo_rights
> n_cst_lln_right_group lo_node_found, lo_node_search
> file://io_lst_right_groups io_lst_right_groups
>
> SetPointer (Hourglass!)
>
> lo_rights = create datastore
> lo_rights.dataobject = "d_rights_usps_by_app_user"
> lo_rights.settrans (io_tr_appsec)
> li_result = lo_rights.retrieve (is_app_name, il_user_login_id)
>
> SetPointer (Arrow!)
>
> if li_result = -1 then // unable to get info
>    Messagebox ("Datastore Failure", "Unable to open dataobject (app name
> = " + is_app_name + &
>     " User ID = " + String(il_user_login_id) + ")", Exclamation!, ok!)
>  return false
> end if
>
> if lo_rights.RowCount() = 0 then
>  Messagebox (is_module_name + " definition error", "Unable to retrieve
> user's group information. " + &
>     "Contact " + is_app_owner_nds_fqn + " for more information",
> Stopsign!, ok!)
>  destroy lo_rights
>  return false
> end if
>
> /* for each record in the datastore, and for each app's record type in
> the database,
> there will always be two fields as the primary key: App_Name and
> Group_Name.
> The remaining fields by name correlate to the "right groups"
> by name in the linked list. The individual groups are initially set to 0
> (no rights);
> at this point, given the current numerical value for a given field, OR
> it against the
> "current" value of the field to create a cumulative value at the end of
> the record set.
> */
>
> SetPointer (Hourglass!)
>
> ll_row_count = lo_rights.rowcount ()
> ll_row_index = 1
> // how many fields in the application's setup?
> li_fld_count = Long(lo_rights.object.datawindow.column.count)
> lo_node_search = create n_cst_lln_right_group
>
> do while ll_row_index <= ll_row_count
>
>    lo_rights.SetRow (ll_row_index) // move the correct row
>  ll_num_errors = 0
>
>    li_fld_index = 3 // start at the first right's field
>  do while li_fld_index <= li_fld_count // cycle through all the fields
>       SetNull(lo_node_found)
>       li_result = lo_rights.SetColumn (li_fld_index)
>   // -> currently returns '1' - success
> //  Messagebox ("SetColumn", "Returned " + String(li_result) + " for
> column " + String(li_fld_index), &
> //     Information!, OK!)
>
>     // get the name of the current column and look up it's group in the
> list
>   ls_group_name = lo_rights.GetColumnName()
>   // -> currently returns a blank string indicating an error for some
> reason
>
>   lo_node_search.of_setkey (ls_group_name)
>     // see if the node is in the list
>     li_result = io_lst_right_groups.of_find (lo_node_found,
> lo_node_search)
>     if li_result <> 1 then
> //     Messagebox ("of_load_user_rights", "Unable to find the group node
> called " + &
> //        ls_group_name, Exclamation!, OK!)
>          ll_num_errors++
>     else
>    // update the group's cumulative value
>    lo_node_found.of_update_right (lo_rights.getitemnumber(1,
> li_fld_index))
>     end if
>     li_fld_index++
>    loop
>  Messagebox ("Number of Errors", String(ll_num_errors) + " out of " +
> String(li_fld_count) + &
>     " where encountered trying to look up column names", &
>     Exclamation!, OK!)
>    ll_row_index++
> loop
> SetPointer (Arrow!)
> destroy lo_rights
>
> return lb_result
>
>


0
Sam
3/9/2000 11:41:25 PM
Reply:

Similar Artilces:

How can I get the column name of a datawindow column?
I want to get the column name in tablename.columnname format. I have tried to get it using dbname property. However, I found that it work only if the tables in the datawindow are inner join. If the tables in the datawindow are outer join, the dbname only return the columnname and the tablename is missed. Do you have any idea? Charles You could add the name to the select clause or to the tag property. Or you caould check to see if it is a join or not (by seeing if there is a '.' in the column name) if not then get the sql select statment and parse to find the table...

how to get all the column names from datawindow
I would like to get all the column names from datawindow. any help apppreciated TIA //1. Column names Int li_col_count, ls_columns[] li_col_count = integer(idw.Describe("DataWindow.Column.Count")) FOR i = 1 TO li_col_count ls_columns[i] = idw.Describe("#" + String(i) + ".Name") Next //2. If you need to include CF's look at the Object.DataWindow.Objects string (tab separated) and parse it back to an array of DW objects. hth > I would like to get all the column names from datawindow. > > any help apppreciated > TIA...

How does a datawindow column get its name?
Q: How does a column get its name? Pretext: Datawindow is built using Tabular - SQL Select - and Converted to Syntax. On existing datawindow - the column names have been modified to strip off the table names (so table name "company" was stripped from column name "company_code" to make it as just "code"). Change: I was changing this existing datawindow - adding one another column. After adding the column into the SQL-SELECT, the datawindow display warning message as "SELECT change has forced update specification change" ( I have update pro...

get column name dynamically in webpage
Hi,I am using <%# DataBinder.Eval(Container.DataItem,filedname %> in my webpage.But I want to get the first field's name in the container I have here(It depends on the dataset I bind to the datalist).How can I do that?thanks i'm not sure what you are trying to acheive here. can you describe it in more detail? I mean how can I get the column name here?I can't hardcoded it here because the datalist will bind to different dataset based on the user selection,so the field name will change....

CrossTab Datawindows and Getting the Column Names
Hi, I'm kind of new to the Crosstab Datawindow. Currently, we are trying to develop a Crosstab Datawindow to show a grid similar to: Extra Small Small Medium Large Extra Large Blue 1 Red 1 Green 1 Yellow 1 with empty boes to type in. This would be used when someone is taking an order for shirts, for example. I can pretty much get this far. My problem is when I am trying to get the name for the Columns. I am using the...

Dynamically changing DataWindow column names
I need a way to "Dynamically change DataWindow column names". This so that when a user wants to save a datawindow as an excel file, that a more user-friendly column name can be used instead of the cryptic database column name. Please advise. Thank you. Dynamically create an external dw with all the columns you want and column names you want. Then move the data from original dw to know dw, and then call saveas(). It does not need any formatting. Create a external dw, export to syntax, look at how its structured. Then you can dynamically build one very easily by loop...

Get Value of column dynamic of datawindow crosstab
Hello to all. I have datawindow crosstab and I need to obtain the value of the generated columns . Thanks! Hola a todos. Tengo un datawindow crosstab y necesito obtener el valor de las columnas generadas dinamicamente Read the thread started by Davy De Permentier with the subject "CrossTab" on friday. "Raul Gil" <gl_ra@hotmail.com> wrote in message news:414f86f2$1@forums-1-dub... > Hello to all. > > I have datawindow crosstab and I need to obtain the value of the > generated columns . > > Thanks! > &...

how to get the column names of a dynamic executed procedure?
I wrote a pb a application that executes a sybase procedure that I get its name and parameters dynamically. I use DynamicDescriptionArea for that and It works fine , except for that I can't get the columns titles. Is there another way to execute a procedure from pb and get the columns names as well ? how ? do you have a code sample for me ? I'm using powerbuilder 6.5 and Sybase 12.0 thanks ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp Column names for what? Please, more info. Alex Osin "Izik I." <izi...

rules-based generic approach to get friendly column names in a Dynamic Data project
All --Please help. I am looking for a rules-based generic approach to get friendly column names in a Dynamic Data project.For instance, suppose I use a rule to name my columns in the database that separates words with PascalCased names-- FirstName, LastName, MiddleName, and so on.Now, suppose that I want to have a rules-driven friendly name creation done automatically by the Dynamic Data templating process to convert such names "insert space if next is capital" so we get... First Name, Last Name, MIddle Name.Or something like that. Maybe the rule is "replace underscores in the...

Get Name of DW Identity Column (column.identity property requires looping thru all columns)
I need to locate the identity column for a DW. Only method i see is use of the columnName.Idenity property - which requires you to traverse all the DW columns and then look up the identity property for each until one is yes. Is there a way just to get the identity column directly - or the Primary Key. thanks, Dave As one can see in he syntax, sorry no. I played around with it this week also as I am using DW.Net2.0 with DataSets and a DataSet can not create update commands from a SQL statements where one has 2 tables. But, now, with the help of DW.Net it can do it ...

Getting Datawindow name from datawindow child variable
Hi ! I want to get the datawindow (name) from a datawindowchild variable. But, the dwc has no way to get it. I want the code like this : datawindowchild dwc dw_1.getchild("colname", dwc) dw_2.dataobject = dwc.dataobject -------------- -> X In the above code, "dw_1.object.colname.dddw.name" is what I want. But, from the "dwc", I can't know that. Please, help! thx. You're correct. There is no way to get the datawindow name from the datawindow child, you have to ask the paren...

Get Column Number Using Column Name
This ones burning me because, I am sure i've done it before and It's simply slipping my mind. I need to be able to get a column number using the column name. i.e. Column name = 'effective_date'. Using effective date - get the column number that belongs to effective date. Any help is appreciated!! Thanks!! William dw.Describe("effective_date.ID") Good Luck Michael Walker Cascadia Software William_Shiers wrote: > This ones burning me because, I am sure i've done it before and It's simply > slipping my mind. > ...

Dynamically name columns in dynamically created datagrid
I am using code that I found on the net to take a datatable, drop it into a datagrid, and then export the whole thing as an excel spreadsheet. So far for the small numberes I have tried it works. Currently I have an application where the number of columns ranges between 40 and 70. The problem that I have is I want the first row to have names which are meaningful to the user, but I don't want to rename my datatable columns, only the datagrid columns. Right now the Excel column names are the same as the datatable names. Those names are meaningful to me (the programmer) but meaningless to...

SQL: Column names, can ONLY get "name" instead of "table.name"
Hey all, When iterating through column names returned from a query, I need to get "table.name" rather than just "name" Check it out: If I have an SQL statement "SELECT table1.ID, table2.ID FROM table1, table2;" And table1 has a column name 'ID' and table2 has a column name 'ID' aswell, and i run the query, the dataset will contain column names 'ID' and 'ID' instead of 'table1.ID' and 'table2.ID' It is extremely important that I can differenciate between the 2 fields, and know where each of them come from. The same thing happen...

Web resources about - How to get Column names from dynamic Datawindow? - sybase.powerscript

PowerBuilder - Wikipedia, the free encyclopedia
PowerBuilder is an integrated development environment owned by Sybase , a division of SAP . It has been in use since 1991, peaking around 1998 ...

Intelligent Versus Surrogate Keys
Should I use business columns as primary key fields for tables in thedatabase, or generate artificial primary key values? When business-related ...

chevy volt
ProEXR File Description =Attributes= channels (chlist) compression (compression): Zip dataWindow (box2i): [0, 0, 5119, 2475] displayWindow (box2i): ...

Enable - A comprehensive solution for the localization of PowerBuilder applications Untitled Document ...
Enable is localization/ translation tool used by PowerBuilder developers to make their applications multilingual.Enable is a powerful tool that ...

comp.lang.clipper.visual-objects - Google Groups
comp.lang.clipper.visual-objects 1-20 von 33006 Themen werden angezeigt Integrity of a file marcosm...@gmail.com 09:35 Combobox value Lu 08:12 ...

Sybase PowerBuilder tool readied for Microsoft's .Net
Developers can choose Win32 or newer style .Net development

PowerToTheBuilder - PowerBuilder UI Controls
HOME - COMPONENTS - PB UI DESIGNER - DOWNLOAD\PURCHASE - SUPPORT - FAQ - ABOUT Take Control of your UI with PB Ultimate Suite PowerToTheBuilder.com ...

Beautiful iPad Mini 3 Concept Reimagines Appleā€™s Tablet With iPhone 6 Design, Gold Color [Images]
The iPhone 6 may be grabbing all of the recent headlines due to its impending announcement, but spare a thought for those who prefer to stay ...

Java Networking - Real's HowTo
Real's HowTo Custom Search Java Language String and Number Applet AWT Swing Environment IO Javascript interaction JDBC Thread Networking JSP ...

Business Intelligence Products - Database Management, Data Warehousing & Mobility Software - Sybase Inc ...
Sybase offers a variety of Business Intelligence (BI) software like products for database management, data warehousing and mining, data integration ...

Resources last updated: 12/9/2015 10:09:18 PM