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 :: sql vs nosql 
Sql :: mysql sql.gz 
Sql :: stored procedure sql 
Sql :: what is unique key in sql 
Sql :: sqlite clear console 
Sql :: install mysql 
Sql :: if sql 
Sql :: frename oracle 
Sql :: ORACLE CALL BACK TRACE 
Sql :: oracle last connection 
Sql :: time in sql server 
Sql :: md5 encode oracle 
Sql :: querry mysql by 2 columns 
Sql :: postgres insert into table 
Sql :: psql command not found windows 
Sql :: dns slave zone convert 
Sql :: Write an SQL query to fetch the count of employees working in the department ‘Admin’. 
Sql :: sql track modification 
Sql :: Failed to process SQL command - ORA-28014: cannot drop administrative user or role 
Sql :: mysql delete duplicate rows except one 
Sql :: SQL IN Operator With Subquery 
Sql :: cast as decimal postgresql 
Sql :: mysql select smaller of two values 
Sql :: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 
Sql :: copy table db 
Sql :: sql commands 
Sql :: mariadb check constraint example? 
Sql :: clustered-nonclustered indexes(constraints) 
Sql :: cannot connect to mysql server 10060 
Sql :: _ Wildcard in SQL 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =