cancel
Showing results for 
Search instead for 
Did you mean: 

Datawindow Error

Former Member
0 Kudos

Hello All,

sample code:

value of ll_newrow = 0

Line 1 : dw_1.setitem(row, column name, dw_2.getitemstring(ll_newrow, column_name))

Line 2 : dw_1.setitem(row, column name, dw_2.GetNumber(ll_newrow, column_name))



In the line one i ma not getting the application termination error, but getting in the line 2.


can any one explain me.


note : all the columns name are valid.


Thanks& Regard

Rashmi Ranjan Giri

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Why don't you just perform the GetItem<whatever> into their own local variables PRIOR to the setitem statements?  That way you can actually see what is being returned?

Former Member
0 Kudos

Sorry All,

It was wrongly typed.

Line 2 : dw_1.setitem(row, column name, dw_2.GetItemNumber(ll_newrow, column_name))

Former Member
0 Kudos

Can you also post the error message you're getting with that line?

nayf
Participant
0 Kudos

There must be something else going on. I'm pretty sure you cannot do a successful GetItem<Anything> with a row parameter of zero

Do the two lines of code execute straight after each other? Are you absolutely certain that ll_newrow = 0?

Former Member
0 Kudos

Hi Rashmi;

FWIW: To stop application crashes and handle the various error situations properly, I would recommend the following ...

1) You should be able to catch this and other errors if you code the following DC/DS events:

  ItemError

  Error

  DBError

  WSError

2) You also need to code the Application Error event as well.

3) Using a  TRY..CATCH around your code would be even better.

As Neil points out ... GetNumber ( ) is not a standard DC/DS method. Sounds like something that your  application developer has added.

HTH

Regards ... Chris

Former Member
0 Kudos

I just wonder , how Getitemstring worked for row = 0 .

arnd_schmidt
Active Contributor
0 Kudos

So the question is:

Why does dw.GetItemString(0,colname) does a "siltent failure", but dw.GetItemNumber(0,colname)  fails?

I got no idea.

Former Member
0 Kudos

GetItemString and GetItemNumber will never work with row 0.

One reason though that these functions won't throw a runtime error is when either or both of row number and column name parameter is NULL. In this case the function will also return NULL but no runtime error.

arnd_schmidt
Active Contributor
0 Kudos

For columns with numeric data you should use GetItemNumber() or GetItemDecimal().

If your target column in dw_1 is of type string, you have to "cast" the value,

because dw.SetItem () expects the columns datatype.

So if the column's datatype in dw_1 and dw_2 do not match, use something like this.

dw_1.setitem(row, column_name, String (dw_2.GetItemNumber(ll_newrow, column_name)))

hth

Arnd

Former Member
0 Kudos

both column has same datype integer.

Former Member
0 Kudos

GetNumber is not a built-in datawindow method.

It could be that dw2 is inherited from a datawindow user object which has a GetNumber function that allows 0 row as parameter.

GetItemString is a built-in dw method and does not accept 0 row as parameter, so it throws runtime error.

Former Member
0 Kudos

There is no inheritance concept in the datawindow .

Former Member
0 Kudos

Wrong. Datawindow objects have no inheritance but datawindow controls certainly do.

We do not understand what you are asking an explanation of.

The GetNumber() method is not a Powerbuilder function, so it must be custom code i.e. your custom code.

The GetItemString() method is a Powerbuilder function, and accepts an argument of a valid row number. Row 0 is never a valid row number. The expected result therefore is an error reporting the row number is invalid I would think.

You report when you run this you get an error (possibly invalid row number).

Only other thing i can think you are searching for is that the SetItem() method is overloaded. That is is SetItem( long, long ) is not the same as SetItem( long, string ) - hence - assuming your column is a numeric - you cannot update it with a string value ( the return type of GetItemString() )