2 Replies Latest reply: Jul 10, 2014 8:38 AM by BluShadow RSS

    need help with XQuery cursor


      Dear Friends,

      I a using Squirrel SQL client v. 3.5.2. 

      I need to write cursor to loop for all records 'sku' in my query. I wrote a cursor for the same but it gives me an error stating "   " hence asking me to write Xquery for the same using xml.

      Below is my original query for which I need to write a cursor :


      select o_parentId, sku,

      case when sum_quantity2 + sum_quantity =0 then (t.sum_completed_1024 * 365) /((t.sum_quantity2 + t.sum_quantity)/2) = 0


      cast((t.sum_completed_1024 * 365) /((t.sum_quantity2 + t.sum_quantity)/2) as FLOAT)


      as "LUG_nR_Stk"

      from (

      select o_parentId, sku, sum(coalesce((quantity2),0)) as sum_quantity2, sum(coalesce((quantity),0)) as sum_quantity, sum(coalesce((completed_1024),0)) as sum_completed_1024, count(distinct(date_created)) as date_count

      from views.own_stock_inventory i left join views.ownstock_article a on i.sku = a.article_id where o_parentId is NOT NULL

      group by o_parentId, sku

      ) t

      group by o_parentId, sku, t.sum_completed_1024, t.date_count, t.sum_quantity2, t.sum_quantity


      I need XQuery more specifically XML Cursor for the above query. Any help will be highly appreciated.