comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Prepared_Statement :(
Date: Sat, 24 Nov 2018 12:05:01 +0100
Date: 2018-11-24T12:05:01+01:00	[thread overview]
Message-ID: <ptbb8s$1g72$1@gioia.aioe.org> (raw)
In-Reply-To: ce530325-6c40-458f-bd51-b5f03eebe02e@googlegroups.com

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


  parent reply	other threads:[~2018-11-24 11:05 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 [this message]
2018-11-24 11:20   ` eduardsapotski
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