Error Syntax Error At End Of Input Postgresql
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions syntax error at end of input postgres you might have Meta Discuss the workings and policies of syntax error at end of input sql this site About Us Learn more about Stack Overflow the company Business Learn more about hiring syntax error at the end of input c developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is
Syntax Error At End Of Input Redshift
a community of 4.7 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 - 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) psqlexception: error: syntax error at end of input 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 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 activ
here for a quick overview of the site Help Center Detailed answers to any questions you might have error: syntax error at end of input position Meta Discuss the workings and policies of this site About Us Learn
Sql State: 42601
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us
Postgres Insert
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like http://stackoverflow.com/questions/23680629/error-syntax-error-at-end-of-input-java-postgres you, helping each other. Join them; it only takes a minute: Sign up Syntax error in plpgsql up vote 1 down vote favorite 1 I have a stored procedure in PostgreSQL CREATE OR REPLACE FUNCTION show_senti_lang_setting(IN _senti_id bigint) RETURNS TABLE(lang_code character, native_name character varying, is_active boolean) AS $BODY$ BEGIN RETURN QUERY SELECT l.lang_code, l.native_name, (CASE WHEN http://stackoverflow.com/questions/14171265/syntax-error-in-plpgsql s.senti_id is NULL THEN FALSE ELSE TRUE END) is_active FROM language l LEFT JOIN senti_lang s ON s.lang_code=l.lang_code AND s.senti_id=_senti_id; END; $BODY$ LANGUAGE plpgsql VOLATILE STRICT; The Error is: ERROR: syntax error at or near "$1" LINE 1: ...HEN s.senti_id is NULL THEN FALSE ELSE TRUE END) $1 FROM l... ^ QUERY: SELECT l.lang_code, l.native_name, (CASE WHEN s.senti_id is NULL THEN FALSE ELSE TRUE END) $1 FROM language l LEFT JOIN senti_lang s ON s.lang_code=l.lang_code AND s.senti_id= $2 CONTEXT: SQL statement in PL/PgSQL function "show_senti_lang_setting" near line 13 ********** Error ********** ERROR: syntax error at or near "$1" SQL state: 42601 Context: SQL statement in PL/PgSQL function "show_senti_lang_setting" near line 13 Seems like the error is due to CASE in plpgsql. The same function in is working well in SQL: CREATE OR REPLACE FUNCTION show_senti_lang_setting(bigint) RETURNS TABLE(lang_code character, native_name character varying, is_active boolean) AS $BODY$ SELECT l.lang_code, l.native_name, CASE WHEN s.senti_id is NULL THEN FALSE ELSE TRUE END is_active FROM language l LEFT JOIN senti_lang s ON s.lang_code=l.lang_cod
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/1e5bcefd0708270540p5a45ae19h5e43568cadb373ea@mail.gmail.com lists Associations User groups Project lists Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News [ERROR] syntax error at end of input From: "Marcelo de Moraes Serpa"