Ge the value of id in master table and supply it to other tables I have 5 tables, of which one is master table and other 4 are the tables with have the foreign key of the id of the master table
 



I have to create a procedure which INSERT's data in all the tables including the Master table, I have to keep the id of Master table incremental.
So how should I get the value of the Master table row and supply the id of it in other tables in that procedure, WITHOUT using SELECT query(to get the id of Master table row) or WITHOUT supplying manually the id of master table in my program. 

I want all of it to be handled it on database side.

I am using PostgreSQL

Please help me in it.
Assuming the ID in the master table is generated (e.g. because it's defined as generated always as identity or serial) you can do those inserts in a single statement:

with new_master as (
  insert into master_table (column_one, column_two, column_tree
  values (1,2,3)
  returning id --&lt;&lt; makes the generated ID available
), new_t1 as (
  insert into table_01 (master_id, some_column, other_column)
  select id, 'some_value', 'other_value'  
  from new_master
), new_t2 as (
  ... as as above
)
insert into table_04 (master_id, some_column)
select id, 'another_value'
from new_master;


You don't really need a stored procedure for that, but you can put the above statement into one if you really want.