Search
 
SCRIPT & CODE EXAMPLE
 

SQL

return result of function in postgresql

Create or replace Function public.my_function(p_el1 int, p_el2 int, p_name char)
Returns table (id int, price int)
language plpgsql

as
$$
	declare
		v_total int;
	
	begin
		-- insert into first table
		insert into my_table1
			(added_name)
		values
			(p_name);

		-- Insert the result of a calculation in a variable
		select (p_el1 + p_el2) into v_total;
	
		-- Update a second table
		update my_table2 mt
		set
			price = v_total
		where
			mt.name = p_name;
		
		-- Return the result of a query
		return query (select
							mt.id,
							mt.price
						from
							my_table2 mt
						where
							mt.name = p_name);
		
	end;
$$

Comment

PREVIOUS NEXT
Code Example
Sql :: change data type postgresql 
Sql :: sql now 
Sql :: mysql like case sensitive 
Sql :: update with inner join sql server 
Sql :: PSQL use LIKE with timestamps 
Sql :: install postgresql 10 centos 7 
Sql :: avg sql 
Sql :: sql select case when 
Sql :: mysql timestamp format 
Sql :: convert multiple columns to rows in sql server 
Sql :: row to value to json in sql server 
Sql :: mysql login to a specific database terminal 
Sql :: alter table myisam to innodb 
Sql :: sql select rows with different values in one column 
Sql :: mysql order by two columns priority 
Sql :: oracle select into 
Sql :: sql count total by foreign key 
Sql :: create temp table in sql 
Sql :: importing excel data into sql server 
Sql :: how to display value of variable in mysql 
Sql :: mysql find duplicates 
Sql :: how to select random rows from a table 
Sql :: mysql import database 
Sql :: create table like another table 
Sql :: postgres role does not exist 
Sql :: null column as zero in mysql 
Sql :: print hello world in sql 
Sql :: oracle dynamic select into 
Sql :: postgressum when 
Sql :: delete * from where id = 1; 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =