Postgres Syntax Error At End Of Input At Character
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us syntax error at the end of input c Learn more about Stack Overflow the company Business Learn more about hiring developers syntax error at end of input redshift or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack psqlexception: error: syntax error at end of input Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR: syntax error at end of input, Java error: syntax error at end of input position - Postgres up vote 0 down vote favorite I have used the next SQL statement but it fails in PostgreSQL. sentencia.execute("INSERT INTO \"Registros\" (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accion_mes,fecha_accion_dia) VALUES ('recarga','" + num_tarjeta + "','" + valor_recargar + "','" + Calendar.getInstance().get(Calendar.YEAR) + "','" + Calendar.getInstance().get(Calendar.MONTH) + "','" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "'"); with this error: ERROR: syntax error at end of input What's the problem? Thanks java sql postgresql share|improve this question asked
Sql State: 42601
May 15 '14 at 14:06 user3554506 314 2 The main problem is that you're specifying a value directly in SQL. Don't do that. Use parameterized SQL instead, to separate the code from the data. Once you've fixed that, you'll see the syntax error much more easily... as well as not being vulnerable to SQL injection attacks. Additionally, you're calling Calendar.getInstance() multiple times, which means you could be using multiple different values. Imagine if you're executing this right at the end of the year... you could end up with the "old" year but the "new" month and day values. Ick. –Jon Skeet May 15 '14 at 14:10 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted You're missing a ) at the end of the statement and the table is surrounded with double quotes for no reason.. INSERT INTO Registros (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accion_mes,fecha_accion_dia) VALUES ('recarga','','','','','')"); share|improve this answer answered May 15 '14 at 14:07 JasonSec 409311 True! :) thanks –user3554506 May 15 '14 at 14:08 2 That's not the biggest problem though... –Jon Skeet May 15 '14 at 14:09 add a comment| Your Answer draft saved draft discarded Sign up or
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional
Postgres Insert
lists Associations User groups Project lists Inactive lists IRC postgres create table Local User Groups Featured Users International Sites Propaganda Resources Weekly News [ERROR] syntax error at end of input From: "Marcelo de Moraes Serpa"
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional https://www.postgresql.org/message-id/957.1188228906@sss.pgh.pa.us lists Associations User groups Project lists Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News Re: [ERROR] http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1047763895 syntax error at end of input From: Tom Lane
専門家 企業公式 Q&A一覧 回答コーナー 今すぐ利用登録 Q&A 知恵ノート Q&A Q&A 知恵ノート 条件指定 すべてのカテゴリ Unix系 質問・相談 知恵ノートを書く 知恵袋トップ> スマートデバイス、PC、家電> OS> Unix系 現在JavaScriptが無効になっています。 Yahoo!知恵袋のすべての機能を利用するためには、javaScriptの設定を有効にしてください。 JavaScriptの設定を変更するには「JavaScriptの設定方法」をご覧ください。 Unix で現在 kadai.c:61:error:syntax error at end of input とでてきてるので... シェア ツイート はてブ 知恵コレ i2_s8m2i9さん 2010/9/2800:11:21 Unix で現在 kadai.c:61:error:syntax error at end of input とでてきてるのですがこれはなにが原因なんでしょうか?? Unix初心者なんでまだよくわかりません…。 お願いします。 補足ちなみに61行目は 終わりの } しかないんですが…^ロ^; この質問は、活躍中のチエリアン・専門家に回答をリクエストしました。 共感した 0 閲覧数:2,328 回答数:3 お礼:50枚 違反報告 ベストアンサーに選ばれた回答 katayori_sannさん 2010/10/200:38:39 { と } の対応が取れているか確認しましょう。 int main( void ) { if ( 1 == 2 ) { printf .....; } /* この閉じ中カッコはmain の閉じカッコなのか ifの閉じカッコなのか いずれにしても、どちらかの閉じカッコが足りない事は確かかと */ 見たいに、最後の } だけでは } が足りない感じになっていませんか? プログラミングで使うテキストエディタの多くはカッコの対応を調べてくれる機能を持ってますので使うとすぐに分かるかと思います。 ※ 例えばvi系のエディタだと:set showmatchすれば。 ナイス 0 違反報告 この質問は投票によってベストアンサーに選ばれました! シェア ツイート はてブ 知恵コレ このQ&Aで解決しましたか?質問する 閉じる ベストアンサー以外