From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Prepared_Statement :( Date: Sat, 24 Nov 2018 12:05:01 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: IzvqdhUtDGKIMCldyDtZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:54881 Date: 2018-11-24T12:05:01+01:00 List-Id: 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