Error Syntax Error At End Of Input Line 1 Select
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 Learn more about Stack Overflow the company Business a syntax error was detected in the input line Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation error syntax error at end of input postgresql Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just syntax error at end of input sql like you, helping each other. Join them; it only takes a minute: Sign up Syntax error at end of input in PostgreSQL up vote 7 down vote favorite 1 I have used the next SQL statement in
Syntax Error At End Of Input Postgres
both MySQL and PostgreSQL, but it fails in PostgreSQL db.Query(`SELECT COUNT(*) as N FROM email WHERE address = ?`, email) with this error: pq: F:"scan.l" M:"syntax error at end of input" S:"ERROR" C:"42601" P:"50" R:"scanner_yyerror" L:"993" What's the problem? The error messages in PostgreSQL are very cryptic. sql postgresql go share|improve this question edited Oct 29 '12 at 10:40 dandan78 7,52873762 asked Oct 29 '12 at 10:26 user1243746 2 What language are you coding syntax error unexpected end of input in? I mean the client language, not the SQL. –Mark Byers Oct 29 '12 at 10:28 1 What database client are you using? That cryptic error is much more to do with the database client than the database server. If I prepare that statement it's fine, so the issue is most likely with your programming language or database adapter. Try it in psql. PREPARE q AS SELECT COUNT(*) as N FROM email WHERE address = $1; then EXECUTE q;. $1 is the placeholder syntax for PREPARE, but your programming language probably uses ?; otherwise there's no difference. –Craig Ringer Oct 29 '12 at 10:29 add a comment| 3 Answers 3 active oldest votes up vote 15 down vote accepted You haven't provided any details about the language/environment, but I'll try a wild guess anyway: MySQL's prepared statements natively use ? as the parameter placeholder, but PostgreSQL uses $1, $2 etc. Try replacing the ? with $1 and see if it works: WHERE address = $1 The error messages in PostgreSQL are very cryptic. In general, Postgres error messages are very clear, but in this instance you've managed to confuse the parser beyond sanity. :) share|improve this answer edited Oct 29 '12 at 10:37 answered Oct 29 '12 at 10:32 intgr 11.9k3753 5 Note that this is dependent on the programming language
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 Learn more about Stack Overflow the company Business Learn more about hiring syntax error unexpected end of input ruby developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Syntax Error Unexpected End Of Input Ajax
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them;
Syntax Error Unexpected End Of Input Javascript
it only takes a minute: Sign up Greenplum plpgsql function returns syntax error at end of input up vote 1 down vote favorite 1 I was writing a PL/pgSQL function in Greenplum and the function needs to translate the interval http://stackoverflow.com/questions/13119786/syntax-error-at-end-of-input-in-postgresql which < interval '00:00:00' to a positive value. For example, the interval value -23:57:00 should be translated to 00:03:00. So I wrote this function: CREATE OR REPLACE FUNCTION abstime(timeval INTERVAL) RETURNS INTERVAL AS $$ BEGIN IF timeval < INTERVAL '00:00:00' THEN RETURN timeval + INTERVAL '24:00:00'; ELSE RETURN timeval; END IF; RETURN; END; $$ LANGUAGE plpgsql; After I entered, I got: ERROR: syntax error at end of input LINE 1: SELECT ^ QUERY: SELECT CONTEXT: SQL statement in PL/PgSQL http://stackoverflow.com/questions/37341380/greenplum-plpgsql-function-returns-syntax-error-at-end-of-input function "abstime" near line 7 I am not sure what's going wrong? sql postgresql plpgsql greenplum share|improve this question edited May 24 at 12:58 asked May 20 at 8:12 cinqS 9311 1 I'm guessing that error showed up after invocation of function. Show us that invocation. –Darek May 20 at 8:16 1 how many abstime function you have?.. –Vao Tsun May 20 at 8:22 actually, I didn't call this function at all, this error show up after I pressed the enter, so I have no functions at all in my \df –cinqS May 20 at 9:04 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Pavel is 100% correct on how to fix the function but based on the function code and because you are using Greenplum, I am guessing you are wanting to select this inline against a large table. When doing this, you'll want to avoid the overhead of PL/pgSQL. It is a great language and I use it often but I would avoid it for inline SQL. Use PL/pgSQL for encapsulating transformation logic, not inline SQL. Secondly, I would make the function IMMUTABLE because you aren't updating the database in the function and the same value always returns for a given parameter. More on that here: http://www.postgresql.org/docs/8.2/static/xfunc-volatility.html Proof: CREATE OR REPLACE FUNCTION abstime(timeval INTERVAL) RETURNS INTERVAL AS $$ BEGIN IF timeval < INTERVAL '00:0
Sign in Pricing Blog Support Search GitHub This repository Watch 118 Star 2,352 Fork 349 lib/pq Code Issues https://github.com/lib/pq/issues/350 36 Pull requests 25 Projects 0 Pulse Graphs New issue Syntax error at end of input #350 Closed mikeroosa opened this Issue Mar 13, 2015 · 2 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants mikeroosa commented Mar 13, 2015 Trying to build a syntax error sample app and can't open a connection to the database. Everything works fine with psql so not sure what I'm doing wrong. db, err := sql.Open("postgres", "host=localhost dbname=postgres user=postgres password=postgres sslmode=disable") This is the error: pq: syntax error at end of input If I leave off password or username then I get a different end of input error. For example, if I don't include the password, I get: pq: password authentication failed for user "postgres" What is wrong with my code or setup? mikeroosa closed this Mar 13, 2015 uhoh-itsmaciek commented Mar 13, 2015 For posterity, what was wrong with your code or setup? At first glance, your connection string looks legit, so we should at least be giving a better error. mikeroosa commented Mar 13, 2015 It was a dumb error on my part. The actual syntax error was from the select statement I had on the next line. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.