sql

Type equality test w/ decltype(), auto, or RTTI in C++? Does Boost have something for this?

I'm writing some code to translate a C++ type to an appropriate type for a SQL DB. I want to identify the type, and then depending on what it is, produce the appropriate SQL code. I'm not sure exactly what can be done in this regard by using RTTI, auto, or decltype. I have some ideas but I'm not sure if they're workable. For instance...

How to check if a database exists with ODBC

Hello fellow programmers I have been searching the internet for a few days now and can't find a generic method to solve this with only ODBC and SQL. Is there a way to see if a database already exist, only using ODBC. It has to be standard SQL because the user can chose a DSN of his choice (meaning his own SQL Server). This means I can...

IBDAC / UniDAC + interbase 6 or 7 + a table field named "returning"

Hello there! I am porting REALLY old code to use the UniDAC components. I have hit a wall with a specific UPDATE sql that changes a field named "returning." Simply wrapping the field in quotes does not resolve the issue, because the SQL dialect in the database is 1, which does not support double quote field delimiters. Is there any w...

How to return maxvalue or nullvalue in SQL?

Hello, I'm running requests on an Oracle database. One of my tables contains time slots for Elements and there can be several time slots for the same Element so that the following example is correct : ID ELEMENT_ID BEGIN_DATE END_DATE -------------------------------------------- 1 1 01/01/2007 01/06/2007 2 ...

SQL can you use IF statement in a UDF and how do you do that?

I am trying to create a UDF that does 2 different things depending on the time. Below is my code. I am wondering if you can use the IF statement in a UDF because I am etting 4 errors, incorrect syntax near Begin and Returns and also a Return Statement with return value cannot be used in this context....Any suggestions? SET ANSI_NULLS ON...

Howto add a string to the 'type <filename>' DOS command before merging into file ?

Question: I've several text files containing sql create table/column/view/storedProcedure textfiles. Now I want to merge the textfiles into one textfile. I go into the directory, and type: type *.sql >> allcommands.sql Now to problem is I should add the text ' GO ' after every file's content. I can append Go by doing type *.sql >>...

VBA Transactions

I'm trying to insert some data into SQL from Excel VBA. The SQL commands are built up over the course of the VBA script, and include the use of some SQL variables. I'm trying to understand how transactions work in VBA, and whether they will work with what I need to do, I have the code below that will test this, but it does not work. It ...

Best SQL Option for Performance

I currently need to execute a database query that involves data from three separate tables. (bases,member,sell_transaction) The bases table looks like the following base_id(PK)    name    state The member table looks like the following id(PK)    last_name    username   email    first_name The sell_transaction table has the following s...

uniqueness of composite id with null component

Hi, I am running into problems using unique constraints. The following combinations are allowed A.name B.name foo NULL foo bar foo bar1 foo1 bar It should not be possible to create a new A with same name, only if it has a different B. With the constraints below it is possible to create A.name B.name foo NULL foo ...

sql statement help

ive got a sql query which creates a table for books which stores data now how do i write an sql statement to search the database for books which the number of copies is 15 or less and make it display only the title and price. i know it might seem really easy but ive just start learning sql thanks CREATE TABLE Book ( ISBN CHAR(1...

Parameterized Oracle SQL query in Java?

I've been trying to figure out why the following code is not generating any data in my ResultSet: String sql = "SELECT STUDENT FROM SCHOOL WHERE SCHOOL = ? "; PreparedStatement prepStmt = conn.prepareStatement(sql); prepStmt.setString(1, "Waterloo"); ResultSet rs = prepStmt.executeQuery(); On the other hand, the following runs properl...

SQL problem if two diffrent author have same name in books database

Just wanted to know what would happen if in my book database i had two different authors which have the same name. How could i redesign my database to sort this problem out? Do i have to assign primary and secondary keys or something? By the way this question is related to my previous one. ...

How to do top 1 in Oracle ?

hi how to do this: select top 1 Fname from MyTbl in oracle 11g ? thank's in advance ...

root in tree like structure with auto-referencing foreign keys

Hi. My application uses some kind of "virtual folders" so I need to store the tree structure in the database. The table holding the data is quite simple, it has 3 columns: id_folder (int, primary key) id_parent (int, references id_folder) folder_name (string) My question is: which is the best way to implement the root? Making id_p...

SQL help, selecting specific columns

Hi, I have a nvarchar column which also has non-English (a-z) characters like Crystal77, Bólido Comidas. How can I specifically select the rows which contain non-English characters in that column? Thanks ...

SQL Select With Multiple References to Single Table

I have a SQL DB that contains multiple relational tables. There are some fields in the master table that reference another table multiple times. For example, say I have a database of salesmen who are responsible of sales for multiple states. My database has fields for State1, State2, and State3 all of which map back to a States table....

How to write "WHERE foo = 'bar' OR foo = 'baz' OR ..." without repeating "foo" each time

I'm new to MySQL and was wondering; instead of doing SELECT fields FROM table WHERE name="tim" OR name="bob" OR name="nancy" OR name="john" If I could do something like SELECT fields FROM table WHERE (name="tim" OR "bob" OR "nancy" OR "john") ...

Exclude .LOG file while restoring a database

Hi I have a database backup file (MyDatabase.bak). When restoring the database through SSMS it gives me "Not enough space on disk" message. I looked for an option to exclude .LOG file from restore but could not find one. I even tried to remove the "MOVE .LOG" from restore query but got an error message "could not find .LOG file use WI...

difficulty in creating update totals query on same table.

Consider the following table: ID nonUniqueID value total -------------------------- 1 12345 5 x 2 12345 10 x 3 789 20 x 4 789 5 x I need to make a query something like this (psuedo SQL), which will work within Access 2007: UPDATE table SET total = SUM(value) WHERE nonUniqueID IS SAM...

Ways to join and update tables in SQL.

Hi, So I am a first time user here, and still relatively new to SQL. I am attempting to take 2 tables, and join them in a sense. In Table1 I have the data: House_Key ---Other Fields--- Customer_ID House_Key is not unique, and as such I can have multiple Customer_IDs per household. House_Key is a numerical code, and Customer_ID i...