Sample Problem with queries Link
Not able to get any inserted row in the RETURNING statement with INSERT and SELECT command even after adding RETURN NEXT; RETURN ;
SCHEMA FOR USER TABLE
create table "user" (name text not null, updated_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP );
function which needs to be updated to return inserted rows
CREATE OR REPLACE FUNCTION testFn()
RETURNS table (name character varying , updated_time timestamp without time zone ) AS $$ DECLARE BEGIN
insert into "user" (name , updated_time)
select 'alex',now()
union
select 'alex2',now()
returning name, updated_time;
END;
$$ LANGUAGE plpgsql;
This function only inserts into DB but doesnt return the inserted rows with updated time on calling the function
it return no output on
select * from testFn()