Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

Close
Important Announcement: WELCOME to the new Schneider Electric Community! Community is now no longer part of Exchange, and is now rebranded under se.com. If you have any bookmarks and links saved, we request you to update them to ensure that you continue accessing our community from this new location. For any issues that you might encounter as part of this change, please reach out to SchneiderCommunity.Support@se.com, and the team will help to get your issues resolved.
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
82125members
349633posts

Tags in SQL statements?

Industry Automation and Control Forum

This forum is addressing industrial automation design & engineering, operations, asset performance, cyber security and digital transformation for Plants & Machines.

Solved
jthyge
Ensign
Ensign
0 Likes
4
1655

Tags in SQL statements?

Hello

 

How is it possible to use tags in SQL statements in Machine SCADA Expert?

 

If I e.g. want to change the database the select is made in. 

 

SELECT * FROM [TAG].trend001

 

Best regards 

 

Jesper

Tags (1)

Accepted Solutions
Paul_Derbyshire
Ensign Ensign
Ensign
1
1632

Re: Tags in SQL statements?

Hell Jesper,

 

You can use {} to enclose tags in a DBExecute script command.

 

For example:

 

 

SELECT * FROM {MyTag}.trend001

 

 

However, you want to change the database?

 

You can change the database/ERP reference in the DB Execute.

 

$DBExecute($MyDBConnection, "SELECT * FROM trend001")

 

Where $MyDBConnection is a string which contains the of the Database/ERP connection name that you created.

 


@jthyge wrote:

Hello

 

How is it possible to use tags in SQL statements in Machine SCADA Expert?

 

If I e.g. want to change the database the select is made in. 

 

SELECT * FROM [TAG].trend001

 

Best regards 

 

Jesper


 

Paul Derbyshire
Senior Product Application Expert | Sales Enablement | HMI Line of Business, Digital Factory | Industrial Automation Business | Schneider Electric

See Answer In Context

Tags (1)
4 Replies 4
Rodrigo_Garcia
Administrator Administrator
Administrator
0
1645

Re: Tags in SQL statements?

Hello @TomDroll , Could you support on this?

 

Regards,

 

Rodrigo G. 


Industrial Automation Community manager

Tags (1)
Paul_Derbyshire
Ensign Ensign
Ensign
1
1633

Re: Tags in SQL statements?

Hell Jesper,

 

You can use {} to enclose tags in a DBExecute script command.

 

For example:

 

 

SELECT * FROM {MyTag}.trend001

 

 

However, you want to change the database?

 

You can change the database/ERP reference in the DB Execute.

 

$DBExecute($MyDBConnection, "SELECT * FROM trend001")

 

Where $MyDBConnection is a string which contains the of the Database/ERP connection name that you created.

 


@jthyge wrote:

Hello

 

How is it possible to use tags in SQL statements in Machine SCADA Expert?

 

If I e.g. want to change the database the select is made in. 

 

SELECT * FROM [TAG].trend001

 

Best regards 

 

Jesper


 

Paul Derbyshire
Senior Product Application Expert | Sales Enablement | HMI Line of Business, Digital Factory | Industrial Automation Business | Schneider Electric

Tags (1)
TomDroll
Lt. Commander Lt. Commander
Lt. Commander
0
1630

Re: Tags in SQL statements?

HI, 

 

Yes it is possible to add tags to your SQL query. there are 3 options available.

 

Option 1:VB Script or Function where you can use VB Variables to build the query and then the $DBExecute function. something like this:

 

Dim SQL

 

SQL = "SELECT FROM Table WHERE Column = " & $TagName

$DBExecute("Connection",SQL)

 

Option 2: You can also use the script database command $DBSelect command with the syntax below.

 

DBSelect("DB1","Table1","Array1,Array2","Column1,Column2","","")

 

Option 3: You can use the database worksheets in the Tasks->Database/ERP folder,  the condition field would be your select where from would be.

 

Hopefully this helps!

 

 

 

 

 
 

 

 

 

 

 

Tom Droll
Attachments
Tags (1)
jthyge
Ensign
Ensign
0 Likes
0
1616

Re: Tags in SQL statements?

Thanks Paul  and Tom

 

This was just what I was looking for. 

 

 

Tags (1)