on 2014 Mar 18 2:40 PM
I use an inline view according below that will use a stored procedure. Input data to the stored procedure arrive from main sql. But it does not work. The code below is an outline to show what I mean. I want to use artid_head and artnr_head from main sql as input to my stored procedure in the inline view. SQL is much larger in practice...
Select tblArt.artid_head, tblBen.artnr_head, (SELECT FIRST STRING(ct_disp.customer) + ' / ' + (select customer.k_namn from customer where customer.k_kod =ct_disp.customer) FROM (SELECT period as period, lev_customer as customer, qty + SUM(best - reserv) OVER (PARTITION BY artnr ORDER BY datum ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as qty FROM sp_get_info(artnr_head, artid_head, 1)) AS ct_disp WHERE ct_disp.qty < 0 ORDER BY ct_disp.period) as cc_plan_customer FROM tblArt, tblBen WHERE tblArt.ID = tblBen.ID
Please post a new question, with code that actually demonstrates the problem described, and we will be happy to look at it.
The code you posted here works on every version of SQL Anywhere from 9 to 16...
@@VERSION,artid_head,artnr_head,cc_plan_customer '9.0.2.3951',2,5,'333 / X' @@VERSION,artid_head,artnr_head,cc_plan_customer '10.0.1.4310',2,5,'333 / X' @@VERSION,artid_head,artnr_head,cc_plan_customer '11.0.1.2960',2,5,'333 / X' @@VERSION,artid_head,artnr_head,cc_plan_customer '12.0.1.3994',2,5,'333 / X' @@VERSION,artid_head,artnr_head,cc_plan_customer '16.0.0.1691',2,5,'333 / X'
Here is the "reproducible"...
CREATE TABLE tblArt ( ID INTEGER, artid_head INTEGER ); INSERT tblArt VALUES ( 1, 2 ); CREATE TABLE tblBen ( ID INTEGER, artnr_head INTEGER ); INSERT tblBen VALUES ( 1, 5 ); CREATE TABLE customer ( k_namn VARCHAR ( 10 ), k_kod INTEGER ); INSERT customer VALUES ( 'X', 333 ); CREATE PROCEDURE sp_get_info ( p1 INTEGER, p2 INTEGER, p3 INTEGER ) BEGIN SELECT 111 AS customer, 222 AS period, 333 AS lev_customer, -444 AS qty, 555 AS best, 666 AS reserv, 777 AS artnr, 888 AS datum; END; Select @@VERSION, tblArt.artid_head, tblBen.artnr_head, (SELECT FIRST STRING(ct_disp.customer) + ' / ' + (select customer.k_namn from customer where customer.k_kod =ct_disp.customer) FROM (SELECT period as period, lev_customer as customer, qty + SUM(best - reserv) OVER (PARTITION BY artnr ORDER BY datum ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as qty FROM sp_get_info(artnr_head, artid_head, 1)) AS ct_disp WHERE ct_disp.qty < 0 ORDER BY ct_disp.period) as cc_plan_customer FROM tblArt, tblBen WHERE tblArt.ID = tblBen.ID;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.