sql

Tossing out certain result rows in a left join

In DB2, using the following left join select a.deptno, a.deptname, b.empno from #dept a left join #emp b on a.deptno = b.workdept on two tables, gets me a list like: dpt name emp ---------------------- A01 ACCOUNTING 5001 A02 PAYROLL NULL A03 OPERATIONS 5003 A03 OPERATIONS 5004 A03 OPERATIONS 5007 A05 MAIN...

print query string in hibernate with parameter values

Hi Is it possible in hibernate to print generated sql queries with real values instead of question marks? How would you suggest to print queries with real values if its not possible with hibernate api? Umar ...

oci_bind_by_name RETURNING INTO truncates value

When I insert a row into a table with 1000+ entries, and attempt to return the row ID (be it from an autoincrement trigger/seq, or from setting the value manually in the insert statement), I get a truncated value: $db = OCILogon(DATABASE_LOGIN, DATABASE_PASSWORD, DATABASE_NAME); $mysqldate = date('Y/m/d G:i:s'); $db_vid_id = 748; $auth...

Adding an ad to a mysql database; Point me in the right direction please...

Currently, I have an 'add your ad here' page, with a form. Now, the user must select what category he will want to post an ad into... So I have a table for each category in mysql. Now my question, how would I make each ad unique, with an ID nr? If I have several tables, the 'auto increment' might turn out to be the same in some ads, a...

which is faster, mysql database with one table or multiple tables?

On my website you can search 'ads' or 'classifieds'. There are different categories. Would the searches be faster with multiple tables, one for each category, or wouldn't it matter? We are talking about around 500 thousand ads. If it won't slow down the search, please explain yourself so that I understand why it won't, because it seem...

SQLite and `Object reference not set` exception

edit2: solution http://stackoverflow.com/questions/1710941/sqlite-and-object-reference-not-set-exception/1711481#1711481 I am having a hard time understanding my error. edit1: I set my define to make my code single threaded. The problem went away. So it seems like a race condition. I get the error below. But not always, i notice that ...

Why Does SQL Update Top apparently reduce locking even when no records are updated?

I have a question about why some SQL (running on SQL Server 2005) is behaving the way it is. Specifically, I made a change to reduce lock contention during an update and it seems to be working in cases I didn't think it would. Original code: We had an update statement like this, that was being applied to a table with more than 3,000,0...

Pulling data from SQL, and writing to a text file.

I am trying to pull data from SQL, and then write it to a text file. This does that, to an extent, but it only pulls 1 from the table, which reads test:test<br> on the text file. I want to be able to pull all the data from the table, and then post to the text file in a list format such as this... test:test test2:test...

optimizing an sql query using inner join and order by

I'm trying to optimize the following query without success. Any idea where it could be indexed to prevent the temporary table and the filesort? EXPLAIN SELECT SQL_NO_CACHE `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 1) AND (`memberships`.`status_code` = 1 A...

How do I specify "close existing connections" in sql script

I'm doing active development on my schema in SQL Server 2008 and frequently want to rerun my drop/create database script. When I run USE [master] GO IF EXISTS (SELECT name FROM sys.databases WHERE name = N'MyDatabase') DROP DATABASE [MyDatabase] GO I often get this error Msg 3702, Level 16, State 4, Line 3 Cannot drop database "My...

Converting Packed COBOL

Hello, I am trying to update a COBOL packed field via a SQL query in a C# application. Currently, the COBOL packed field is being stored in a character column (char(50)) in a MS SQL database. COBOL Data Type = 4 Byte binary number (“PIC S9(9) COMP”): I can use the following statement to extract the data. I am not sure on how to reve...

Wipe data from Oracle DB

I'm running some test to migrate data from one database to another and for that i need to delete and recreate same tables, views and other stuff. So what is the SQL statement(s) in Oracle to wipe everything (delete Tables, Views, Sequences, Functions, Procedures, etc.). I know that I can use "DROP" but sometimes that's not convenient eno...

VBscript and ADO - 3704 Operation is not allowed when the object is closed.

Hi All, This function inserts a row into a SQL database and needs to return the identity number created: Function WriteDatabase(backupTypeID, numImages, folderSize, success, errorMessage, strLogFileName) On Error Resume Next err.clear Set objConnection = CreateObject("ADODB.Connection") Set objRecordSet = CreateObject(...

Create a before delete trigger?

id country_name region area population 1 LASvega Americas 2314 2134562 2 California AMERICAS 10101 2134562 3 Algeria Middle East 24000000 32900000 4 Andorra Europe 468 64000 fire a delete query , just before that this trigger is fired an...

Group Aggregated Data better in SQL or in CODE (in terms of performance)

I would like to ask for opinion on making aggregate data by concatenating strings. If I have a column aggregate but I want to concatenate then in an aggregate column, which is faster in terms of performance? Doing one SQL then just aggregating then in the CODE. Or selecting the main data then querying one at a time. For Example: TABLE_...

Mixing of Group Columns with No Group Columns

Hello. I got this error and Im not sure how to work with it. Simple explanations would be much appreciated. Thanks. Error: There was an SQL error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause - SELECT email, COUNT(*) AS records_found FROM (emails) WHERE email = 'Emai...

almost newbie sql question

can you run ansi sql statements in sql server express 2005 or 2008? ...

3NF Database Normalization

There is a report table for overdue DVD rentals. The store has multiple copies of the same DVD (they are all numbered to be identified). How can I normalize this data to meet 3NF requirements? ...

Is there an ASP.NET full text search system for websites?

We host websites in a shared hosting environment where Microsoft SQL Server full text searching is not allowed. We would love an ASP.NET API that allowed similar functionality to get around this restriction. We can't easily install software on the shared servers, so the API would have to be written in ASP.NET. SQL "like" queries are o...

What is best: several tables or a really big one?

I was wondering about this. Let's say I need to store in a datawarehouse the data for several measures vs time: t | x' ------- 1 | 20 2 | 50 3 | 30 t | x'' ------- 3 | 23 4 | 56 6 | 28 and so on.. t | x''n ------- 5 | 35 6 | 92 7 | 23 If I need to build some large fact table composing the previous data in ways not yet...