set-returning-functions Questions
4
Solved
As far as I can tell, my function properly resembles the samples I've seen. Can someone clue me in as to how I get this to work?
create or replace function get_user_by_username(
username varchar(2...
Margravine asked 22/12, 2011 at 14:19
2
I tried to run this query in PostgreSQL 10:
select e.errordescription,
CASE
WHEN e.reworkempid is not null THEN get_empname(e.reworkempid)
else null
end
from error_log_gs e
where e.qcwork...
Toponym asked 30/11, 2017 at 13:11
3
Solved
In an example table:
CREATE TABLE example (
id SERIAL PRIMARY KEY,
data JSON NOT NULL );
INSERT INTO example (id, data) VALUES
(1, '[{"key": "1", "value": "val...
Simba asked 31/5, 2021 at 8:59
3
Solved
I have the following PostgreSQL function which returns multiple columns from a table:
CREATE OR REPLACE FUNCTION userbyid(id integer)
RETURNS TABLE(id int, username character varying(30), email ch...
Immiscible asked 14/6, 2017 at 3:5
3
Solved
Table: table_name
create table table_name
(
given_dates timestamp,
set_name varchar
);
Insertion of records:
insert into table_name values('2001-01-01'),('2001-01-05'),('2001-01-10'),
('2001-0...
Injured asked 19/1, 2015 at 6:24
3
Solved
Suppose I have a table like this:
subject
flag
this is a test
2
subject is of type text, and flag is of type int. I would like to transform this table to something like this in Postgres...
Sigismund asked 2/4, 2015 at 18:31
6
Solved
When I have a column with separated values, I can use the unnest() function:
myTable
id | elements
---+------------
1 |ab,cd,efg,hi
2 |jk,lm,no,pq
3 |rstuv,wxyz
select id, unnest(string_to_array(...
Ignacia asked 6/1, 2012 at 15:45
1
Solved
I have a simple PostgreSQL function which I aspect should return values into separate columns -115 and 101000005458E6258... but it returns one column where two values are separated by a comma...
Marissamarist asked 25/6, 2020 at 14:7
5
I'm trying to generate a series in PostgreSQL with the generate_series function. I need a series of months starting from Jan 2008 until current month + 12 (a year out). I'm using and restricted to ...
Caudle asked 16/9, 2011 at 21:23
1
Solved
If I create a function f that queries a function I think it becomes easier to read if the return type is the name of a table instead of RETURNS TABLE(id integer, name text).
CREATE TABLE users ( i...
Whopping asked 14/2, 2020 at 8:4
2
Solved
I am receiving the error:
set-valued function called in context that cannot accept a set
when executing this function at RETURN QUERY EXECUTE line:
PLSQL $ cat lookup_email.pl
CREATE OR REPL...
Luik asked 13/12, 2016 at 1:42
3
Solved
I've got this PL/pgSQL function which must return some users information.
CREATE OR REPLACE FUNCTION my_function(
user_id integer
) RETURNS TABLE(
id integer,
firstname character varying,
la...
Kiddush asked 6/8, 2013 at 15:55
2
Solved
I have a table defined like so:
create table users (
id serial primary key,
name text,
email text,
);
...and I want to write a function that returns rows of the shape:
(
id integer,
name t...
Radke asked 28/6, 2017 at 0:15
3
Solved
I'm trying to get a "cross join" with the result of two set-returning functions, but in some cases I don't get the "cross join", see example
Behaviour 1: When set lenghts are the same, it matches ...
Phiz asked 5/10, 2016 at 0:2
1
Solved
I have a JSONB object in PostgreSQL:
'{"cars": ["bmw", "mercedes", "pinto"], "user_name": "ed"}'
I am trying to use values from the "cars" array inside it in the WHERE clause of a SELECT:
SELEC...
Narceine asked 3/7, 2016 at 23:52
2
Solved
Given a table defined as such:
CREATE TABLE test_values(name TEXT, values INTEGER[]);
...and the following values:
| name | values |
+-------+---------+
| hello | {1,2,3} |
| world | {4,5,6} |
I'...
Hubsher asked 13/8, 2015 at 20:18
1
Solved
I have a table bank_accounts:
Column | Type | Modifiers | Storage | Stats target | Description
---------------+-----------------------+-----------------------------------------------------------...
Bidarka asked 13/4, 2015 at 12:7
1
Solved
I have already tried the common PostgreSQL answer, but seems like it doesn't work with Redshift:
SELECT * FROM VALUES (1) AS q (col1);
ERROR: 42883: function values(integer) does not exist
I ne...
Valenti asked 30/1, 2015 at 10:10
1
Solved
I have the same question as this:
Splitting a comma-separated field in Postgresql and doing a UNION ALL on all the resulting tables
Just that my 'fruits' column is delimited by '|'. When I try:
S...
Cheng asked 10/3, 2015 at 22:11
1
Solved
I am trying to join table and function which returns rows:
SELECT p.id, p.name, f.action, f.amount
FROM person p
JOIN calculate_payments(p.id) f(id, action, amount) ON (f.id = p.id);
This functi...
Spiker asked 4/3, 2015 at 11:8
2
Solved
My last question Passing an array to stored to postgres was a bit unclear. Now, to clarify my objective:
I want to create an Postgres stored procedure which will accept two input parameters. One w...
Devour asked 8/1, 2015 at 9:22
2
Solved
I'm experimenting with keeping values like the following in a Postgres jsonb field in Postgres 9.4:
[{"event_slug":"test_1","start_time":"2014-10-08","end_time":"2014-10-12"},
{"event_slug":"test...
Mew asked 22/10, 2014 at 2:4
1
Solved
I have a table my_friends_cards:
id | name | rare_cards_composite[] |
---+---------+------------------------
1 | 'timmy' | { {1923, 'baberuth'}, {1999, 'jeter'}}
2 |'jimmy' | { {1955, 'Joey D'}, {...
Cluj asked 16/12, 2014 at 22:37
3
Solved
I have a PL/pgSQL function like this (thanks to the guy who made this possible):
CREATE OR REPLACE FUNCTION public.split_string(text, text)
RETURNS SETOF text
LANGUAGE plpgsql
AS $function$
D...
Amplify asked 26/11, 2014 at 11:54
2
Solved
This is a variation on plpgsql function that returns multiple columns gets called multiple times. However, I was hoping to find a solution to my particular set of circumstances.
I have a function ...
Gotthelf asked 29/9, 2014 at 20:3
1 Next >
© 2022 - 2024 — McMap. All rights reserved.