Postgresql – Functions

Next i present to you one of my implementions of postgresql function usage.

Generally postgresql functions should be  something like stored procedures from MSSQL. From documenation you can see that the sintaxt is almost the same like MSSQL, but in my opinion it has more flexibility.

I’ve tried to implement the insert, update, delete, select functions who will return a data table for C#.

First you should create an table for testing purposes.

The function for insert is something like this:

For update the function looks like this:

For delete i use only a logical delete  using a flag. It can be modified in order to make an real delete. 🙂

For select i return a cursor in order to be read in the application.

Generally the functions can be called using “SELECT”. In my case i used C# + Npgsql.dll-.Net Data Provider for PostgreSQL.

In C# the calling of the functions is made something like this.

For adding select parameters i’ve created an function for each type of operation (insert,update,delete,select).

I’ve attached all the function in pgsql+the business entity+DAO. I hope that for some of you this classes can be usefull. 🙂

Modify them as you need.

 

Posted in Postgresql.