Solved

About View In Sql

Posted on 2003-11-13
10
349 Views
Last Modified: 2013-11-23
How Can I Make A View For My Table Using Sql
And Select Fields From This View From Another Query
0
Comment
Question by:waelolabi
[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
  • 6
  • 4
10 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 9746071
Hi,

If you are talking about MS SQL then:
1. Use CREATE VIEW statement

with ADOQuery1 do begin
  Close;
  SQL.Clear;
  SQL.Add('CREATE VIEW MyView AS');
  SQL.Add('SELECT Field1, Field2 FROM Table1');
  ExecSQL;
end;

2. Use the already created view as regular table

with ADOQuery2 do begin
  Close;
  SQL.Clear;
  SQL.Add('SELECT * FROM MyView');
  Open;
  // do something here
  Close;
end;

Regards, Geo
0
 

Author Comment

by:waelolabi
ID: 9747178
My Dear
I Am Using A Paradox Tabels
So I Am Using BDE Query In My Project
And This Code Did Not Work On BDE Query
And I Have The Following Error Message : "Cabapility Not Support"

What Is The Solution
How Can I Make A View In This Case

And Thanks For Your Help
0
 
LVL 17

Expert Comment

by:geobul
ID: 9747365
Would you explain what you understand as 'view' in paradox? As far as I know there is no such thing. I said that my code above is for MSSQL server.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:waelolabi
ID: 9751932
Hi geobul
Thanks For Your Help
Your Code Is Perfect And Working Very Well In Acsess Database
(Ado Components in Delphi)
But As I Said:
I Am Using Paradox7 Database (BDE Components In Delphi)
And Your Code Is Not Working On This Database

Hope You Understand Me
Waiting Your Reply Please
0
 
LVL 17

Expert Comment

by:geobul
ID: 9753462
Again: Would you explain what you understand as 'view' in paradox? As far as I know there is no such thing.
0
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 9753473
A possible solution could be:

1. using CREATE TABLE statement create a new empty table with the desired structure

CREATE TABLE "MyView.db"
(
  custno NUMERIC(10,2),
  company CHAR(20)
)

2. using INSERT INTO statement with SELECT inside fill that table:

INSERT INTO "MyView.db"
(custno, company)
SELECT custno, company
FROM "customer.db" WHERE custno > 100

3. use MyView as a regular table in another query

4. when you don't need it anymore execute
DROP TABLE "MyView.db"

Regards, Geo
0
 

Author Comment

by:waelolabi
ID: 9776926
Hi geobul
I Will Try You Final Soulution I Hope It Is Ok

About View In Paradox I Meant Using Sql (Creat View Command) on Paradox7 Database Using BDE Component In Delphi6 (Tquery)
Rather Than Ado Component (Tadoquery)
0
 
LVL 17

Expert Comment

by:geobul
ID: 9777045
Hi,

There is no difference whether you'll use TQuery or TADOQuery. The problem is if Paradox supports CREATE VIEW command. I think it doesn't. That's why I proposed creating a new table instead.

Regards, Geo
0
 

Author Comment

by:waelolabi
ID: 9785534
Please What Is Th Name Of The Sql Language That We Use In Delphi
Is It (MsSql, Sql Server ........... etc)
thanks
0
 
LVL 17

Expert Comment

by:geobul
ID: 9789405
If you have MSSQL server then you'll use MS Transact SQL, if you connect to Oracle then you'll use Oracle's SQL etc. Delphi passes SQL statements to the SQL server you are connected to.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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