Solved

About View In Sql

Posted on 2003-11-13
10
344 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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