I would like to write a function/procedure in Postgres with 2 SELECT statements. First I select from table1 and if there is no record matching in table1
then perform the same SELECT on table2
. E.g.
function getRecord(String: inValue){
If (select col1, col2 from table1 where col3=inValue) then
return the row (with col1 and col2);
else
return select col1, col2 from TABLE2 where col3=inValue;
}
Is it possible to have a function like this in PostgreSQL (ver 9.1 and above)?