From: eduardsapotski@gmail.com
Subject: Re: Prepared_Statement :(
Date: Sat, 24 Nov 2018 03:20:27 -0800 (PST)
Date: 2018-11-24T03:20:27-08:00 [thread overview]
Message-ID: <9468b0a5-19bd-4057-a0d8-f84ed0425188@googlegroups.com> (raw)
In-Reply-To: <ptbb8s$1g72$1@gioia.aioe.org>
суббота, 24 ноября 2018 г., 14:05:02 UTC+3 пользователь Dmitry A. Kazakov написал:
> On 2018-11-24 11:45, eduardsapotski@gmail.com wrote:
> > Trying insert data into PostgreSql:
> >
> > function Insert_Trade(Trade : Trade_Type) return Boolean is
> >
> > Conn : Database_Connection := Build_Database_Connection;
> > PS : Prepared_Statement := Prepare(Query => "INSERT INTO exmo.trades(trade_id, pair, type, price, quantity, amount, date) VALUES (?, ?, ?, ?, ?, ?, ?)");
> > Params : SQL_Parameters(1..7);
> > FC : Forward_Cursor;
> >
> > Result : Boolean := False;
> >
> > begin
> >
> > Params(1) := "+"(Trade.Trade_ID);
> > Params(2) := "+"(Trade.Pair);
> > Params(3) := "+"(Trade.Direction);
> > Params(4) := "+"(Trade.Price'Img);
> > Params(5) := "+"(Trade.Quantity'Img);
> > Params(6) := "+"(Trade.Amount'Img);
> > Params(7) := "+"(Trade.Date);
> >
> > Execute (Conn, PS, Params);
> >
> > Commit_Or_Rollback(Conn);
> >
> > Put_Line(Conn.Last_Error_Message);
> >
> > return Result;
> >
> > end;
> >
> > Result:
> >
> > ERROR: syntax error at or near ","
> > LINE 1: ...ir, type, price, quantity, amount, date) VALUES (?, ?, ?, ?,...
> > ^
> > What's wrong? :(
>
> First. You don't say what library/binging/RDBMS client you are using,
> which version, what platform. That is certainly wrong.
>
> Then, "date" is a reserved keyword in SQL, which has tons of. You could
> start with qualifying all column names in the statement.
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
with GNATCOLL.SQL_Impl; use GNATCOLL.SQL_Impl;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.SQL.Postgres; use GNATCOLL.SQL;
If I just write:
Execute(Conn, "INSERT INTO exmo.trades(trade_id, pair, type, price, quantity, amount, date) VALUES (100500, 'pair', 'type', 1.0, 1.0, 1.0, 100500)");
Everything is working!
I think the problem is in the parameters.
next prev parent reply other threads:[~2018-11-24 11:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-24 10:45 Prepared_Statement :( eduardsapotski
2018-11-24 10:48 ` eduardsapotski
2018-11-24 11:05 ` Dmitry A. Kazakov
2018-11-24 11:20 ` eduardsapotski [this message]
2018-11-24 17:56 ` briot.emmanuel
2018-11-24 20:00 ` Simon Wright
2018-11-24 20:45 ` Dmitry A. Kazakov
2018-11-26 6:52 ` eduardsapotski
2018-11-27 0:27 ` Dennis Lee Bieber
2018-11-27 8:46 ` Dmitry A. Kazakov
2018-11-27 8:51 ` briot.emmanuel
2018-11-24 11:29 ` eduardsapotski
2018-11-27 9:58 ` eduardsapotski
2018-11-27 18:00 ` Dmitry A. Kazakov
2018-11-27 19:02 ` Björn Lundin
2018-11-28 5:04 ` eduardsapotski
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox