I mentioned in my previous articles that Postgresql can be written in more than one language, in this article we will be talking about the Postgresql plperl language.
To use the plperl language, you need to make the necessary installations for perl on whichever operating system you are using.
1 2 3 4 5 6 7 8 9 10 11 |
CREATE FUNCTION search_name(employee,text,integer) RETURNS text AS ' my $emp = shift; my $Text = shift; my $Case = shift; if (($Case > 0) && ($emp->{''name''} =~ /\\Q$Text\\E/i)) { return $emp->{''name''}; } elsif ($Case > 0) {return "";} elsif ($emp->{''name''} =~ /\\Q$Text\\E/) { return $emp->{''name''}; } else { return "";} ' LANGUAGE 'plperl'; |