Merging and returning arrays

Merging and returning arrays

I've two functions,

I've two functions,

CREATE OR REPLACE FUNCTION function_a(input varchar)
RETURNS setof integer AS $$
    SELECT somecolumn FROM some_things WHERE a_column = input;

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']);

The error,

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.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

PostgreSQL Tutorial - Learn PostgreSQL Database from Scratch

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.

Learn & Use PostgreSQL - Getting Started with Sequelize and PostgreSQL

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

PostgreSQL with Nodejs

Most of the applications need at some point to persist data. It can be through files, local storage, cloud services or often databases