Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Using DB constraint Value in th same property

Experimenter
Experimenter

I am having a property which is coming through DB constraint. Later, I perform some unit conversion activity with it. Is it possible to do it in the original property without creating a separate property for unit conversion? 

8 REPLIES

Re: Using DB constraint Value in th same property

Valued Contributor
Valued Contributor

I believe you can use dynamic query and to do unit conversion inside the query.

Dynamic query can look something like this:

Select 1000 * Radius as RadiusMM
From Cell
Where....

Re: Using DB constraint Value in th same property

Experimenter
Experimenter

as based on your suggestion, I wrote this . 

Dim x As String
x = "Select [pdropcalc_sc] FROM [FWHRead] Where ProjectId='"+Convert.ToString(Me.project_id)+"'"
g_ComponentData.ExecuteSQL(x)
Dim y As Double= Convert.ToDouble (x)
Result = y*7.030696*.01

 

But rulestream engineer is showing input string is not in correct format. 

Re: Using DB constraint Value in th same property

Valued Contributor
Valued Contributor

What do you expect to get using this rule? I see that you are trying convert to Double your X variable which is your string query generally.

Also keep in mind that g_ComponentData.ExecuteSQL return DataSet, not the value.

Re: Using DB constraint Value in th same property

Experimenter
Experimenter

I want to get a cell value from a table and then apply unit conversion on it. Currently, I make a database constraint and then apply unit conversion in a different property. I am having long list of such properties. So , if there is anyway to do in same property of which db constraint is being made.

Re: Using DB constraint Value in th same property

Valued Contributor
Valued Contributor

@arp123, Why don't you like my first answerSmiley Happy

If it is not really clear I can show you examaple later today.

Re: Using DB constraint Value in th same property

Experimenter
Experimenter

It will be of great help if you could share an example.

Re: Using DB constraint Value in th same property

Valued Contributor
Valued Contributor

Hi, @arp123. Below some explanations.

  • Initial table

image.png

 

  • Example of the query where you can generate new column (RadiusMM) on a fly with converted values.

image.pngQuery

  • Use dynamic query in the DBConstrain:

image.pngRule with dynamic query

 

image.pngUse dynamic query in DBConstrain

 

image.pngBind the properties

 

  • See the result in Engineer:

image.png

 

Hope this help.

 

Re: Using DB constraint Value in th same property

Pioneer
Pioneer

@arp123the general answer to your main question is that if you bind a property to a DB constraint, RS does not execute the formula. The property formula is executed ONLY if the DB constraint fails to retrieve any row or it retrieves a NULL value.

 

Dharmesh Sanghavi