Subject | RE: [firebird-support] -104 Token unknown - line 1, column 497 ? |
---|---|
Author | Varga Balázs |
Post date | 2013-02-26T17:37:27Z |
I have renamed the parameter names, but I get the same error.
Btw. I have another queries, where I use the same parameter many times.
Changing the query is unfort. not an option.
To: firebird-support@yahoogroups.com
From: svein.erling.tysvaer@...
Date: Tue, 26 Feb 2013 09:15:49 +0100
Subject: RE: [firebird-support] -104 Token unknown - line 1, column 497 ?
Helen has many times said that parameters are place holders, not variables, and that they cannot be reused. Some component sets actually let you reuse parameters with little or no problem (e.g. with IBObjects, problems only occur if the same parameter name is used for fields of different types), but it might not be the case for you. So, try changing your query to use a different name for each parameter, or change your query - e.g. to something like this:
INSERT INTO
szamlaegyenlegek(szamlaszam, halmt, halmk, halme, uzleti_ev, alperiodus_kod, datum, targyt, targyk, targye, kpnem)
WITH tmp(elozofoper, elozovege, halmt, halmk, halme) AS
(SELECT uzleti_ev, max(datum), max(halmt), max(halmk), max(halme)
FROM szamlaegyenlegek
WHERE uzleti_ev=:elozofoper
AND datum<=:elozovege)
SELECT DISTINCT se.szamlaszam, t.halmt, t.halmk, t.halme, :kovuzlev, 0, cast(:kovuzlev_kezdes as Date), 0, 0, 0, :KPNEM
FROM szamlaegyenlegek se
JOIN szamlatukor st ON se.szamlaszam=st.szamlaszam
JOIN tmp t on se.uzleti_ev = t.uzleti_ev
WHERE st.szamlatip IN ('Akt�v', 'Passz�v')
AND se.szamlaszam=:szamlaszam
AND se.datum<=t.elozovege
HTH,
Set
[Non-text portions of this message have been removed]
Btw. I have another queries, where I use the same parameter many times.
Changing the query is unfort. not an option.
To: firebird-support@yahoogroups.com
From: svein.erling.tysvaer@...
Date: Tue, 26 Feb 2013 09:15:49 +0100
Subject: RE: [firebird-support] -104 Token unknown - line 1, column 497 ?
>I have this query with some parameters:Hi Varga, here's my guess:
>
>"INSERT INTO " & _
> "szamlaegyenlegek(szamlaszam, halmt, halmk, halme, uzleti_ev, alperiodus_kod, datum, targyt, targyk, targye, kpnem) " & _
> "SELECT DISTINCT " & _
> "szamlaegyenlegek.szamlaszam, (select max(halmt) from (select halmt from szamlaegyenlegek where uzleti_ev=@elozofoper and datum<=@elozovege)), " & _
> "(select max(halmk) from (select halmk from szamlaegyenlegek where uzleti_ev=@elozofoper and datum<=@elozovege)), " & _
> "(select max(halme) from (select halme from szamlaegyenlegek where uzleti_ev=@elozofoper and datum<=@elozovege)), " & _
> "@kovuzlev AS uzleti_ev, 0 AS alperiodus_kod, DATE @kovuzlev_kezdes AS datum, " & _
> "0, " & _
> "0, " & _
> "0, '" & KPNEM & "' AS kpnem " & _
> "FROM szamlaegyenlegek INNER JOIN szamlatukor ON szamlaegyenlegek.szamlaszam=szamlatukor.szamlaszam " & _
> "WHERE szamlatip IN ('Akt�v', 'Passz�v') AND szamlaegyenlegek.szamlaszam=@szamlaszam and uzleti_ev=@elozofoper AND datum<=@elozovege"
>
>If I run the query, I get the error:
>
>Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 497 ?
>
>The column 497 is at @elozofoper and datum<=@elozovege)), @kovuzlev AS uzleti_ev.
>
>As you see, all the parameters have a value:
>
>FirebirdSql.Data.FirebirdClient Information: 0 : Parameters:
>
>FirebirdSql.Data.FirebirdClient Information: 0 : Name:@kovuzlev Type:VarChar Used Value:2014
>FirebirdSql.Data.FirebirdClient Information: 0 : Name:@kovuzlev_kezdes Type:TimeStamp Used Value:01/01/2014 00:00:00
>FirebirdSql.Data.FirebirdClient Information: 0 : Name:@elozofoper Type:VarChar Used Value:2013
>FirebirdSql.Data.FirebirdClient Information: 0 : Name:@elozovege Type:VarChar Used Value:2013.12.31.
>FirebirdSql.Data.FirebirdClient Information: 0 : Name:@szamlaszam Type:VarChar Used Value:541100
>
>It is strange, why I don't get the same error f.e at one line above in the query. I have there the same parameter.
Helen has many times said that parameters are place holders, not variables, and that they cannot be reused. Some component sets actually let you reuse parameters with little or no problem (e.g. with IBObjects, problems only occur if the same parameter name is used for fields of different types), but it might not be the case for you. So, try changing your query to use a different name for each parameter, or change your query - e.g. to something like this:
INSERT INTO
szamlaegyenlegek(szamlaszam, halmt, halmk, halme, uzleti_ev, alperiodus_kod, datum, targyt, targyk, targye, kpnem)
WITH tmp(elozofoper, elozovege, halmt, halmk, halme) AS
(SELECT uzleti_ev, max(datum), max(halmt), max(halmk), max(halme)
FROM szamlaegyenlegek
WHERE uzleti_ev=:elozofoper
AND datum<=:elozovege)
SELECT DISTINCT se.szamlaszam, t.halmt, t.halmk, t.halme, :kovuzlev, 0, cast(:kovuzlev_kezdes as Date), 0, 0, 0, :KPNEM
FROM szamlaegyenlegek se
JOIN szamlatukor st ON se.szamlaszam=st.szamlaszam
JOIN tmp t on se.uzleti_ev = t.uzleti_ev
WHERE st.szamlatip IN ('Akt�v', 'Passz�v')
AND se.szamlaszam=:szamlaszam
AND se.datum<=t.elozovege
HTH,
Set
[Non-text portions of this message have been removed]