I copied the following example from an SQLite Java library website: I’m struggling to understand the significance of toggling autoCommit() either side of executeBatch(). Does it merely prevent a commit being made for each individual batch operation? Thus a single ‘bulk’ commit is will be mad…
Tag: sql
See whether an item appears more than once in a database column
I want to check if a piece of data appears more than once in a particular column in my table using SQL. Here is my SQL code of what I have so far: salesid is the column I wish to check for, any help would be appreciated, thanks. Answer It should be: Regarding your initial query: You cannot do a
How to make a list of T-SQL results with comma’s between them?
Suppose we have a simple query like this: If we have one record in the result set, I want to set variable @v to that one value. If we have two or more records, I’d like the results to be separated by a comma and a space. What is the best way to write this T-SQL code? Example: result set
Remove duplicate data in ‘date-ranged’ rows
I have a table like the following. The date range is used to know for what time period the rest of the Attributes were valid, the problem i have is that there are several consecutive time ranges where the Attributes ramain the same, what I would like is to obtain the same data but without the duplicate rows. …
0 rows inserted – How can I fix this?
I an trying to INSERT multiple rows into an SQL, Oracle table though SQL Developer v3.0.04 the Database was set-up by Uni so I don’t know what version it is. after looking on-line I have come up with the code below but it will not INSERT any data. I have tested the insert with just one row and that is
How do I create Oracle Type which refers to table columns for data type?
I am trying to define a type using the following code. If I run this, I get the error. What is wrong with this? Answer What’s wrong with it is that %type is PL/SQL syntax. It isn’t supported in SQL. Now we use PL/SQL to define Types (especially member functions, constructors, etc) but the Types th…
How to find which views are using a certain table in SQL Server (2008)?
I have to add a few columns to a table and I also need to add these columns to all the views that use this table. Is it possible to get a list of all the views in a database that use a certain table? Answer This should do it:
MySQL comparison with null value
I have a column called CODE in a MySQL table which can be NULL. Say I have some rows with CODE=’C’ which I want to ignore in my select result set. I can have either CODE=NULL or CODE!=’C’ in my result …
creating a temporary table from a query using sqlalchemy orm
I can create a temporary table this way: but the new table is unreadable because it says it has no primary key. existingtable.id is the primary key of exisitingtable, so I expected it to get the same treatment in the temp table. However, I would rather find some ORM way of doing this anyway. Given: How can I …
java.sql.SQLException: Data truncated for column ‘MonthlyIncome’ at row 1 error
I am trying to update as well as save data to my database using my GUI. My problem is, if i don’t enter any data to certain textboxes which i have allowed null on my database, i get this kind of error: java.sql.SQLException: Data truncated for column ‘MonthlyIncome’ at row 1 Answer Typically…