snippet

Dockerfile for dotnet core worker process

In this article we will talk about creating a dotnet core worker process and we will run it in a docker container. This article is divided into two parts, in the first part we will create a simple worker process and in the second part we will write the Dockerfile to containerise it. If you already know about creating workers in dotnetcore feel free to skip the first part. Creating the dotnet core worker processs From your favourite shell, execute the following commands:

Writing A On Update Trigger in Postgresql

The previous [article] ( /posts/writing-a-on-delete-trigger-in-postgresql/) was about deletion trigger. This article is about update triggers. I had two tables what_did_you_eat and what_was_the_type. On insertion into what_did_you_eat, the what_type column was populated with the food type. Now, if I update the value in what column of a row from what_did_you_eat, I would want the corresponding row in what_was_the_type table to be updated too. For example, if we have the following data:

Writing a On Delete Trigger in Postgresql

The previous [article] ( /posts/writing-a-on-insert-trigger-in-postgresql/) was about insertion trigger. I had two tables what_did_you_eat and what_was_the_type. On insertion into what_did_you_eat, the what_type column was populated with the food type. Now, if I delete a row from what_did_you_eat, I would not want a row to remain in what_was_the_type to refer to a non existing row in the what_did_you_eat table. To handle this, I will use the delete trigger. Like before we first write the trigger function.

Writing A On Insert Trigger In Postgresql

Here is a simple example of a on insert postgresql trigger. I have a table called what_did_you_eat. It has the following structure - what will contain what was eaten. I have another table called what_was_the_type with the following structure - I want to store the type of food that was eaten in what_type column. And I want to do this to happen on insert into the what_did_you_eat table. So, off we go to write a trigger.

How To Parse Json In A Stored Procedure In Postgresql

Say we have a table called person with the following structure --------------------------- column| datatype --------------------------- _id | autonumber name | text age | integer --------------------------- We want to insert multiple records into the table using a stored procedure. If we have a stored procedure with say two input variables name and age, then it will take multiple calls. We can do this using a single call if we use a json input and using the json_to_recordset function.

Writing a Postgresql Stored Procedure Returning a Single Value

Say we have a table called person with the following structure --------------------------- column| datatype --------------------------- _id | autonumber name | text age | integer --------------------------- We want to write a stored procedure to return the highest age that we have in the table. We will use OUT param here. CREATE OR REPLACE FUNCTION get_max_age(OUT max_age int) RETURNS int LANGUAGE 'plpgsql' AS $BODY$ BEGIN SELECT MAX(age) INTO max_age FROM person; END $BODY$; That’s it.

Writing a Postgresql Stored Procedure Returning Resultset

Coming from Microsoft SQL Server, I keep on forgetting how to return a resultset from a stored procedure in postgresql. Here is a small sample of how to do it. Needs a bit more code than SQL Server. Note that postgresql does not have stored procedure, they have function. They are equivalent. Say we have a table called person with the following structure --------------------------- column| datatype --------------------------- _id | autonumber name | text age | integer --------------------------- We want to write a stored procedure to return records with age greater than a specified age.