cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Is there any option to give to alias name to sql result columns like Target,Actual?

rvuta1
1-Newbie

Is there any option to give to alias name to sql result columns like Target,Actual?

Hi Sushant

Now I have  to add sql service result to a data table as columns names are coming dynamically.

DataTable have fields like "Product Name","Target","Actual".

SQL service result is coming with column names as Target_A,Target_B..etc  on every iteration .

How to map this result with data table object properties?

Is there any option to give to alias name to sql result columns like Target,Actual?

Regards,

Raji.

Message was edited by: Sushant Pandey branched from https://community.thingworx.com/message/58830#58830

3 REPLIES 3
qngo
5-Regular Member
(To:rvuta1)

Hi, with the SQL query, you can change the column names with "... Target_A AS Product_Name ..." right ? Or you can change the column name after retrieveing the data with RenameField

var params = {

  t: data/* INFOTABLE */,

  from: "Target_A" /* STRING */,

  to: "Product Name" /* STRING */

};

// result: INFOTABLE

var result = Resources["InfoTableFunctions"].RenameField(params);

rvuta1
1-Newbie
(To:qngo)

Hi,

I am passing property names of thing dynamically to service "GetNamedPropertyValues" and retrieving their values.

In  your suggestion I have two doubts.

1..As property name is changing every time ,how can I pass "From" filed dynamically.

2.  I didn't find "RenameFiled" service as the service of infotable. how to check that service?

Regards,

Raji

qngo
5-Regular Member
(To:rvuta1)

Hi,

1. Without knowing your whole usecase, I suggest using Localization Table and provide in advance a "translation" of all possible property names. Then retrieve its "translation" with service, for example:

Resources["RuntimeLocalizationFunctions"].GetEffectiveToken({token: undefined /* STRING */})

or

Resources["RuntimeLocalizationFunctions"].GetEffectiveTokenForLanguage({language: undefined /* STRING */, token: undefined /* STRING */})

2. In service zone, you can check it in two ways:

i. Tab Snippets, type RenameField

ii. Tab Entities, type InfoTableFunctions, then RenameField

Top Tags