comp.lang.ada
 help / color / mirror / Atom feed
From: eduardsapotski@gmail.com
Subject: Prepared_Statement :(
Date: Sat, 24 Nov 2018 02:45:23 -0800 (PST)
Date: 2018-11-24T02:45:23-08:00	[thread overview]
Message-ID: <ce530325-6c40-458f-bd51-b5f03eebe02e@googlegroups.com> (raw)

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? :( 
Can anyone have a working example?


             reply	other threads:[~2018-11-24 10:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-24 10:45 eduardsapotski [this message]
2018-11-24 10:48 ` Prepared_Statement :( eduardsapotski
2018-11-24 11:05 ` Dmitry A. Kazakov
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