Executing stored procedures and functions
Dealing with stored procedures and functions is always more complex than usual statements, especially if the procedures contain custom types. The standard library provides the API to deal with these, but the final word of how much the stored procedure calls are supported is in the driver implementation. This recipe will show a very simple function/procedure call.
Getting ready
Verify if Go is properly installed by calling the go version
command in your Terminal. If the command fails, follow the Getting ready section in the first recipe of this chapter.
Set up the PostgreSQL server, as mentioned in the first recipe of this chapter.
How to do it...
- Run the following SQL script against your sample database:
CREATE OR REPLACE FUNCTION format_name (firstname Text,lastname Text,age INT) RETURNS VARCHAR AS $$ BEGIN RETURN trim(firstname) ||' '||trim(lastname) ||' ('||age||')'; END; $$ LANGUAGE plpgsql...