I've two functions,
I've two functions,
CREATE OR REPLACE FUNCTION function_a(input varchar) RETURNS setof integer AS $$ BEGIN RETURN QUERY SELECT somecolumn FROM some_things WHERE a_column = input; END; $$ LANGUAGE PLpgSQL;
CREATE OR REPLACE FUNCTION function_b(inputs varchar) RETURNS setof integer AS $$ DECLARE input varchar; result integer; BEGIN FOREACH input IN ARRAY inputs LOOP result := result || ARRAY[function_a(input)]; END LOOP; END; $$ LANGUAGE PLpgSQL;
I am running it like,
SELECT function_b(ARRAY['a', 'b']);
ERROR: query "SELECT result || ARRAY[function_a(input)]" returned more than one row CONTEXT: PL/pgSQL function function_b(character varying) line 7 at assignment
All I want to do is to run a function over an array. I've always used scripting languages like Ruby to do this kind of stuff instead of using SQL, but I'm trying to learn SQL as it is much faster to get results on the db console itself. I wish it wasn't so frustrating.
PostgreSQL Tutorial - Learn PostgreSQL Database from Scratch. Learn how to use PostgreSQL in this full course. PostgreSQL is a general purpose and object-relational database management system. It is the most advanced open source database system widely used to build back-end systems. What is a Database? What is SQL And Relational Database? What is PostreSQL AKA Postrgres? PostgreSQL Installation. How to Create Database.
In this tutorial, we will learn about NodeJS ORM called Sequelize interfacing with PostgreSQL Database. We are going to learn and use PostgreSQL. Sequelize is the NodeJS module which provides common functionalities and utilities to manipulate SQL based databases. Technically, it is an ORM ( Object relational mapping ) module for NodeJS. It supports the following databases: MySQL, PostgreSQL, MariaDB, SQLite, MSSQL
Most of the applications need at some point to persist data. It can be through files, local storage, cloud services or often databases