#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    76
    Rep Power
    5

    Parameter problem


    Hi,

    I have this query with some parameters:
    Code:
    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, 'EUR' 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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    36
    Rep Power
    8
    Replace @ with ? in your query and it will work.

IMN logo majestic logo threadwatch logo seochat tools logo