I read this about the SQL keyword DEFERRABLE in Database Systems – The Complete Book. The latter [NOT DEFERRABLE] is default, and means that every time a database modification statement is executed, the constraint is checked immediately afterwards, if the modification could violate the foreign-key const…
Tag: sql
MySQL INSERT/UPDATE on POINT column
I’m trying to populate my DB with geographical places of my country. One of my tables have 4 fields: ID[PK], latitude. longitude ande geoPoint EDIT `SCDBs`.`Punto_Geografico`; SET @lat = 18.469692; …
SQL query: a stored procedure that receive user ProfileId and get table messages contact list
I need a help with a complicated select query.I have message table CREATE TABLE Message( MessageId int IDENTITY(1,1) NOT NULL, /*primary key*/ FromProfileId int NOT NULL, /*foreign key to …
SQL exception preparing query with ORMLite
I am using an ORM (ORMlite) and all my calls are going well until I get the following error. Exception in thread “main” org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement ” SELECT * …
Calculate business hours between two dates
How can I calculate business hours between two dates? For example we have two dates; 01/01/2010 15:00 and 04/01/2010 12:00 And we have working hours 09:00 to 17:00 in weekdays How can I calculate …
Right query to get the current number of connections in a PostgreSQL DB
Which of the following two is more accurate? Answer Those two requires aren’t equivalent. The equivalent version of the first one would be: In that case, I would expect that version to be slightly faster than the second one, simply because it has fewer rows to count. But you are not likely going to be a…
Map database type to concrete Java class
Background Map a column data type to its corresponding Java class. Problem A query returns meta information from a database: For example, this query returns (the self-referential): Where ‘dictionary’ is the schema name, ‘resource_bundle’ is the object_name, and ‘column_name’…
Freeware Query Builder [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 7 years ago. Improve this question I’m looking for some freeware Query Builder. Query Builder in Aqua…
Eliminate and reduce overlapping date ranges
I have a set of date ranges consisting of both partially and fully overlapping dates, like this: Using T-SQL, I would like to create a new set of data, per user, with eliminated overlapping data, extending ranges and removing redundant data where needed, resulting in something like this: Cursors are fine if n…
Default value not populating in migration with Rails and Postgresql
I am currently trying to run this migration: class AddDroppedProjectsCountToUser < ActiveRecord::Migration def self.up add_column :users, :dropped_projects, :integer, {:default=>0, :…