Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I determine whether a column exists in a dw without having the app to crash

2,458 views
Skip to first unread message

Roger Bertilsson

unread,
Feb 6, 2008, 7:20:52 AM2/6/08
to
I'm using powerbuilder 10.5.2 and I have developed a common function that
should be applied on all my datawindow reports.
I would like to check wether a computed column with a specific name exists
in the dwreport. If it exists I will then run additional code.

But how do I write code to check if a column exists without having the
application to crasch.

If I just do a datawindow.getitemstring(1,"column_name"), I get a runtime
error event thought I try to put it in a try catch block as follows

boolean lb_exists
long ll_value
lb_exists = true
try
ll_value = dw_data.getitemnumber(1,"colname")
finally
lb_exists = false
ll_value = -1
end try

if lb_exists = true then
//run additional code
else
//don't run additional code
end if

Please help

/Roger Bertilsson


Paul Horan[TeamSybase]

unread,
Feb 6, 2008, 8:01:00 AM2/6/08
to
You have a TRY but you don't have a CATCH...

You can also use Describe( 'colname.id' ). If that returns a "!", your
column doesn't exist.

Paul Horan[TeamSybase]

"Roger Bertilsson" <roger.be...@eniro.com> wrote in message
news:47a9a624$1@forums-1-dub...

Roger Bertilsson

unread,
Feb 6, 2008, 9:19:05 AM2/6/08
to
Thanks Paul!

It worked fine with describe (colname.type) because it is a computed column.

Now to the next and hopefully the final issue: How can I now change the
value of a computed column at runtime.
I have tried setitem(1,"colname",ll_value) but that rises an error.
I have also tried dwobject.object.colname[1] = ll_value
I have placed the computed column in the header band (thats why I thought I
should use row number 1)

P.S I will use this value from a print dialog to give the user the option to
choose have many pages in horizontal direction that should be printed. That
print dialog should update the computed column and the visible property of
all columns in the dwreport reads that computed column to see whether that
column should be visible or not

/Roger


"Paul Horan[TeamSybase]" <phoran AT sybase DOT com> wrote in message
news:47a9af8c$1@forums-1-dub...

Paul Horan[TeamSybase]

unread,
Feb 6, 2008, 11:32:45 AM2/6/08
to
You *don't* change the value of a computed column. It's computed! You
change the values in the columns that are used in the computation, and the
computed column automatically changes itself. That's the whole point of
computed columns...

Now, if you want to change the computation itself, you can use Modify() or
dot notation on it.

It sounds like you don't want to use a computed column at all. You should
add a "real" column to the result set by changing the SQL statement and
adding something like ",0 as myNewColumn" (or if it's an external source
dw, just add another column to the result set manually).

Now you can use SetItem( 1, "myNewColumn", 2 ) to change it.

Paul Horan[TeamSybase]

"Roger Bertilsson" <roger.be...@eniro.com> wrote in message

news:47a9c1d9$1@forums-1-dub...

M. Searer

unread,
Feb 6, 2008, 3:28:55 PM2/6/08
to

dw.modify("computefieldname.expression='" + ls_expression + "'" )

where computefieldname is the compute field name
and ls_expression is whatever you want it to be. make sure you check the return
value of the modify


"Roger Bertilsson" <roger.be...@eniro.com> wrote in message

news:47a9c1d9$1@forums-1-dub...

0 new messages