Skip to content

Tag: sql-function

SQL get row count from every table tenantwise

I am working on a multitenant application. Most of the tables contain a column tenant_id. I want the number of rows in all tables for a particular tenant_id. Example, Tables:- Sample result to get number of rows in every table having tenantid = 64 TableName Count Employee 2 Student 3 Teacher 1 How do I loop t…

Why does Postgresql function not work as expected

I have table like this I create get function like this I tried to call function like this but return json all 3 row instead of 1 row with booking_id 1467 can you explain root cause ? Answer The root cause of you problem is naming your parameter (booking_id) the same as a column name (booking_id) in your table…

Passing parameters for a constraint function

I have the following table that joins driver and truck tables in order to assign trucks to drivers. I need to constraint entries that belong to the same driver on the same day, and DO NOT include the same truck code. It was suggested to create a boolean function to pass along dateval, truckval and driverval, …