{"id":8244,"date":"2019-08-13T16:06:21","date_gmt":"2019-08-13T19:06:21","guid":{"rendered":"http:\/\/kb.elipse.com.br\/en\/?p=8244"},"modified":"2019-08-16T14:02:12","modified_gmt":"2019-08-16T17:02:12","slug":"kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/","title":{"rendered":"KB-102503: Replacing Elipse E3 queries with Stored Procedures in the database."},"content":{"rendered":"<h2><strong>Question:<\/strong><\/h2>\n<p>I have a low performing application due to the many queries being executed cyclically in Elipse E3. In this case, can I replace these queries with\u00a0 Stored Procedures? Will this reduce the amount of processing taking place in E3, and then transfer it to the Database?<\/p>\n<h2><strong>Solution:<\/strong><\/h2>\n<p>Yes. According to the article <a href=\"https:\/\/kb.elipse.com.br\/en\/performance-tips-for-e3\/\" target=\"_blank\" rel=\"noopener noreferrer\">Performance tips for E3<\/a>, you can replace queries with Stored Procedures depending on the query&#8217;s complexity, or even to its execution interval. You can create these SPs in the database specifically for this function, and Elipse E3 will only be responsible for their execution; therefore, the query will be processed in a completely different environment, and not in E3.<\/p>\n<p>In this article, we will show you:<\/p>\n<ol>\n<li>First, how to identify a query in an Elipse E3 object.<\/li>\n<li>Then, how to create a Stored Procedure.<\/li>\n<li>Finally, how to replace the query with a Stored Procedure in an <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/lp\/sql-server\/database-design?view=sql-server-2017\" target=\"_blank\" rel=\"noopener noreferrer\">SQL Server database<\/a> and then execute ir from Elipse E3.<\/li>\n<\/ol>\n<p>For this example, we created a query in a table using three filter variables. The database used in this application was Microsoft SQL Server 2014.<\/p>\n<div id=\"page\" class=\"site\">\n<h3><strong>Query used in an E3Query in E3:<\/strong><\/h3>\n<pre>SELECT Alarms.E3TimeStamp,Alarms.FullAlarmSourceName,Alarms.InTime,Alarms.OutTime,Alarms.Area,Alarms.ConditionName \r\nFROM Alarms \r\nWHERE (( Alarms.E3TimeStamp >= #<%InitialDate%># AND Alarms.E3TimeStamp <= #<%FinalDate%># ) AND ( Alarms.Area = '<%Area%>' )) \r\nORDER BY Alarms.E3TimeStamp ASC<\/pre>\n<h3>Creating the Stored Procedure<\/h3>\n<pre>CREATE PROCEDURE SPAlarms\r\n-- Add the parameters for the stored procedure here\r\n@Area varchar(50), @InitialDate datetime, @FinalDate datetime\r\nAS\r\nBEGIN\r\n-- SET NOCOUNT ON added to prevent extra result sets from\r\n-- interfering with SELECT statements.\r\nSET NOCOUNT ON;\r\n\r\n-- Insert statements for procedure here\r\nSELECT Alarms.E3TimeStamp,Alarms.FullAlarmSourceName,Alarms.InTime,Alarms.OutTime,Alarms.Area,Alarms.ConditionName \r\nFROM Alarms \r\nWHERE (( Alarms.E3TimeStamp >= @InitialDate AND Alarms.E3TimeStamp <= @FinalDate ) AND ( Alarms.Area = @Area )) \r\nORDER BY Alarms.E3TimeStamp ASC\r\n\r\nEND\r\n<\/pre>\n<h3>Executing the Stored Procedure from E3<\/h3>\n<\/div>\n<p>To create the Stored Procedure, you will first need to add the following syntax to a query:<\/p>\n<pre>EXEC SPAlarms '<%Area%>', #<%InitialDate%>#, #<%FinalDate%>#<\/pre>\n<div>Likewise, to set up the variables and return data from the Stored Procedure, add the following script to Elipse E3:<\/div>\n<div><\/div>\n<div>\n<pre>Sub CommandButton1_Click()\r\nset Query = Screen.Item(\"Query1\") \r\nQuery.SetVariableValue \"Area\", \"Area1\"\r\nQuery.SetVariableValue \"InitialDate\", \"13\/11\/2018 15:52:00\"\r\nQuery.SetVariableValue \"FinalDate\", \"13\/11\/2018 15:52:10\"\r\nset RS = Query.GetADORecordset()\r\n\r\nFor i = 1 To RS.RecordCount\r\nC1 = RS(\"E3TimeStamp\")\r\nC2 = RS(\"Area\")\r\nC3 = RS(\"FullAlarmSourceName\")\r\nRS.MoveNext()\r\nstr = str & C1 & vbTab & C2 & vbTab & C3 & vbnewline \r\nNext\r\nMsgBox str\r\nEnd Sub\r\n<\/pre>\n<p><strong>NOTE:<\/strong> In similar cases, you can replace <em>GetADORecordset<\/em> method with<em> GetAsyncADORRecordSet method<\/em>. The <i><a href=\"https:\/\/kb.elipse.com.br\/kb65651-utilizando-o-metodo-getasyncadorecordset\/\">GetAsyncADORecordSet<\/a> <\/i>method creates a Query; once this query finishes, it will generate a <i>OnAsyncQueryFinish <\/i>event in the object; the result passed in this event is therefore the generated result\u00a0 (<i>Recordset<\/i>).<\/p>\n<p>&nbsp;<\/p>\n<h3>Related article<\/h3>\n<hr \/>\n<ul>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/structure-query-language-sql-introduction\/\" target=\"_blank\" rel=\"noopener noreferrer\">Structure Query Language (SQL): Introduction.<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Question: I have a low performing application due to the many queries being executed cyclically in Elipse E3. In this case, can I replace these queries with\u00a0 Stored Procedures? Will&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[735,730],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Replace queries with stored procedures in the Elipse E3 database.<\/title>\n<meta name=\"description\" content=\"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Replace queries with stored procedures in the Elipse E3 database.\" \/>\n<meta property=\"og:description\" content=\"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-13T19:06:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-16T17:02:12+00:00\" \/>\n<meta name=\"author\" content=\"D\u00e9lio Damin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"D\u00e9lio Damin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\"},\"author\":{\"name\":\"D\u00e9lio Damin\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778\"},\"headline\":\"KB-102503: Replacing Elipse E3 queries with Stored Procedures in the database.\",\"datePublished\":\"2019-08-13T19:06:21+00:00\",\"dateModified\":\"2019-08-16T17:02:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\"},\"wordCount\":314,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"articleSection\":[\"DataBases\",\"Elipse E3\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\",\"name\":\"Replace queries with stored procedures in the Elipse E3 database.\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-08-13T19:06:21+00:00\",\"dateModified\":\"2019-08-16T17:02:12+00:00\",\"description\":\"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"KB-102503: Replacing Elipse E3 queries with Stored Procedures in the database.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778\",\"name\":\"D\u00e9lio Damin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"caption\":\"D\u00e9lio Damin\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/delio\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Replace queries with stored procedures in the Elipse E3 database.","description":"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/","og_locale":"en_US","og_type":"article","og_title":"Replace queries with stored procedures in the Elipse E3 database.","og_description":"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.","og_url":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-08-13T19:06:21+00:00","article_modified_time":"2019-08-16T17:02:12+00:00","author":"D\u00e9lio Damin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"D\u00e9lio Damin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/"},"author":{"name":"D\u00e9lio Damin","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778"},"headline":"KB-102503: Replacing Elipse E3 queries with Stored Procedures in the database.","datePublished":"2019-08-13T19:06:21+00:00","dateModified":"2019-08-16T17:02:12+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/"},"wordCount":314,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"articleSection":["DataBases","Elipse E3"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/","url":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/","name":"Replace queries with stored procedures in the Elipse E3 database.","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-08-13T19:06:21+00:00","dateModified":"2019-08-16T17:02:12+00:00","description":"How to create stored procedures in the database to replace complex queries; in this case, the Elipse E3 will only execute the queries.","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/kb-102503-replacing-elipse-e3-queries-with-stored-procedures-in-the-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"KB-102503: Replacing Elipse E3 queries with Stored Procedures in the database."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778","name":"D\u00e9lio Damin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","caption":"D\u00e9lio Damin"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/delio\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8244"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=8244"}],"version-history":[{"count":2,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8244\/revisions"}],"predecessor-version":[{"id":8325,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/8244\/revisions\/8325"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=8244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=8244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=8244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}