Welcome to the new Schneider Electric Community

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

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
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
84247members
353346posts

Script Variant

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

andrew101
Ensign
Ensign
0 Likes
2
501

Script Variant

Simpe answer i hope. Im trying to have buttons execute a mimic script but change the variant, where pVariant is the ID

 

-script-

SELECT

    Recordtime

FROM

    CDBHISTORIC

WHERE

    ID = pVariant AND

    Recordtime BETWEEN { OPC 'Y' } AND { OPC 'Y + 1Y' } AND

    STATEDESC = 'Running'"
end sub

2 Replies 2
AdamWoodland
Commander Commander
Commander
0 Likes
0
493

Re: Script Variant

There are a few ways to do it, but where is pVariant coming from? Is it a point value, is it an input from the user?

 

Once you have that value and have validated it (i.e. it is only an integer) then you can just do some simple string concatenation to get the SQL you need, i.e.

 

"SELECT columns FROM table WHERE id = " & pVariant & " AND something = somevalue"

 

Then use Server.Query to execute it and get the results, the help has that info in.

BevanWeiss
Spock
Spock
0 Likes
0
469

Re: Script Variant

As Adam mentioned, if you really need this in your script, you can do it that way.

 

But... if you want to display it for a user, then you probably want to use an animation for the SQL expression on an embedded query list.

 

You could do something like:

'SELECT

    Recordtime

FROM

    CDBHISTORIC

WHERE

    ID = ' + REGISTRY("RegistryLocationWhereYouHavepVariantStored", -1) + ' AND

    Recordtime BETWEEN { OPC 'Y' } AND { OPC 'Y + 1Y' } AND

    STATEDESC = ''Running'''

 

NOTE: single quotes within the SQL need to be escaped as two single quotes (i.e. 'Running' -> ''Running'')

 

Then if you had a button to change the variant, it could simply set the registry value.  The animation 'plumbing' is normally good for this, when your button changes the registry field, then the animations based on that are updated (I've never had it fail... outside of bug situations).

 


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..