Я пытаюсь выполнить мой sproc, используя codeignter, но я получаю эту ошибку.
это как я называю мой sp через codeigniter $this->db->query("SP_COUNT_IRA 'ROGER', 'GLOBE' ");
Ниже мой sproc.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_COUNT_IRA] (@USERNAME VARCHAR(30) , @PROG_ID VARCHAR(30) )
AS
BEGIN
DECLARE @COUNT_IRA INT
DECLARE @IRA INT
DECLARE @COUNT INT
DECLARE @VARIANCE INT
DECLARE @CC INT
DECLARE @SS INT
DECLARE @WW INT
SELECT @COUNT = 3
SELECT @VARIANCE = 2
/*(convert(decimal(16,1),
((SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
))
FROM SCH_CYCLECOUNT*/
IF @COUNT > @VARIANCE
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 - (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount)) end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
PRINT '1'
END
ELSE IF @VARIANCE > @COUNT
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 + (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount))end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
PRINT '2'
END
ELSE IF @VARIANCE = 0 OR @VARIANCE = @COUNT
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 * (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount))end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
PRINT '3'
END
SET @CC = ( select distinct IRA = (100 - (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Cycle Count') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Cycle Count') * 1.0) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand') * 1.0)end)*100
when 0 then 100 end))
from sch_cyclecount )
SET @SS = ( select distinct IRA = (100- (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') ) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') * 1.0)end ) * 100
when 0 then 100 end))
from sch_cyclecount )
SET @WW = ( select distinct IRA = (100- (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') ) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') * 1.0)end ) * 100
when 0 then 100 end))
from sch_cyclecount )
UPDATE SCH_CYCLECOUNT_IRA SET PROG_ID = @PROG_ID, IRA = @IRA, CC_AC = @CC, CC_WW = @WW, CC_SS = @SS WHERE PROG_ID = @PROG_ID
END
Я использую sqlsrv как dbdriver, определенный в моем config.php.
Я уже решил это, удалив все печать, спасибо.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_COUNT_IRA] (@USERNAME VARCHAR(30) , @PROG_ID VARCHAR(30) )
AS
BEGIN
DECLARE @COUNT_IRA INT
DECLARE @IRA INT
DECLARE @COUNT INT
DECLARE @VARIANCE INT
DECLARE @CC INT
DECLARE @SS INT
DECLARE @WW INT
SELECT @COUNT = 3
SELECT @VARIANCE = 2
/*(convert(decimal(16,1),
((SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
))
FROM SCH_CYCLECOUNT*/
IF @COUNT > @VARIANCE
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 - (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount)) end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
END
ELSE IF @VARIANCE > @COUNT
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 + (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount))end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
END
ELSE IF @VARIANCE = 0 OR @VARIANCE = @COUNT
BEGIN
SET @IRA = (select distinct IRA = (convert(decimal(16,1), case (select distinct count(sku) from sch_variance_report a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger' ) when 0 then 0.0 else
1 * (convert(decimal(16,1),(SELECT DISTINCT count(sku) from sch_cyclecount) - (SELECT DISTINCT count(sku) from SCH_VARIANCE_REPORT))
/(select distinct count(sku) from sch_cyclecount))end) * 100)
from sch_variance_report a inner join sch_cyclecount b on a.sku = b.sku and
a.ref_no = b.ref_no and a.prog_id = b.prog_id inner join sch_web_users_detail c on a.prog_id = c.prog_id where c.user_id = 'roger' )
END
SET @CC = ( select distinct IRA = (100 - (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Cycle Count') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Cycle Count') * 1.0) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand') * 1.0)end)*100
when 0 then 100 end))
from sch_cyclecount )
SET @SS = ( select distinct IRA = (100- (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') ) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id
where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') * 1.0)end ) * 100
when 0 then 100 end))
from sch_cyclecount )
SET @WW = ( select distinct IRA = (100- (
CASE
(case (select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') when 0 then 0.0 else
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') -
(select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'System to System') ) /
((select distinct count(sku)from sch_cyclecount a inner join sch_web_users_detail b on a.prog_id = b.prog_id where b.user_id = 'roger'and count_type = 'Stock on Hand(S2S)') * 1.0)end ) * 100
when 0 then 100 end))
from sch_cyclecount )
UPDATE SCH_CYCLECOUNT_IRA SET PROG_ID = @PROG_ID, IRA = @IRA, CC_AC = @CC, CC_WW = @WW, CC_SS = @SS WHERE PROG_ID = @PROG_ID
END
Других решений пока нет …