Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #783

Re: SQL command gives different result when done in function

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Dimitri Fontaine <dimitri.fontaine@schibsted.com>
Newsgroups comp.databases.postgresql
Subject Re: SQL command gives different result when done in function
Date Mon, 29 May 2017 11:20:31 +0200
Organization A noiseless patient Spider
Lines 16
Message-ID <m2y3tgvx28.fsf@dimitris-mbp.home> (permalink)
References <28abb49e-321a-45ac-9562-16f0bc301c46@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="187b117db01b397870c298e755165ead"; logging-data="13112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/EsJCbCWgUHagj+qqh4Cv"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin)
Cancel-Lock sha1:aDKodVSjk11WkL/C6RIWiN30aNU= sha1:eVquFc5N+eXts/N+3CV5ApmP2ms=
Xref csiph.com comp.databases.postgresql:783

Show key headers only | View raw


neojustebelmont@gmail.com writes:
> Now I put that SQL into a function. And when the function is called, it
> instead gave out "C", which also fulfilled the date and product_id
> requirement.
>
> Is there a way I could get "A" no matter what? Hopefully without adding
> extra WHERE clauses

The only way to know in which order you get the rows in SQL is to use
the ORDER BY clause. I don't think it makes any sense to use the LIMIT
clause without an ORDER BY clause, apart from interactive data discovery
at the prompt.

-- 
Dimitri Fontaine
PostgreSQL DBA, Architecte

Back to comp.databases.postgresql | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

SQL command gives different result when done in function neojustebelmont@gmail.com - 2017-05-29 02:07 -0700
  Re: SQL command gives different result when done in function Dimitri Fontaine <dimitri.fontaine@schibsted.com> - 2017-05-29 11:20 +0200
  Re: SQL command gives different result when done in function DFS <nospam@dfs.com> - 2017-05-29 22:07 -0400

csiph-web