Showing posts with label bug. Show all posts
Showing posts with label bug. Show all posts

Friday, March 30, 2012

Part of SP not executing... Maybe BUG!?

Hello!

I have a strange problem in one SP. One small part of it wan't execute.

I have pasted whole procedure here and a solution to problem.

So, black on red part of code will not execute if black on blue code is in place.

But, if I supstitute black on blue with black on green, black on red part will execute!

Only thing I want to know is why is that hapening...

Regards

--SNIP--

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_FINKO_Knjizenje_Robnih]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_FINKO_Knjizenje_Robnih]
GO


CREATE procedure sp_FINKO_Knjizenje_Robnih
(
@.VrDok varchar(8) = '', --Vrsta robnog dokumenta
@.IDs varchar(2200) = '' --IDovi iz HeRPuSPrijenos_Knjizenja
)
AS
BEGIN

set @.VrDok = rtrim(ltrim(@.VrDok))
set @.Ids = rtrim(ltrim(@.Ids))

if @.VrDok='' OR len(@.IDs) = 0
BEGIN
RAISERROR ('Potrebna vrsta dokumenta i IDovi', 16, 1)
return
END
declare @.vbCrLf char(2)
declare @.SQL_temp nvarchar(4000)


set @.vbcrlf = CHAR(13) + CHAR(10)

CREATE TABLE #tmpDokumenti (
[ID] [numeric] (18,0), [Dok_broj] [varchar] (32) COLLATE Croatian_CI_AS NULL, [AK_Skladiste] [varchar] (10) COLLATE Croatian_CI_AS NULL, [Dok_Vrsta] [varchar] (8)COLLATE Croatian_CI_AS NULL
)

set nocount ON
--Racunamo da imamo vrstu dokumenta te ajdiove te cemo sada brojeve dokumenata i skladista prebaciti u temp tablicu
set @.SQL_temp= 'SELECT ID,Dok_Broj,AK_Skladiste,Dok_AK FROM HeRPuSPrijenos_Knjizenja' + @.vbcrlf
set @.SQL_temp= @.SQL_Temp + 'WHERE (isnull(Temeljnica_Nastala,0)=0 AND Dok_OA = ''50'' AND Dok_AK=''' + @.VrDok + ''')' + @.vbcrlf
set @.SQL_temp= @.SQL_Temp + 'AND ID IN (' + @.IDs + ') '

set @.SQL_temp= 'SET NOCOUNT ON ' + @.vbcrlf + @.SQL_temp

INSERT INTO #tmpDokumenti
exec (@.SQL_temp) --prebacujemo

SELECT v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,sum(v.Duguje) as Duguje
,sum(v.Potra?uje) as Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo, IDENTITY(int, 1,1) as rbr
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,v.RVrDok as r_Vrsta_dokumenta
INTO #tmpTemeljnica
FROM vFK_RK as V INNER JOIN #tmpDokumenti as D
ON v.broj_dokumenta=d.dok_Broj AND V.AK_skladiste=D.AK_skladiste AND V.vrsta_dokumenta=@.VrDok
GROUP BY v.Oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,v.RVrDok--, v.RK_ID
,case --grupiranje po predznaku...
WHEN v.duguje < 0 THEN 'M'
WHEN v.potra?uje < 0 THEN 'M'
ELSE 'P'
end
IF @.@.ERROR <>0
BEGIN
PRINT 'Greska: sp_FINKO_Knjienje_Robnih'
END

declare @.Greska as bit
declare @.ID_Knjiz as bigint
declare @.VrDok1 as varchar(8)
declare @.BrDok1 as varchar(8)
declare @.Skl as varchar(8)
declare @.Anal1 as varchar(8)
declare @.Anal2 as varchar(8)
declare @.Konto as varchar(8)
declare @.Duguje as numeric(18,2)
declare @.Potrazuje as numeric(18,2)
declare @.SQL_Update as varchar(4000)

SET @.Greska = 0 --ovdje pratimo jeli bilo kakvih gresaka a temeljnici


DECLARE rsTmp CURSOR LOCAL FAST_FORWARD READ_ONLY
FOR
SELECT d.ID,d.ak_skladiste,t.r_Vrsta_dokumenta,t.Broj_dokumenta,t.analiticki_konto,t.podanaliticki_konto,t.Konto,t.Duguje,t.Potra?uje
FROM #tmpTemeljnica as t INNER JOIN #tmpDokumenti as d
ON t.r_vrsta_dokumenta=d.Dok_Vrsta and t.broj_dokumenta=d.Dok_broj
WHERE
(len(t.oznaka_analitike) = 2 and t.analiticki_konto is null)
OR
(len(t.Podoznaka_analitike) = 2 and t.Podanaliticki_konto is null)
OR
(t.Konto is null)
OR
(t.duguje=0 and t.potra?uje=0)
ORDER by d.ID


OPEN rsTmp FETCH NEXT FROM rsTMP into @.ID_Knjiz ,@.Skl,@.VrDok1,@.BrDok1,@.anal1,@.Anal2,@.Konto,@.Duguje,@.Potrazuje
WHILE (@.@.fetch_status=0)
BEGIN
IF @.Anal1 IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,201,'Ne mogu pronaci analitiku za konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Anal2 IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,202,'Ne mogu pronaci podanalitiku za konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Konto IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,203,'Ne mogu pronaci konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Duguje=0 AND @.Potrazuje=0
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,204,'Stavka za duguje i potrazuje ima 0','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
FETCH NEXT FROM rsTMP into @.ID_Knjiz ,@.Skl,@.VrDok1,@.BrDok1,@.anal1,@.Anal2
END
CLOSE rsTmp
deallocate rsTmp

if @.Greska= 0
BEGIN
declare @.PojedinacniPrijenos bit
declare @.Tem_vrsta varchar(8) --vrsta tekuce temeljnice
declare @.Tem_broj bigint --sljedeci broj iz fin kartica
declare @.Tem_Datum smalldatetime --danasnji datum
declare @.Tem_ID uniqueidentifier --eto
declare @.Knjiz_Mjesec numeric(18,0)
declare @.Knjiz_Godina numeric(18,0)
declare @.Knjiz_Dnevnik numeric(18,0)

SET @.PojedinacniPrijenos=(
select isnull(osiguranje,0) FROM analiticka_konta where oznaka_analitike='50' and analiticki_konto=@.VrDok
)
SET @.Tem_vrsta =(
select top 1 vrsta_temeljnice from #tmpTemeljnica
)
SET @.Tem_broj =(
SELECT isnull(max(dbo.ToNumeric(FK.Broj_temeljnice)),0) +1 --bilo sranje jer je broj_temeljnice varchar pa je sad ToNumeric
FROM Financijske_kartice as FK WHERE FK.Vrsta_temeljnice=@.Tem_Vrsta
)
SET @.Tem_Datum=CONVERT(CHAR(8),getdate(),112) --treba nam samo datum
SET @.Tem_ID=newid()
SET @.Knjiz_Mjesec=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Mjesec knji?enja'
)
SET @.Knjiz_Godina=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Godina knji?enja'
)
SET @.Knjiz_Dnevnik=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Broj dnevnika'
)

UPDATE #tmpTemeljnica SET
Broj_temeljnice =@.Tem_broj
,Tem_ID =@.Tem_ID
,Datum_temeljnice =@.Tem_datum
,Mjesec =@.Knjiz_Mjesec
,Godina =@.Knjiz_Godina
,Broj_dnevnika =@.Knjiz_Dnevnik

--idemo si napravit kopiju temp tablice(treba nam zbog grupnoh odnosno pojedinacnog prijenosa)
SELECT * INTO #tmpTemeljnica1
FROM #tmpTemeljnica WHERE 1=2

--idemo sad grupirat sve sto treba
SET @.PojedinacniPrijenos =1 --zasad ostajemo na ovom

IF @.PojedinacniPrijenos = 1
BEGIN

INSERT INTO #tmpTemeljnica1
SELECT v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,sum(v.Duguje) as Duguje
,sum(v.Potra?uje) as Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,''
FROM #tmpTemeljnica as v
GROUP by
v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,
CASE --grupiranje po predznaku...
WHEN v.duguje < 0 THEN 'M'
WHEN v.potra?uje < 0 THEN 'M'
ELSE 'P'
END

END
ELSE
BEGIN
print ''
END


INSERT INTO HeRPuSPrijenos_Temeljnica
SELECT
v.oznaka_analitike,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta,v.broj_dokumenta,v.Datum_dokumenta
,v.Duguje,v.Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj,v.Duguje2,v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta,v.rbr
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID--,v.RVrDok --, v.RK_ID
FROM #tmpTemeljnica1 as V

IF @.@.ERROR <> 0
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(0,'Robni prijenos',0,0,205,'Greska prilikom prebacivanja podataka u HeRPuSPrijenos_Temeljnica','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END

END


-- DROP TABLE #tmpDokumenti --necemo dropat jel ce server dropat nakon zavrsetka procedure
-- DROP TABLE #tmpTemeljnica
-- DROP TABLE #tmpTemeljnica1

IF @.Greska=0
BEGIN
set @.SQL_Update='update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=1, Temeljnica_Greska=0 Where ID IN (' + @.vbcrlf
set @.SQL_Update=@.SQL_Update + @.IDs + ') AND Dok_AK=''' + @.VrDok + '''' + @.vbcrlf
EXEC (@.SQL_Update)

UPDATE robne_kartice SET Knjizenje_financijsko=1 WHERE ID IN --updejta robne kartice na knjizeno
(
SELECT v.RK_ID
FROM vfk_rk as v INNER JOIN #tmpDokumenti as D
ON v.broj_dokumenta=d.dok_Broj AND V.AK_skladiste=D.AK_skladiste AND
V.vrsta_dokumenta=@.VrDok
)

END
ELSE
BEGIN
set @.SQL_Update='update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=0, Temeljnica_Greska=1 Where ID IN (' + @.vbcrlf
set @.SQL_Update=@.SQL_Update + @.IDs + ') AND Dok_AK=''' + @.VrDok + '''' + @.vbcrlf

EXEC (@.SQL_Update)
END
END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

--SNIP--

update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=1, Temeljnica_Greska=0 Where
ID IN (select ID from #tmpDokumenti)

It would be great if you reported this at http://lab.msdn.microsoft.com/productfeedback. If you do, you are more likely to get the attention of the right people, and you might find out if this is a known bug, and if so, what the status is.

Thanks.

Part of SP not executing... Maybe BUG!?

Hello!

I have a strange problem in one SP. One small part of it wan't execute.

I have pasted whole procedure here and a solution to problem.

So, black on red part of code will not execute if black on blue code is in place.

But, if I supstitute black on blue with black on green, black on red part will execute!

Only thing I want to know is why is that hapening...

Regards

--SNIP--

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_FINKO_Knjizenje_Robnih]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_FINKO_Knjizenje_Robnih]
GO


CREATE procedure sp_FINKO_Knjizenje_Robnih
(
@.VrDok varchar(8) = '', --Vrsta robnog dokumenta
@.IDs varchar(2200) = '' --IDovi iz HeRPuSPrijenos_Knjizenja
)
AS
BEGIN

set @.VrDok = rtrim(ltrim(@.VrDok))
set @.Ids = rtrim(ltrim(@.Ids))

if @.VrDok='' OR len(@.IDs) = 0
BEGIN
RAISERROR ('Potrebna vrsta dokumenta i IDovi', 16, 1)
return
END
declare @.vbCrLf char(2)
declare @.SQL_temp nvarchar(4000)


set @.vbcrlf = CHAR(13) + CHAR(10)

CREATE TABLE #tmpDokumenti (
[ID] [numeric] (18,0), [Dok_broj] [varchar] (32) COLLATE Croatian_CI_AS NULL, [AK_Skladiste] [varchar] (10) COLLATE Croatian_CI_AS NULL, [Dok_Vrsta] [varchar] (8)COLLATE Croatian_CI_AS NULL
)

set nocount ON
--Racunamo da imamo vrstu dokumenta te ajdiove te cemo sada brojeve dokumenata i skladista prebaciti u temp tablicu
set @.SQL_temp= 'SELECT ID,Dok_Broj,AK_Skladiste,Dok_AK FROM HeRPuSPrijenos_Knjizenja' + @.vbcrlf
set @.SQL_temp= @.SQL_Temp + 'WHERE (isnull(Temeljnica_Nastala,0)=0 AND Dok_OA = ''50'' AND Dok_AK=''' + @.VrDok + ''')' + @.vbcrlf
set @.SQL_temp= @.SQL_Temp + 'AND ID IN (' + @.IDs + ') '

set @.SQL_temp= 'SET NOCOUNT ON ' + @.vbcrlf + @.SQL_temp

INSERT INTO #tmpDokumenti
exec (@.SQL_temp) --prebacujemo

SELECT v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,sum(v.Duguje) as Duguje
,sum(v.Potra?uje) as Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo, IDENTITY(int, 1,1) as rbr
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,v.RVrDok as r_Vrsta_dokumenta
INTO #tmpTemeljnica
FROM vFK_RK as V INNER JOIN #tmpDokumenti as D
ON v.broj_dokumenta=d.dok_Broj AND V.AK_skladiste=D.AK_skladiste AND V.vrsta_dokumenta=@.VrDok
GROUP BY v.Oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,v.RVrDok--, v.RK_ID
,case --grupiranje po predznaku...
WHEN v.duguje < 0 THEN 'M'
WHEN v.potra?uje < 0 THEN 'M'
ELSE 'P'
end
IF @.@.ERROR <>0
BEGIN
PRINT 'Greska: sp_FINKO_Knjienje_Robnih'
END

declare @.Greska as bit
declare @.ID_Knjiz as bigint
declare @.VrDok1 as varchar(8)
declare @.BrDok1 as varchar(8)
declare @.Skl as varchar(8)
declare @.Anal1 as varchar(8)
declare @.Anal2 as varchar(8)
declare @.Konto as varchar(8)
declare @.Duguje as numeric(18,2)
declare @.Potrazuje as numeric(18,2)
declare @.SQL_Update as varchar(4000)

SET @.Greska = 0 --ovdje pratimo jeli bilo kakvih gresaka a temeljnici


DECLARE rsTmp CURSOR LOCAL FAST_FORWARD READ_ONLY
FOR
SELECT d.ID,d.ak_skladiste,t.r_Vrsta_dokumenta,t.Broj_dokumenta,t.analiticki_konto,t.podanaliticki_konto,t.Konto,t.Duguje,t.Potra?uje
FROM #tmpTemeljnica as t INNER JOIN #tmpDokumenti as d
ON t.r_vrsta_dokumenta=d.Dok_Vrsta and t.broj_dokumenta=d.Dok_broj
WHERE
(len(t.oznaka_analitike) = 2 and t.analiticki_konto is null)
OR
(len(t.Podoznaka_analitike) = 2 and t.Podanaliticki_konto is null)
OR
(t.Konto is null)
OR
(t.duguje=0 and t.potra?uje=0)
ORDER by d.ID


OPEN rsTmp FETCH NEXT FROM rsTMP into @.ID_Knjiz ,@.Skl,@.VrDok1,@.BrDok1,@.anal1,@.Anal2,@.Konto,@.Duguje,@.Potrazuje
WHILE (@.@.fetch_status=0)
BEGIN
IF @.Anal1 IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,201,'Ne mogu pronaci analitiku za konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Anal2 IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,202,'Ne mogu pronaci podanalitiku za konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Konto IS NULL
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,203,'Ne mogu pronaci konto','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
ELSE IF @.Duguje=0 AND @.Potrazuje=0
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(@.ID_knjiz,'Robni prijenos',0,0,204,'Stavka za duguje i potrazuje ima 0','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END
FETCH NEXT FROM rsTMP into @.ID_Knjiz ,@.Skl,@.VrDok1,@.BrDok1,@.anal1,@.Anal2
END
CLOSE rsTmp
deallocate rsTmp

if @.Greska= 0
BEGIN
declare @.PojedinacniPrijenos bit
declare @.Tem_vrsta varchar(8) --vrsta tekuce temeljnice
declare @.Tem_broj bigint --sljedeci broj iz fin kartica
declare @.Tem_Datum smalldatetime --danasnji datum
declare @.Tem_ID uniqueidentifier --eto
declare @.Knjiz_Mjesec numeric(18,0)
declare @.Knjiz_Godina numeric(18,0)
declare @.Knjiz_Dnevnik numeric(18,0)

SET @.PojedinacniPrijenos=(
select isnull(osiguranje,0) FROM analiticka_konta where oznaka_analitike='50' and analiticki_konto=@.VrDok
)
SET @.Tem_vrsta =(
select top 1 vrsta_temeljnice from #tmpTemeljnica
)
SET @.Tem_broj =(
SELECT isnull(max(dbo.ToNumeric(FK.Broj_temeljnice)),0) +1 --bilo sranje jer je broj_temeljnice varchar pa je sad ToNumeric
FROM Financijske_kartice as FK WHERE FK.Vrsta_temeljnice=@.Tem_Vrsta
)
SET @.Tem_Datum=CONVERT(CHAR(8),getdate(),112) --treba nam samo datum
SET @.Tem_ID=newid()
SET @.Knjiz_Mjesec=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Mjesec knji?enja'
)
SET @.Knjiz_Godina=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Godina knji?enja'
)
SET @.Knjiz_Dnevnik=(
select isnull(podatak,0) from fink where segment='KNJIZIFIN' and naziv= 'Broj dnevnika'
)

UPDATE #tmpTemeljnica SET
Broj_temeljnice =@.Tem_broj
,Tem_ID =@.Tem_ID
,Datum_temeljnice =@.Tem_datum
,Mjesec =@.Knjiz_Mjesec
,Godina =@.Knjiz_Godina
,Broj_dnevnika =@.Knjiz_Dnevnik

--idemo si napravit kopiju temp tablice(treba nam zbog grupnoh odnosno pojedinacnog prijenosa)
SELECT * INTO #tmpTemeljnica1
FROM #tmpTemeljnica WHERE 1=2

--idemo sad grupirat sve sto treba
SET @.PojedinacniPrijenos =1 --zasad ostajemo na ovom

IF @.PojedinacniPrijenos = 1
BEGIN

INSERT INTO #tmpTemeljnica1
SELECT v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,sum(v.Duguje) as Duguje
,sum(v.Potra?uje) as Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,''
FROM #tmpTemeljnica as v
GROUP by
v.oznaka_analitike
,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta
,v.broj_dokumenta
,v.Datum_dokumenta
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj, v.Duguje2, v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta, v.IdNo
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID,
CASE --grupiranje po predznaku...
WHEN v.duguje < 0 THEN 'M'
WHEN v.potra?uje < 0 THEN 'M'
ELSE 'P'
END

END
ELSE
BEGIN
print ''
END


INSERT INTO HeRPuSPrijenos_Temeljnica
SELECT
v.oznaka_analitike,v.Analiticki_konto
,v.Konto
,v.vrsta_dokumenta,v.broj_dokumenta,v.Datum_dokumenta
,v.Duguje,v.Potra?uje
,v.Opis
,v.Vrsta_Temeljnice, v.Broj_Temeljnice, v.Datum_temeljnice
,v.Tecaj,v.Duguje2,v.Potra?uje2
,v.Protukonto, v.Protuanalitika, v.ProtuAnliticki_konto
,v.Zatvoreno, v.Mjesec, v.Godina, v.Broj_dnevnika, v.Saldo
,v.Zatvoren_dnevnik, v.Valuta,v.rbr
,v.PodOznaka_analitike, v.Podanaliticki_konto
,v.Broj_izvornog_dokumenta, v.Vrsta_dokumentaIzvorni
,v.Broj_dokumentaIzvorni, v.Datum_dokumentaIzvorni
,v.DugujeDEV, v.PotrazujeDEV, v.NovcanaJedinica
,v.ZatvaraDokument
,v.Prijenos_ID, v.Prijenos_DokID
,v.Duguje2DEV, v.Potrazuje2DEV, v.ZatvorenoDEV
,v.Racunalo, v.Korisnik, v.DatumAzuriranja
,v.Prijenos_Dok_Dogadjaj, v.Prijenos_dok_zatvara
,v.Red_ID, v.Tem_ID--,v.RVrDok --, v.RK_ID
FROM #tmpTemeljnica1 as V

IF @.@.ERROR <> 0
BEGIN
BEGIN TRANSACTION T1
INSERT INTO HeRPuSPrijenos_Greske
(Knjizenje_ID,Modul,Stavka_ID,Stavka_Rbr,Broj_Greske,Opis_Greske1,Opis_Greske2,Opis_Greske3,VrijemeUpisa,Korisnik,Racunalo)
VALUES
(0,'Robni prijenos',0,0,205,'Greska prilikom prebacivanja podataka u HeRPuSPrijenos_Temeljnica','','',getdate(),'server','server')
COMMIT TRANSACTION T1
SET @.Greska=1
END

END


-- DROP TABLE #tmpDokumenti --necemo dropat jel ce server dropat nakon zavrsetka procedure
-- DROP TABLE #tmpTemeljnica
-- DROP TABLE #tmpTemeljnica1

IF @.Greska=0
BEGIN
set @.SQL_Update='update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=1, Temeljnica_Greska=0 Where ID IN (' + @.vbcrlf
set @.SQL_Update=@.SQL_Update + @.IDs + ') AND Dok_AK=''' + @.VrDok + '''' + @.vbcrlf
EXEC (@.SQL_Update)

UPDATE robne_kartice SET Knjizenje_financijsko=1 WHERE ID IN --updejta robne kartice na knjizeno
(
SELECT v.RK_ID
FROM vfk_rk as v INNER JOIN #tmpDokumenti as D
ON v.broj_dokumenta=d.dok_Broj AND V.AK_skladiste=D.AK_skladiste AND
V.vrsta_dokumenta=@.VrDok
)

END
ELSE
BEGIN
set @.SQL_Update='update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=0, Temeljnica_Greska=1 Where ID IN (' + @.vbcrlf
set @.SQL_Update=@.SQL_Update + @.IDs + ') AND Dok_AK=''' + @.VrDok + '''' + @.vbcrlf

EXEC (@.SQL_Update)
END
END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

--SNIP--

update HeRPuSPrijenos_Knjizenja set Temeljnica_Nastala=1, Temeljnica_Greska=0 Where
ID IN (select ID from #tmpDokumenti)

It would be great if you reported this at http://lab.msdn.microsoft.com/productfeedback. If you do, you are more likely to get the attention of the right people, and you might find out if this is a known bug, and if so, what the status is.

Thanks.

Tuesday, March 20, 2012

parameters.refresh bug

It seems MS have not fixed the parameters.refresh bug yet.If I use this
code, it would throw out an exception of 'AV in module SQLOLEDB.dll'. By the
way, my SQL is 2000 + SP4 under Win2000 +SP4.
Jack ZhongJack Zhong (invalid@.email.com) writes:
> It seems MS have not fixed the parameters.refresh bug yet.If I use this
> code, it would throw out an exception of 'AV in module SQLOLEDB.dll'. By
> the way, my SQL is 2000 + SP4 under Win2000 +SP4.
Which code?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||>
> Which code?
>
(in Delphi 7)
sp.Parameters.Refresh;
.....
sp.ExecProc;
sp is a stored procedure component wrapped in datamodule. There would be an
AV exception if fire sp.Parameters.Refresh; If this line is disabled, it
works perfectly well. I knew there was a Parameters.Refresh bug in previous
SQLOLEDB.dll before, but my SQL might be the latest, it is SP4 patched.
The following is snippet of my codes in Delphi 7.
function TBiz.TransData(FGuest: TGuest; FIndex: Byte): Boolean;
begin
begin
with dm.prTransGuest do
begin
try
Parameters.Refresh;
Parameters.ParamByName('@.ref').Value := Ref ;
..
Parameters.ParamByName('@.position').Value := FIndex;
Prepared:=True ;
ExecProc;
Result := True;
except
Result := False;
end;
end;
end;
end;
Jack Zhong|||Jack Zhong (invalid@.email.com) writes:
> (in Delphi 7)
> sp.Parameters.Refresh;
> .....
> sp.ExecProc;
> sp is a stored procedure component wrapped in datamodule. There would be
> an AV exception if fire sp.Parameters.Refresh; If this line is
> disabled, it works perfectly well. I knew there was a Parameters.Refresh
> bug in previous SQLOLEDB.dll before, but my SQL might be the latest, it
> is SP4 patched.
I don't know Delphi or have any access to it, so I cannot repro. But I
know we use the .Refresh method in our code (ADO + VB6), and I have not
heard about any access violation.
Besides, the .Refresh method is not in SQLOLEDB proper, but is part of
ADO. True, though, that ADO uses SQLOLEDB (or whichever provider you
use).
Is Delphi 7 a recent version of Delphi?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Merry Christmas, Erland.
I am a betrayer to VB, ^_*. Yes, there are a great many AVs in Delphi than
in VB, VB is much friendly to programmers sometimes.
Actually, the AV is somewhat strange. There are two function routines of
similar structure in the same loop to insert data into different tables, the
other function would be OK even though there is also a Parameters.Refresh.
The only diffrence is the underlying tables are slightly different. One has
primary key and the other one contains no primary keys. Inserting data into
the latter table, *without primary key*, might throw out AV if execute
Parameters.Refresh before insertion. I am not sure whether this might be the
point in which the problem lies. However, if I put a TADOStoredProcedure
component on the form and set the values in the properties inspector, then
no matter how many times I fire it, there is no AV at all.
By the way, for there are some differences between Pascal data types and SQL
server, I modified some parameters data types, for instance from
ftWideString to ftString, I got an AV in module mo15.dll if I enable
Parameters.Refresh.
Delphi 7 is an Adult in the Delphi family, Delphi 2006 is the latest one. D7
might be the latest one for Win32 enviroment.
Following is the snippet of my codes, I have added some comments to it. BTW,
the TBiz is a class to implement business rules.
procedure TBiz.ButtonApplyClick(FMbr: tstrings; FContact: TContact);
//class routine respond to ButtonApply click event in host application
var
i : Integer;
begin
if Assigned(FMbr) then
begin
for i := 0 to FMbr.Count - 1 do //repeatedly insert data into tables
with two stored procedure
begin
if TGuest(FMbr.Objects[i]).Rounds <> 0 then
begin
if ( AddNew( TGuest(FMbr.Objects[i]) ) <> 0) then
TransData(TGuest(FMbr.Objects[i]), i + 1);
end; //end if
end; //end for
case Operation of
0: New; //Operation create new.
1: Append; //Operation append
end;
end;
end;
function TBiz.TransData(FGuest: TGuest; FIndex: Byte): Boolean;
begin
begin
with dm.prTransGuest do //prTransGuest is a stored procedure in dm
(TDataMudle);
begin
try
Parameters.Refresh;
Parameters.ParamByName('@.ref').Value := Ref ;
..
Parameters.ParamByName('@.position').Value := FIndex;
Prepared;
ExecProc; //throw out AV exception on the second try, if
Parameters.Refresh enabled
Result := True;
except
Result := False;
end;
end;
end;
end;
function TBiz.AddNew(FGuest: TGuest): LongWord;
begin
with dm.prAddNew do
begin
with Parameters do
begin
try
try
Parameters.Refresh;
ParamByName('@.FirstName').Value := FGuest.FirstName;
..
Prepared;
ExecProc; //No AV even enable the above Parameters.Refresh
Result := ParamByName('@.Return_Value').Value;
except
result := 0;
end;
finally
end;
end;
end;
end;|||Jack Zhong (invalid@.email.com) writes:
> Actually, the AV is somewhat strange. There are two function routines
> of similar structure in the same loop to insert data into different
> tables, the other function would be OK even though there is also a
> Parameters.Refresh. The only diffrence is the underlying tables are
> slightly different. One has primary key and the other one contains no
> primary keys. Inserting data into the latter table, *without primary
> key*, might throw out AV if execute Parameters.Refresh before
> insertion. I am not sure whether this might be the point in which the
> problem lies. However, if I put a TADOStoredProcedure component on the
> form and set the values in the properties inspector, then no matter how
> many times I fire it, there is no AV at all.
There is one thing that I find strange in your code. You are refreshing
the parameters for each time in the loop, but you never set up any
command object. Or this is implicit in some way.
Anyway, calling .Refresh for every call to the procedure is hardly good
for performance, since that is a roundtrip to the server. Ideally, you
could call .Refresh once, and the reuse the parameter collection. Un-
fortunately, when I have tried to reuse command objects in ADO, it has
started doing things I don't like at all.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||"Erland Sommarskog" <esquel@.sommarskog.se> '
news:Xns9735F04F06514Yazorman@.127.0.0.1...
> There is one thing that I find strange in your code. You are refreshing
> the parameters for each time in the loop, but you never set up any
> command object. Or this is implicit in some way.
>
This might be the difference between Delphi and VB, I am afraid. Delphi
could add parameter list in the property inspector, so it is not needed to
add parameters.refresh in the routines again. But If there were some
parameters added to the procedure and the programmer forgot to add them to
the inspector box, Delphi would throw out 'parameter not found' error.

> Anyway, calling .Refresh for every call to the procedure is hardly good
> for performance, since that is a roundtrip to the server. Ideally, you
> could call .Refresh once, and the reuse the parameter collection. Un-
> fortunately, when I have tried to reuse command objects in ADO, it has
> started doing things I don't like at all.
>
I would move Refresh command to the form.create routine, this might avoid
refreshing SP for many times.
Thanks.

> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx

Friday, March 9, 2012

Parameters in subqueries ?

Can anyone tell me if this is a known bug? When using a parameter in a
subquery I get an access violation
The query below reproduces the problem using Northwind.
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
It also happens when using OLEDB
SELECT * FROM Orders
WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
?)
Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.0 (Build 2195: Service Pack 4)
What is question mark supposed to represent? Is this in a stored procedure?
Did you mean to use a named @.parameter?
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"news.microsoft.com" <deo.is@.unknown.com> wrote in message
news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on
Windows
> NT 5.0 (Build 2195: Service Pack 4)
>
|||The question mark represents and unnamed parameter.
I never use the @.param syntax for queries since Enterprise manager does
support them.
It is not in a stored procedure. It's being submitted from C# code but it
blows up just the same from Enterprise SQL Mangler
Seems to work ok with named parameters from Query Analyser.
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:uJgffxqPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> What is question mark supposed to represent? Is this in a stored
procedure?[vbcol=seagreen]
> Did you mean to use a named @.parameter?
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
> "news.microsoft.com" <deo.is@.unknown.com> wrote in message
> news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
=
> Windows
>
|||> I never use the @.param syntax for queries since Enterprise manager does
> support them.
Why are you using Enterprise Manager for this?

> It is not in a stored procedure. It's being submitted from C# code but it
> blows up just the same from Enterprise SQL Mangler
If you're sending the code like that, why not fill in the parameter value in
C#?

> Seems to work ok with named parameters from Query Analyser.
As it should. Not all providers are going to understand the same funky
syntax that EM requires.
|||I use the ? style parameter since the query wizards in Visual Studio don't
support the @.param style. The VS.NET wizards must use the same codebase as
EM since they mangle queries in much the same fashion
Thanks for the help
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...[vbcol=seagreen]
> Why are you using Enterprise Manager for this?
it
> If you're sending the code like that, why not fill in the parameter value
in
> C#?
>
> As it should. Not all providers are going to understand the same funky
> syntax that EM requires.
>
|||"news.microsoft.com" wrote:

> I use the ? style parameter since the query wizards in Visual Studio don't
> support the @.param style. The VS.NET wizards must use the same codebase as
> EM since they mangle queries in much the same fashion
> Thanks for the help
> "Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
> news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> it
> in
>
>
|||I'm getting that error "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation", and I'm just trying to create some tables from a script in Query Analyzer. I'm trying to create the tables in the pubs database. What's the deal
Microsoft SQL Server 7.00 - 7.00.961 (Intel X86)
Oct 24 2000 18:39:12
Copyright (c) 1988-1998 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)
"news.microsoft.com" wrote:

> I use the ? style parameter since the query wizards in Visual Studio don't
> support the @.param style. The VS.NET wizards must use the same codebase as
> EM since they mangle queries in much the same fashion
> Thanks for the help
> "Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
> news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> it
> in
>
>
|||I'm getting that message "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" and all I'm doing is trying to create some tables from a script in Query Analyzer. Can someone help me with this?
Microsoft SQL Server 7.00 - 7.00.961 (Intel X86)
Oct 24 2000 18:39:12
Copyright (c) 1988-1998 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)
"news.microsoft.com" wrote:

> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
> NT 5.0 (Build 2195: Service Pack 4)
>
>
|||I'm going to try this again. I'm having the same problem. I'm getting that message "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" and all I'm doing is trying to create some tables in the pubs database from a script. I'm using Que
ry Analyzer. Can someone help me with this.
"news.microsoft.com" wrote:

> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
> NT 5.0 (Build 2195: Service Pack 4)
>
>

Parameters in subqueries ?

Can anyone tell me if this is a known bug? When using a parameter in a
subquery I get an access violation
The query below reproduces the problem using Northwind.
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
It also happens when using OLEDB
SELECT * FROM Orders
WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
?)
Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.0 (Build 2195: Service Pack 4)What is question mark supposed to represent? Is this in a stored procedure?
Did you mean to use a named @.parameter?
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"news.microsoft.com" <deo.is@.unknown.com> wrote in message
news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violatio
n
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on
Windows
> NT 5.0 (Build 2195: Service Pack 4)
>|||The question mark represents and unnamed parameter.
I never use the @.param syntax for queries since Enterprise manager does
support them.
It is not in a stored procedure. It's being submitted from C# code but it
blows up just the same from Enterprise SQL Mangler
Seems to work ok with named parameters from Query Analyser.
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:uJgffxqPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> What is question mark supposed to represent? Is this in a stored
procedure?
> Did you mean to use a named @.parameter?
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
> "news.microsoft.com" <deo.is@.unknown.com> wrote in message
> news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
=[vbcol=seagreen]
> Windows
>|||> I never use the @.param syntax for queries since Enterprise manager does
> support them.
Why are you using Enterprise Manager for this?

> It is not in a stored procedure. It's being submitted from C# code but it
> blows up just the same from Enterprise SQL Mangler
If you're sending the code like that, why not fill in the parameter value in
C#?

> Seems to work ok with named parameters from Query Analyser.
As it should. Not all providers are going to understand the same funky
syntax that EM requires.|||I use the ? style parameter since the query wizards in Visual Studio don't
support the @.param style. The VS.NET wizards must use the same codebase as
EM since they mangle queries in much the same fashion
Thanks for the help
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> Why are you using Enterprise Manager for this?
>
it[vbcol=seagreen]
> If you're sending the code like that, why not fill in the parameter value
in
> C#?
>
> As it should. Not all providers are going to understand the same funky
> syntax that EM requires.
>|||"news.microsoft.com" wrote:

> I use the ? style parameter since the query wizards in Visual Studio don't
> support the @.param style. The VS.NET wizards must use the same codebase a
s
> EM since they mangle queries in much the same fashion
> Thanks for the help
> "Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
> news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> it
> in
>
>|||I'm getting that error "[Microsoft][ODBC SQL Server Driver]Syntax er
ror or access violation", and I'm just trying to create some tables from a s
cript in Query Analyzer. I'm trying to create the tables in the pubs databa
se. What's the deal
Microsoft SQL Server 7.00 - 7.00.961 (Intel X86)
Oct 24 2000 18:39:12
Copyright (c) 1988-1998 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)
"news.microsoft.com" wrote:

> I use the ? style parameter since the query wizards in Visual Studio don't
> support the @.param style. The VS.NET wizards must use the same codebase a
s
> EM since they mangle queries in much the same fashion
> Thanks for the help
> "Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
> news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> it
> in
>
>|||I'm getting that message "[Microsoft][ODBC SQL Server Driver]Syntax
error or access violation" and all I'm doing is trying to create some tables
from a script in Query Analyzer. Can someone help me with this?
Microsoft SQL Server 7.00 - 7.00.961 (Intel X86)
Oct 24 2000 18:39:12
Copyright (c) 1988-1998 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 1)
"news.microsoft.com" wrote:

> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violatio
n
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Window
s
> NT 5.0 (Build 2195: Service Pack 4)
>
>|||I'm going to try this again. I'm having the same problem. I'm getting that
message "[Microsoft][ODBC SQL Server Driver]Syntax error or access
violation" and all I'm doing is trying to create some tables in the pubs dat
abase from a script. I'm using Que
ry Analyzer. Can someone help me with this.
"news.microsoft.com" wrote:

> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violatio
n
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName =
> ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Window
s
> NT 5.0 (Build 2195: Service Pack 4)
>
>

Parameters in subqueries ?

Can anyone tell me if this is a known bug? When using a parameter in a
subquery I get an access violation
The query below reproduces the problem using Northwind.
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
It also happens when using OLEDB
SELECT * FROM Orders
WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName = ?)
Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.0 (Build 2195: Service Pack 4)What is question mark supposed to represent? Is this in a stored procedure?
Did you mean to use a named @.parameter?
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"news.microsoft.com" <deo.is@.unknown.com> wrote in message
news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
> Can anyone tell me if this is a known bug? When using a parameter in a
> subquery I get an access violation
> The query below reproduces the problem using Northwind.
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> It also happens when using OLEDB
> SELECT * FROM Orders
> WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName => ?)
> Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on
Windows
> NT 5.0 (Build 2195: Service Pack 4)
>|||The question mark represents and unnamed parameter.
I never use the @.param syntax for queries since Enterprise manager does
support them.
It is not in a stored procedure. It's being submitted from C# code but it
blows up just the same from Enterprise SQL Mangler
Seems to work ok with named parameters from Query Analyser.
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:uJgffxqPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> What is question mark supposed to represent? Is this in a stored
procedure?
> Did you mean to use a named @.parameter?
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
> "news.microsoft.com" <deo.is@.unknown.com> wrote in message
> news:OZMXwpqPEHA.3708@.TK2MSFTNGP10.phx.gbl...
> > Can anyone tell me if this is a known bug? When using a parameter in a
> > subquery I get an access violation
> > The query below reproduces the problem using Northwind.
> >
> > [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> > [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
> >
> > It also happens when using OLEDB
> >
> > SELECT * FROM Orders
> > WHERE CustomerID IN (SELECT customerID FROM Customers WHERE CompanyName
=> > ?)
> >
> > Microsoft SQL Server 2000 - 8.00.857 (Intel X86) Sep 2 2003 18:55:32
> > Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on
> Windows
> > NT 5.0 (Build 2195: Service Pack 4)
> >
> >
>|||> I never use the @.param syntax for queries since Enterprise manager does
> support them.
Why are you using Enterprise Manager for this?
> It is not in a stored procedure. It's being submitted from C# code but it
> blows up just the same from Enterprise SQL Mangler
If you're sending the code like that, why not fill in the parameter value in
C#?
> Seems to work ok with named parameters from Query Analyser.
As it should. Not all providers are going to understand the same funky
syntax that EM requires.|||I use the ? style parameter since the query wizards in Visual Studio don't
support the @.param style. The VS.NET wizards must use the same codebase as
EM since they mangle queries in much the same fashion :(
Thanks for the help
"Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> > I never use the @.param syntax for queries since Enterprise manager does
> > support them.
> Why are you using Enterprise Manager for this?
> > It is not in a stored procedure. It's being submitted from C# code but
it
> > blows up just the same from Enterprise SQL Mangler
> If you're sending the code like that, why not fill in the parameter value
in
> C#?
> > Seems to work ok with named parameters from Query Analyser.
> As it should. Not all providers are going to understand the same funky
> syntax that EM requires.
>|||"news.microsoft.com" wrote:
> I use the ? style parameter since the query wizards in Visual Studio don't
> support the @.param style. The VS.NET wizards must use the same codebase as
> EM since they mangle queries in much the same fashion :(
> Thanks for the help
> "Aaron Bertrand - MVP" <aaron@.TRASHaspfaq.com> wrote in message
> news:O61yeArPEHA.3016@.TK2MSFTNGP10.phx.gbl...
> > > I never use the @.param syntax for queries since Enterprise manager does
> > > support them.
> >
> > Why are you using Enterprise Manager for this?
> >
> > > It is not in a stored procedure. It's being submitted from C# code but
> it
> > > blows up just the same from Enterprise SQL Mangler
> >
> > If you're sending the code like that, why not fill in the parameter value
> in
> > C#?
> >
> > > Seems to work ok with named parameters from Query Analyser.
> >
> > As it should. Not all providers are going to understand the same funky
> > syntax that EM requires.
> >
> >
>
>