[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

General SQL-question!

Posted on 1997-08-18
2
Medium Priority
?
182 Views
Last Modified: 2010-04-06
Hi!

I'm building a relational database (Paradox-tables) with about 15 tables that are related to eachother. When I delete a certain product that belongs to a certain customer I want to delete all records in about 10 tables with the following condition:

if (CustomerNumber = '???') AND (ProductNumber = '???') then
  delete the record


I've managed to use the TQuery object to delete the correct records from one table, the problem is how to do it from many tables, preferrably with one single SQL-question.
   The fields "CustomerNumber" and "ProductNumber" are of course present in all the tables.

   How do I solve this? Could you give me an example of what properties I need to set and the exact formulation of the SQL-query, I would be very grateful.

Daniel Persson, Sweden
0
Comment
Question by:Dippen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1341789
Don't know much about SQL, but I would just iterate through all the tables and fire that SQL-query on them.

But maybe this can help. OOPSOFT gives at this moment their SQL editor SQL Express away for free! It's the full version! Though you have to be quick because they offer this only for a limited time. Just look at their site and I hope you'll find your answer there.


0
 
LVL 1

Accepted Solution

by:
Zonnald earned 450 total points
ID: 1341790
If the query is about the same for all tables why not use a string variable to name the table in the 'FROM' clause this way the same query can be used.

Alternatively you can pass the table name in hetrogenious query using the :TABLENAME notation.  Where TABLENAME CONTAINS the string for the table and the : means that this is a parameter assigned to the query component.  
Follow is the help out of DELPHI (3) which discusses the parameters and hetrogenious queries (not important that example is oracle)

Delphi supports heterogeneous queries, queries made against tables in more than one database. A heterogeneous query may join tables on different servers, and even different types of servers. For example, a heterogeneous query might involve a table in a Oracle database, a table in a Sybase database, and a local dBASE table. When you execute a heterogeneous query, the BDE parses and processes the query using Local SQL, so extended, server-specific SQL syntax is not supported.

To perform a heterogeneous query:

1.      Define a BDE standard alias that references a local directory, and set the DatabaseName property of the query component to that alias. To define BDE aliases use the Database Explorer.
2.      Define separate BDE aliases for each database accessed in the query.
3.      Specify the SQL statement to execute in the SQL property. Precede each table name in the SQL statement with the BDE alias for the database where that table can be found.
4.      Set any parameters for the query in the Params property.

5.      Call Prepare to prepare the query for execution prior to executing it for the first time.
6.      Call Open or ExecSQL depending on the type of query to execute.

For example, suppose you define an alias called Oracle1 for an Oracle database that has a CUSTOMER table, and Sybase1 for a Sybase database that has an ORDERS table. A simple query against these two tables would be:

SELECT CUSTOMER.CUSTNO, ORDERS.ORDERNO
FROM ":Oracle1:CUSTOMER", ":Sybase1:ORDERS"
WHERE CUSTNO = 1503
Contains the parameters for a query’s SQL statement.

property Params[Index: Word]TParams;

Description

Access Params at runtime to view and set parameter names, values, and data types dynamically (at design time use the Query Parameters editor to set parameter information). Params is a zero-based array of parameter records. Index specifies the array element to access.

Note

An easier way to set and retrieve parameter values when the name of each parameter is known is to call ParamByName. ParamByName cannot, however, be used to change a parameter’s data type or name.
Parameters used in SELECT statements cannot be NULL, but they can be NULL for UPDATE and INSERT statements.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question