I really found of Spring Data’s JpaSpecificationExecutor, it allows me to dynamically build queries, depending on the filters applied by user. However, I’ve installed a ZomboDB plugin, and now I need …
Cycling through Table Defs and Deleting
I have a subroutine that runs on a local copy of a database and a network stored master. To allow users to run my Excel add-in offline, I create a local version that has the same table names as the …
Update a column using another column in the same table with two entries (Values) in SQL Server
I’m trying to update a column Product_Group from a column called Product in the same table. This Product column has two entries, Simple or Others. i.e shown below in Invoice table: The issue I’m have is that if you look at Top_Level ID 10, 19, 21 and 31 has multiple entries and the Product are mul…
Grant on dynamic database name in Postgresql
I am trying to grant a new user permissions on the current database (whose name I do not know). Basically I want to archive something like this: Any hints how this could be achieved? Answer You cannot combine GRANTs with queries directly, but you may write a small block to achieve that. Since GRANT allows onl…
Cannot insert the value NULL into column ‘ExampleID’
Upon executing I keep receiving the error: Cannot insert the value NULL into column ‘ExampleID’, table ‘DB_Example.dbo.tbl_Example’; column does not allow nulls. INSERT fails. However I don’t think any NULL values are present. I am trying to simply fill a table with specific valu…
DB2 SQL Return One Row from Left Joined Table Based on Custom Weighting
I have two tables, ‘INVOICES’ contains invoice information and ‘CSEML’ contains customer email addresses. The email address type (field EMLTP) could be designated as ‘AP’ (Accounts Payable), ‘PO’ (…
How to calculate the a third column based on the values of two previous columns?
My sample data is as follows: Table T1: +——+——-+ | Item | Order | +——+——-+ | A | 30 | | B | 3 | | C | 15 | | A | 10 | | B | 2 | | C | 15 | +—–…
How to add a column in MSSQL with default value?
In MSSQL 2014 I would like to use an update syntax which is adding a new column with a default value. Is this possible somehow? Answer Here is a complete reproducible example. Create table Check contents Add new column with default value Check the result Here is a SQL fiddle with this example.
Apply if only on one column on result
This are sample template UserDetails : id,UserName,IsShow Brand : id,BrandName Product : id,ProductName BrandProduct:id,brandid,productid,price If Isshow is false, show entire price else …
PostgreSQL conditional ENUM
Let’s say I have a table inventory with columns item_id, category and size. item_id is auto incremented integer (primary key) category is ENUM size is ENUM I want size to be a conditional ENUM. …