I am trying to write a trigger like in the following simplified example: This fails! Only this works: What am I doing wrong? Answer I think you should write a stored procedure with the IF – THEN logic and call that from this trigger. I think triggers support only simple SQL statements, not SPL statement…
Tag: sql
Oracle cascade delete
Is cascade delete on a table more efficient than individual delete statements (executed in a single plsql block) ? Answer What cascade delete does is issue individual delete statements. Examine the following test case: In the trace file, you will find a line like this: That is Oracle issuing a delete statemen…
Update same table as selected with calculated values using resultset
I’m new to sql (scripting). Single CRUD commands are no problem, but I’m trying to create a stored procedure that wil update a table with a calculated value using the results from the same selected table. In the table there is a value with the total vacation-hours for each employee and a value of …
Need to perform ORDER by Twice
I want to sort according to date first and then if date is similar then according to id..How to do that in Informix/HSQL query? Answer A good tutorial on this SQL ORDER BY
Change PostgreSQL columns used in views
I would like PostegreSQL to relax a bit. Every time I want to change a column used in a view, it seems I have to drop the view, change the field and then recreate the view. Can I waive the extra protection and just tell PostgreSQL to let me change the field and then figure out the adjustment to the
Select something that has more/less than x character
Was wondering if it’s possible to select something that has more/less than x characters in SQL. For example, I have an employee table and I want to show all employee names that has more than 4 characters in their name. Here’s an example table Answer If you are using SQL Server, Use the LEN (Length…
Accessing database connection string using app.config in C# winform
I can’t seem to be able to access the app.config database connection string in my c# winforms app. app.config code C# code: When I try the C# code, I get a message: Warning 1 ‘System.Configuration.ConfigurationSettings.AppSettings’ is obsolete: ‘ This method is obsolete, it has been re…
sql getting information, but in wrong order
I have the following query in sql: a1 = the name I need the information in the table to output the names its queried in the order ive asked, so I need 40 to be first then 28 so on on. The reason for this is my code reads the results and stores in an array that then is used
How do I check if a column is empty or null in MySQL?
I have a column in a table which might contain null or empty values. How do I check if a column is empty or null in the rows present in a table? (e.g. null or ” or ‘ ‘ or ‘ ‘ and …)
Generate sequence in SQL Server, poor performance with cross apply
I obtained the following code from the web many years ago and it has served my very well. It is simply a function that generates a sequence of numbers from 1 to whatever you pass in. Basically it’s a way of doing a for loop in a SQL statement. This generally works very well and is fast but I have