SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table Accounts (Bank text, Account text, FiO text, dBirth date); insert into Accounts values ('01', '111', 'Иванов Иван Иванович', '1990-05-17'), ('01', '222', 'Иванов Иван Иванович', '1990-05-17'), ('01', '333', 'Иванов Иван Иванович', '1990-05-17'), ('02', '111', 'Иванов Иван Иванович', '1990-05-17'); create or replace function get_account(bank_num text, lastname text, birth_dt date) returns setof text as $$ select Account from Accounts where 1=1 and Bank = $1 and split_part(FIO, ' ', 1) = $2 and dBirth = $3; $$ language sql; explain select * from get_account('01', 'Иванов', '1990-05-17'); explain create or replace function get_account_dynamic(bank_num text, lastname text, birth_dt date) returns table(acc text) as $$ begin return query select Account from Accounts where 1=1 and Bank = $1 and split_part(FIO, ' ', 1) = $2 and dBirth = $3; end; $$ language plpgsql; select * from get_account_dynamic('01', 'Иванов', '1990-05-17');
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear