O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The calling of stored procedures is highly dependent on the driver and the database. Note that retrieving result on PostgreSQL database is very similar to querying tables. The Query or QueryRow method of the DB struct pointer is called, and the resulted rows or row pointer can be parsed to obtain the values.

The MySQL driver uses the CALL statement, if the stored procedure needs to be called.

The general problem for almost all drivers ia the OUTPUT parameters of stored procedures. Go 1.9 added support for such parameters, but the majority of drivers of commonly-used databases do not implement this yet. The solution, then, could be the usage of the driver with a nonstandard API.

The way the OUTPUT params are supposed to work ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required