sql

updating a table conditionally with values from a group by sub query in oracle

the problem is Update the salary of all the employees by 50% who had worked on 5 or more than 5 projects, by 30% (>= 3 projects), by 20 % (>= 1 projects) the number of project is got by performing a group by query on the EMPLOYEE_PROJECT_HISTORY; i have tried these queries update emp set emp.sal= case when jemp.pcount >=5 then emp.sal...

Date range intersection in SQL

I have a table where each row has a start and stop date-time. These can be arbitrarily short or long spans. I want to query the sum duration of the intersection of all rows with two start and stop date-times. How can you do this in MySQL? Or do you have to select the rows that intersect the query start and stop times, then calculate ...

JDBC Pagination

Hi, I want to implement pagination using JDBC. The actual thing I want to know is "How can i get first 50 and then next 50 records from database for page 1 and 2 respectively" My Query is Select * from data [data table contains 20,000 rows] For page #1 I get 50 records and for page #2 I want to get next 50 records. How can I implement...

Getting ORACLE programming object definitions

Let's say I have an ORACLE schema with contains a package. That package defines types, functions, procedures, etc: CREATE PACKAGE... DECLARE FUNCTION ... PROCEDURE ... END; Is there a query I can execute to get the definitions of those individual objects, without the wrapping package? ...

SQL Server Query Command

Hi, I have an SQL database table, I want to find everything in a table where the 'Room' says 'DISPOSED', Insert 'DISPOSED' into the 'Status' field and then delete the entry in 'Room'. Basically moving the entry from one field to another (if the 'Room' field has 'DISPOSED' in it) Hope this makes sense. Thanks for any help. ...

SQL query: Last but one rank for user

My table structure looks like this: create table rankings ( id IDENTITY NOT NULL, user_id INT NOT NULL, game_poule_id INT NOT NULL, rank INT NOT NULL, insertDate DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (game_poule_id) REFERENCES game_poules(id) ON DELETE CA...

auto incrementing id in sql server

How to auto increment an id in SQL Server whenever a new row is inserted in the table? This id is primary key of the table. ...

Jasper error: Caused by SQLServerException: Transaction (Process ID 58) was deadlocked on thread | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

I got the above error in my jasper report mail. The query that is used in the report is quite complicated (for me). Reading different posts I conclude that to solve this the I have to change the query to SET TRANSACTION ISOLATION LEVEL REPEATABLE READ GO BEGIN TRANSACTION ... my query ... COMMIT TRANSACTION ? I wonder if this is the ...

Copying Primary key to another field in Access.

Hey, I'm struggling to copy the Primary Key to another field in Access. This is irrelevant , but clarifying on what I'm comparing. ... WHERE Tunniste=" & [Tarkiste] & "" Tunniste = Primary Key , Autonumber , ID (Generated by Access.) Tarkiste = This is the field I want to copy it to compare it. I'm open to suggestions, I've already...

Password security; Is this safe?

I asked a question yesterday about password safety... I am new at security... I am using a mysql db, and need to store users passwords there. I have been told in answers that hashing and THEN saving the HASHED value of the password is the correct way of doing this. So basically I want to verify with you guys this is correct now. It i...

Multiple SQL Server Integration Services (SSIS) database instances on one machine

Hi, i want to configured the configuration file to use more than one MSDB database, which are stored in separated database instances in Stored packages of SSIS database. if any body knows let me know ? write in steps how to do..? Regards. kumar ...

Write a sql for updating data based on time

Hello everyone, Because I am new with SQL Server and T-SQL, so I will need your help. I have 2 table: Realtime and EOD. To understand my question, I give example data for 2 tables: ---Realtime table--- Symbol Date Value ABC 1/3/2009 03:05:01 327 // this day is not existed in EOD -> inserting BBC 1/3/2009 03...

SQL Server Command Timeouts Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

Hi there, we've had a ASP.NET web application deployed for a number of years now.... last week we migrated to a slightly slower server to save some money. Now we're frequently getting command timeouts: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding This is understandable...

error occurred when run site

this error occurred when run site Login failed for user 'NT AUTHORITY\NETWORK SERVICE ...

SQL Server Query

Hi, I'm trying to do some work with my SQL table. I have 2 buildings with room numbers 1 - 100 in building 1 and 101 - 199 in building 2. I have a location field (which I've just created) and want to run a query to populate it with either 'Building 1' or 'Building 2' depending on which room number it has in the 'Room' field. Many than...

Is saving an entity with a component collection supposed to do a SQL DELETE then INSERT using NHibernate?

I have an entity, TrackLog that has a component collection of TrackPoints. I create a new TrackLog and add some Trackpoints to it and save it to the DB. When I grab my TrackLog again and add a new TrackPoint, instead of doing one SQL INSERT like I expect, it's doing a DELETE on all the TrackPoints associated with the TrackLog and then r...

JPQL IN clause: Java-Arrays (or Lists, Sets...)?

I would like to load all objects that have a textual tag set to any of a small but arbitrary number of values from our database. The logical way to go about this in SQL would be to build an "IN" clause. JPQL allows for IN, but it seems to require me to specify every single parameter to IN directly (as in, "in (:in1, :in2, :in3)"). Is th...

How can I automatically generate sql update scripts when some data is updated ?

I'd like to automatically generate an update script each time a value is modified in my database. In other words, if a stored procedure, or a query, or whatever updates column a with value b in table c (which as a pk column (i,j...k), I want to generate this : update c set a=b where i=... and j=... and k=... and store it somewhere (fo...

SQL: Using a CASE Statement to update 1000 rows at once

Ok, I would like to use a CASE STATEMENT for this, but I am lost with this. Basically, I need to update a ton of rows, but just on the "position" column. I need to UPDATE all position values that are great than the position value that was removed to position - 1 on a per id_layout and id_layout_position basis. OK, here is a pic of wha...

How to work with CTE. There is some error related to anchor.

I am creating a hierarchy representaion of a column. But an error occurs Details are Msg 240, Level 16, State 1, Line 1 Types don't match between the anchor and the recursive part in column "DISPLAY" of recursive query "CTE". I know there is some typecasting error. But I dont know how to remove error. Please just dont only s...