Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
All versions of PostgreSQL. Add an additional version-specific tag like [postgresql-13] if that context is relevant.
2
votes
1
answer
3k
views
How can I pass a string as where clause to a function?
How can I convert this:
CREATE OR REPLACE FUNCTION getFooData()
RETURNS TABLE(foo_name name text) AS
$BODY$
BEGIN
RETURN QUERY select foo_name from foo where x = 3;
END
$BODY$
LANGUAGE plpgsql V …
2
votes
Accepted
How can I pass a string as where clause to a function?
EDIT: Following the Horse's answer/comment, this is my final version of my function:
CREATE OR REPLACE FUNCTION public.pointscanner(IN routegeometry text, IN criteria text)
RETURNS TABLE(way geomet …
3
votes
Use column values in ORDER BY and LIMIT clauses
It was solved by a friend with this statement:
select * from test
order by
case when (ordr='asc') then first_name end asc,
case when (ordr='desc') then first_name end desc
limit ( sel …
4
votes
2
answers
5k
views
Use column values in ORDER BY and LIMIT clauses
I have this table in a Postgres 9.3 database:
I need to use the content of columns order and limit to sort and filter this table. The table will be sorted by column first_name.
The final result wi …
1
vote
3
answers
293
views
How to do a kind of selective grouping in a SQL result?
I have some query as select x1,x2,x3,x4 from foo where bar resulting something like:
CREATE TEMP TABLE foo
AS SELECT * FROM ( VALUES
( '00','01','03','AA' ),
( '01','03','03','BB' ),
( '02','09',' …
0
votes
How to do a kind of selective grouping in a SQL result?
This function was the one that actualy solved my problem. I'll not accept it because I was not too clear in my question and based in my example the accepted answer is the correct one. The major proble …
0
votes
3
answers
55
views
Help to improve a function
I have this function working fine:
CREATE or replace FUNCTION pointscanner(
IN source integer,
IN target integer,
IN k integer,
IN directed boolean,
IN quant integer
)
RETURNS ta …
0
votes
Help to improve a function
This is the complete full version of the working function:
CREATE OR REPLACE FUNCTION public.pointscanner(IN routegeometry text, IN criteria text, IN source text)
RETURNS TABLE(way geometry, name t …