Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table test(
- id int generated by default as identity primary key,
- nama char (50) not null,
- age int not null,
- address char(100) not null,
- salary int not null);
- insert into test (nama, age, address, salary)
- values ('Rahmad', 24, 'Medan', 1000000);
- insert into test (nama, age, address, salary)
- values ('Andari', 19, 'Suka Bumi', 2000000);
- insert into test (nama, age, address, salary)
- values ('Rahmadi', 18, 'Jambi', 3000000);
- insert into test (nama, age, address, salary)
- values ('Rafi', 20, 'Jakarta', 4000000);
- insert into test (nama, age, address, salary)
- values ('Wandi', 20, 'Prabumuli', 5000000);
- insert into test (nama, age, address, salary)
- values ('Wildan', 22, 'Bekasi', 6000000);
- insert into test (nama, age, address, salary)
- values ('Rahmad', 24, 'Medan', 1000000);
- insert into test (nama, age, address, salary)
- values ('Rahmad', 24, 'Medan', 1000000);
- create or replace function totalRecords ()
- returns integer as $total$
- declare
- total integer;
- begin
- select count(*) into total from test;
- return total;
- end;
- $total$ language plpgsql;
- end
- select totalRecords();
- select * from test;
Advertisement
Add Comment
Please, Sign In to add comment