Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql procedure example


        
            
        
     create [or replace] procedure procedure_name(parameter_list)
language plpgsql
as $$
declare
-- variable declaration
begin
-- stored procedure body
end; $$
Comment

postgres stored procedure

CREATE OR REPLACE FUNCTION public.date_submission(state varchar, created_at date, updated_at date)
 returns date
 LANGUAGE plpgsql
 IMMUTABLE
AS $function$
declare
	response date;
begin
	if (state = 'CREATED' or state = 'PENDING' or state = 'PENDING - RESUBMITTED') then 
		response = updated_at;
	else
		response = created_at;
	end if;
	return response;
end;
$function$

select date_submission('PENDING', now()::date, now()::date)
Comment

PREVIOUS NEXT
Code Example
Sql :: postgres role does not exist 
Sql :: mariadb cast to int 
Sql :: QL HAVING Keyword 
Sql :: mysql connectiion timeout 
Sql :: mysqldump database 
Sql :: sql query to check if column contains alphabets 
Sql :: get largest number in database sql 
Sql :: command to give readonly access to a postgres sql user 
Sql :: sql where part of string match 
Sql :: create empty table from existing table 
Sql :: sql oracle limit 
Sql :: oracle dynamic select into 
Sql :: count the table indatabase 
Sql :: How to import CSV file into a MySQL table 
Sql :: ignore case in string sql 
Sql :: delete * from where id = 1; 
Sql :: find log file postgresql linux 
Sql :: postgresql concat string with separator 
Sql :: oracle chain rules 
Sql :: test sql query 
Sql :: how to get parent and child record in single query using sql 
Sql :: sql rename table 
Sql :: mysql update command 
Sql :: delete table cassandra 
Sql :: mysql join two tables 
Sql :: flask connect to mysql 
Sql :: query to find third highest salary 
Sql :: postgress if 
Sql :: mysql nested query 
Sql :: multiple row primary key 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =