1. Michael Zuskin
  2. PowerBuilder
  3. Tuesday, 18 June 2019 10:55 AM UTC

I need to get the value of a retrieval argument by which the datawindow has been retrieved. I use this method:

dw_emp_by_dept.Describe("Evaluate('dept_id', 1)")

But this method doesn't work if the DW has no rows. That makes sense because it Evaluate()s the 1st row.

Is there any way to obtain the argument's value if zero rows have been retrieved?

Michael Zuskin Accepted Answer Pending Moderation
  1. Wednesday, 19 June 2019 11:34 AM UTC
  2. PowerBuilder
  3. # 1

OK, I decided to leave it with row number 0 (since it works at least sometimes :-D ). Thanks to everybody!

Comment
There are no comments made yet.
Michael Zuskin Accepted Answer Pending Moderation
  1. Wednesday, 19 June 2019 11:06 AM UTC
  2. PowerBuilder
  3. # 2

It's strange... When I write 0 as row number, sometimes it works, sometimes doesn't, even though the DWs are identical by type and retrieval method...

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 19 June 2019 02:26 AM UTC
  2. PowerBuilder
  3. # 3

Hey Michael,

I have a DW with retrieval argument = "PartialName".

In the RetrieveEnd event I have this code that works for any number of rows: 0, 1, or more.

>>> Edit 19-Jun: Added NULL-check to make NULL argument stand out more obvious.
>>> The underlined segment makes sure you see when retrieval arg's value is null.
>>> If the value is a non-NULL value, you see the actual value of partialName which may be the empty string.

HTH /Michael


// Display retrieval argument
sle_SearchArg.Text = Describe("Evaluate('If(IsNull(partialName), ~"~", partialName)', 0)")
Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 18:28 PM UTC
  2. PowerBuilder
  3. # 4

René is correct, use 0 or 1, the evaluate will return the correct value.

 

example:

cus is the name of the argument in the datawindow.

 

long ll_r
string ls_arg

dw_1.dataobject = 'd_testargget'
dw_1.settransobject( sqlca )

ls_arg = 'a'
ll_r = dw_1.retrieve( ls_arg )  //returns 0 rows, ll_r = 0

string ls_value
ls_value = dw_1.Describe("Evaluate('cus', 0)")

------------

ls_value  = 'a'   //argument value

 

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 17:49 PM UTC
  2. PowerBuilder
  3. # 5

I understand. IN that case I agree with Chris's approach. Capture the parameters in instance variables, then they will be available if an error occurs. If no error occurs, then  you don't need that data.


// Get fancy and list the parameter name + the values as follows:
     ls_parmlist = ls_parmlist + "~r~n Name: " + ls_parameter_name + ", Value: " + ls_parameter_value_entered + &
                                         "~r~n Name: " + ls_parameter_name + ", Value: " + ls_parameter_value_entered + &
   ....for each of the DW parameters.

 

 

long   ll_rowcount, ll_id

 

ll_rowcount = dw_emp_by_dept.RowCount()
IF (ll_rowcount > 0) THEN

   ll_id = Long (dw_emp_by_dept.Describe("Evaluate('dept_id', 1)"))

ELSE

   MessageBox ("Error", "The parameters specified resulted in no data:" + &
               "~r~n " + ls_parmlist, Information!)

END IF

Olan

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 17:20 PM UTC
  2. PowerBuilder
  3. # 6

long   ll_rowcount, ll_id

 

ll_rowcount = dw_emp_by_dept.RowCount()
IF (ll_rowcount > 0) THEN

   ll_id = Long (dw_emp_by_dept.Describe("Evaluate('dept_id', 1)"))

ELSE

   SetNull (ll_id)   --- OR ---  ll_id = 0

END IF

Olan

Comment
  1. Michael Zuskin
  2. Tuesday, 18 June 2019 17:31 PM UTC
But the value of the retrieval argument is not 0 or NULL, I cannot mislead the user. I need the actual value, by which no rows were retrieved.
  1. Helpful
  1. Michael Zuskin
  2. Tuesday, 18 June 2019 17:34 PM UTC
Currently, I display "Cannot define argument's value since no rows were retrieved" in that situation. Ugly, by honestly. :-)
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 15:37 PM UTC
  2. PowerBuilder
  3. # 7

Hi, Michael -

What if you perform an InsertRow(0) when there are no rows retrieved before you issue the Describe/Evaluate?

Comment
  1. Michael Zuskin
  2. Tuesday, 18 June 2019 16:13 PM UTC
The DW Spy only displays information about DW, it never changes it (who knows what can be triggered by that in different applications where the Spy is used).
  1. Helpful
  1. Michael Zuskin
  2. Tuesday, 18 June 2019 16:25 PM UTC
Anyway, I tried, but Evaluate() still returns empty string. Probably, the values of the retrieval args are written only to the retrieved rows, not ones inserted later
  1. Helpful
There are no comments made yet.
Michael Zuskin Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 14:11 PM UTC
  2. PowerBuilder
  3. # 8

You may also specify 0 as Row.

I tried that. It returns empty string (even though works fine when at least one row is retrieved).

Why don't you store the value in an instance variable or similar when you retrieve?

I need a generic solution. It's for a tool, used by many developers all over the world (DataWindow Spy).

Comment
  1. René Ullrich
  2. Wednesday, 19 June 2019 05:18 AM UTC
Hi Michael,

0 or 1 as row works for me.

I guess the name of your retrieval argument is the same as a name of a column in your datawindow?

So it may be that you evaluate the value of the columns instead of the retrieval argument.

Try to change the name of the retrieval argument.

HTH,

René
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 12:33 PM UTC
  2. PowerBuilder
  3. # 9

You can include the argument in the result set.

Comment
  1. Sivaprakash BKR
  2. Tuesday, 18 June 2019 12:57 PM UTC
I think, it will not give the value, when zero rows are retrieved.
  1. Helpful
  1. Roland Smith
  2. Tuesday, 18 June 2019 13:22 PM UTC
Like Kevin said, store the argument in an instance variable.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 12:32 PM UTC
  2. PowerBuilder
  3. # 10

Why don't you store the value in an instance variable or similar when you retrieve?  At some point you are calling dw.Retrieve(arg) right?

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 18 June 2019 16:53 PM UTC
Excellent idea Keven!

I would suggest using an instance variable with an array of ANY.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 18 June 2019 11:55 AM UTC
  2. PowerBuilder
  3. # 11

Hi Michale,

in my test the Evaluate also works with Row 1 if there are now rows.

You may also specify 0 as Row.

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.