Solved

About View In Sql

Posted on 2003-11-13
10
348 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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