database

Get the Primary Key of a new Entry

I have a number of child tables that have a foreign key to a parent table. How do I add an entry in the parent table and get the primary key of that entry, so that I can then enter rows in the child tables that point to the entry in the parent table? I'm doing this in a MS Access Database from a C# application. ...

How can I dynamically change the Active Record database for all models in Ruby on Rails?

In our program, each customer gets their own database. We e-mail them a link that connects them to their database. The link contains a GUID that lets the program know which database to connect to. How do I dynamically and programatically connect ActiveRecord to the right db? ...

Single-row subqueries in Oracle -- what is the join plan?

I've just discovered that Oracle lets you do the following: SELECT foo.a, (SELECT c FROM bar WHERE foo.a = bar.a) from foo As long as only one row in bar matches any row in foo. The explain plan I get from PL/SQL developer is this: SELECT STATEMENT, GOAL = ALL_ROWS TABLE ACCESS FULL BAR TAB...

Encrypted data base query

I've just found out about stackoverflow.com and just checking if there are ideas for a constraint I'm having with some friends in a project. Although this is more a theoretical question to which I've been trying to find an answer for some time. I'm not much given into cryptography but if I'm not clear enough I'll try to edit/comment to ...

what does "select count(1) from table_name" on any database tables mean

When we execute select count(*) from table_name it returns the number of rows. What does count(1) do? What does 1 signifies over here? Is this same as count(*) as it gives the same result on execution? ...

Quick and dirty way to compare SQL server performance

Further to my previous question about the Optimal RAID setup for SQL server, could anyone suggest a quick and dirty way of benchmarking the database performance on the new and old servers to compare them? Obviously, the proper way would be to monitor our actual usage and set up all sorts of performance counters and capture the queries, e...

ORA-01438: value larger than specified precision allows for this column

We get sometimes the following error from our partner's database: <i>ORA-01438: value larger than specified precision allows for this column</i> The full response looks like the following: <?xml version="1.0" encoding="windows-1251"?> <response> <status_code></status_code> <error_text>ORA-01438: value larger than specified precis...

Help migrating from Visual FoxPro to MySQL

Our company is planning to migrate to VB.net and database to My SQL. (our system and database currently is VFP). We are in outsourcing business and one of our service is installing a program in client's workstation. This program is a clone of our main program that would generate reports for them. We update the data by sending them the db...

Problem opening berkeley db in python

I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work. The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get the following error using bs...

Multiple languages in one database - SQL Server 2005

Hello, We have an application where people can type in multiple langugaes. Though we only have one database to store all the data. We have text columns as nvarchar ( assuming we only want text data to be in multiple languages and not all dates etc.) Do you think this is a feasbile solution and are there any other points to consider bes...

What techniques are most effective for dealing with millions of records?

I once had a MySQL database table containing 25 million records, which made even a simple count(*) query takes minute to execute. I ended up making partitions, separating them into a couple tables. What i'm asking is, is there any pattern or design techniques to handle this kind of problem (huge number of records)? Is MSSQL or Oracle bet...

Tool for Scripting Table Data

Are there any free tools for scripting MSSQL table data? I'll gladly write one, but am hoping it's been done, and the app matured a bit before/ ...

In a layered design with a separate DataAccess layer in .NET where should connection string be managed?

There is a long running habit here where I work that the connection string lives in the web.config, a Sql Connection object is instantiated in a using block with that connection string and passed to the DataObjects constructor (via a CreateInstance Method as the constructor is private). Something like this: using(SqlConnection conn = ne...

SQL Server 2005 Performance: Distinct or full table in WHERE IN statement

Hello, We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType hasMany Documents. (Document.document_type_id = DocumentType.id) We wish to retrieve a list of all document types for one given ShowOn_Id. We see two possiblities: SELECT DocumentType.* FROM DocumentType W...

The ways of Database Integration in SOA/ESB?

Situation: Some Bank has an old legacy ABS (Automatic bank system). Bank wants to: notify old legacy CRM system about client's account changes (Publish operation). check PIN codes of client cards (Request/Response operation) - in synchronious mode. ABS is implemented in very old private technologies with StoredProcedures calls. So,...

Setup Python enviroment on windows

How do I setup a Python enviroment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use? Thanks Sorry I should of mentioned that I am using this for web based applications. Does it require apache? or does it use another http server? What is the standard s...

SQL Server 2000 Live data mirroring

I am currently working with 2 sql 2000 servers one I can query but not add any databases to which lead to the second one having lots of queries that use the first as a linked server. I would like to improve performance while still querying live data. Is it possible to mirror the live data to the second server, that way the queries would...

LinqToSql referenced entities will throw NullReferenceException

I have a very interesting problem on my LinqToSql model. On some of my tables i have a references to other tables and in LinqToSql this is represented by a EnitiyRef class, when you are trying to access the references table LinqToSql will load the reference from the database. On my development machine everything worked fine (the referen...

How to read sql_variant database type in C#

Looking into System.Data.DbType there is no SqlVariant type there. SqlDataReader, for example, provides the GetString method for reading into string variable. What is the appropriate way to retrieve data from the database field of type sql_variant, presumably into object? The aim is to read data stored as sql_variant type in database. ...

Firebird stored procedure solution

Hi, my goal is to write a stored proc that can collect all field values from multiple rows into one single output variable (maybe varchar(some_length)). It may seem strange solution but i've quite positive its the only one i can use at that situation im in. I have not used Firebird before and stored procs look way different than in other...