<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>using the SQL item type as a view</title><link>https://www.aras.com/community/f/development/8988/using-the-sql-item-type-as-a-view</link><description>Querying a SQL view I built in SSMS from an Aras server method: 
 string SQL_View = &amp;quot;innovator.my_custom_sql_view&amp;quot;; 
 string SQL = &amp;quot;select * from &amp;quot; + SQL_View; Item SQL_qry = inn.applySQL(SQL); 
 This is quick for me because I do a lot in SQL, but I know</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: using the SQL item type as a view</title><link>https://www.aras.com/community/thread/4294?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 00:39:01 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:c1a5e4f8-5e9e-433d-b7f5-739430a33801</guid><dc:creator>paul.sheehy@bd.com</dc:creator><description>&lt;p&gt;&lt;span&gt;Gopikrishnan, thanks for the helpful info!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using the SQL item type as a view</title><link>https://www.aras.com/community/thread/4292?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 18:42:37 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:065ab3f0-99f7-4bd8-90c4-b9a260e6aa90</guid><dc:creator>Gopikrishnan</dc:creator><description>&lt;p&gt;Hi Paul&lt;/p&gt;
&lt;p&gt;You can use below method to get the required view. I used item_number of NCMR as ID is unique for each item type&lt;/p&gt;
&lt;p&gt;Innovator inn = this.getInnovator();&lt;br /&gt;//Verify the Item type name in system&lt;br /&gt;var ncmrItem = inn.newItem(&amp;quot;NCMR MANAGEMENT&amp;quot;, &amp;quot;get&amp;quot;);&lt;br /&gt;ncmrItem.setAttribute(&amp;quot;select&amp;quot;, &amp;quot;id,item_number&amp;quot;);&lt;br /&gt;ncmrItem = ncmrItem.apply();&lt;br /&gt;if (ncmrItem.isError())&lt;br /&gt;{&lt;br /&gt; return inn.newError(&amp;quot;No NCMR Item Found&amp;quot;);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt; var ncmrIdList = new List &amp;lt; string &amp;gt; ();&lt;br /&gt; for (int i = 0; i &amp;lt; ncmrItem.getItemCount(); i++)&lt;br /&gt; {&lt;br /&gt; var ncmrOneItem = ncmrItem.getItemByIndex(i);&lt;br /&gt; //I&amp;#39;m using item_number here as ID is unique for each item type and we might not have same ID used for Part and NCMR. If you want to use ID, then change item_number to id&lt;br /&gt; ncmrIdList.Add(&amp;quot;&amp;#39;&amp;quot; + ncmrOneItem.getProperty(&amp;quot;item_number&amp;quot;, string.Empty) + &amp;quot;&amp;#39;&amp;quot;);&lt;br /&gt; }&lt;br /&gt; var partView = inn.newItem(&amp;quot;Part&amp;quot;, &amp;quot;get&amp;quot;);&lt;br /&gt; partView.setAttribute(&amp;quot;select&amp;quot;, &amp;quot;id,item_number&amp;quot;);&lt;br /&gt; partView.setProperty(&amp;quot;is_current&amp;quot;, &amp;quot;1&amp;quot;);&lt;br /&gt; partView.setProperty(&amp;quot;state&amp;quot;, &amp;quot;Released&amp;quot;);&lt;br /&gt; partView.setProperty(&amp;quot;item_number&amp;quot;, string.Join(&amp;quot;,&amp;quot;, ncmrIdList)); // Change it to ID if you want to use ID instead item_number&lt;br /&gt; partView.setPropertyAttribute(&amp;quot;item_number&amp;quot;, &amp;quot;condition&amp;quot;, &amp;quot;not in&amp;quot;); // Change it to ID if you want to use ID instead item_number&lt;br /&gt; partView = partView.apply();&lt;br /&gt; if (partView.isError())&lt;br /&gt; {&lt;br /&gt; return inn.newError(&amp;quot;No Part item found using this criteria&amp;quot;);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; return partView;&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;We can SQL also but it is good practice to use AML as SQL directly interacts with tables and other server events will not be triggered.&lt;/p&gt;
&lt;p&gt;Views in database is created for Poly Item and are system created. If you want to use SQL for any complex get query, you can use stored procedure and call the SQL Process in your method&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using the SQL item type as a view</title><link>https://www.aras.com/community/thread/4291?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 11:35:57 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:71f33bc1-158b-4209-950d-60bb9186307f</guid><dc:creator>paul.sheehy@bd.com</dc:creator><description>&lt;p&gt;my view query is fairly simple:&lt;/p&gt;
&lt;p&gt;select&lt;br /&gt;id&lt;br /&gt;,ITEM_NUMBER&lt;/p&gt;
&lt;p&gt;from innovator.part&lt;br /&gt;where [state] = &amp;#39;Released&amp;#39;&lt;br /&gt;and IS_CURRENT = 1&lt;br /&gt;and id not in (select NCMR_PART from innovator.NCMR_MANAGEMENT)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if i have to convert the sql query to AML, then what is the point of a SQL item with type=view? how is it used?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: using the SQL item type as a view</title><link>https://www.aras.com/community/thread/4285?ContentTypeID=1</link><pubDate>Wed, 29 Jan 2020 05:15:46 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:e72f2c04-c79f-44a2-8aa8-d4ea52b8bf3b</guid><dc:creator>Gopikrishnan</dc:creator><description>&lt;p&gt;Hi Paul&lt;/p&gt;
&lt;p&gt;Can you post the&amp;nbsp;&lt;span&gt;innovator.my_custom_sql_view SQL query&amp;nbsp; here so that we can have a look&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You need to convert your SQL query to AML query and use it in method. (&amp;quot;SQL&amp;quot; in your method will get the SQL item types but you need to use the correct item type which you are querying in you SQL view).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>