Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current-Date in SQL Query for DataBase PARADOX

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I whish to know how get Current Date (es. "NOW" working by Interbase DB) in SQL Query working by PARADOX DB(STANDARD) in DELPHI 2.

Thanks you.
 
FraLeCime,

This is not the right forum for Delphi questions. This forum is for questions related to Corel Paradox for Windows, e.g. the client software published by Corel for working with the Paradox table format.

Having said this, here's the text from a file in my archives that I believe you'll find useful:

*--snip--*
Q: How do I pass a variable to a query?

A: First, you must write a query that uses a variable.

Select Test."FName", Test."Salary Of Employee"
From Test
Where Test."Salary of Employee" :val

Note: If you just write the field name as
"Salary of Employee" you will get a Capability Not
Supported error. It must be Test."Salary of Employee".

In this can the variable name is "val", but it can be whatever
you want (of course). Then, you go to the TQuery's params
property and set the "val" parameter to whatever the
appropriate type is. In our example here we will call it an
integer.

Next, you write the code that sets the parameter's value.
We will be setting the value from a TEdit box.

procedure TForm1.Button1Click(Sender: TObject);
begin
with Query1 do
begin
Close;
ParamByName('val').AsInteger := StrToInt(Edit1.Text);
Open;
end;
end;


Note: you may want to place this code in a try..except
block as a safety precaution.

If you want to use a LIKE in your query, you can do
it this way:

Note: This next section uses the customer table from
the \delphi\demos\data directory. It can also be
referenced by using the DBDEMOS alias.

SQL code within the TQuery.SQL property:

SELECT * FROM CUSTOMER
WHERE Company LIKE :CompanyName


Delphi code:

procedure TForm1.Button1Click(Sender: TObject);
begin
with Query1 do
begin
Close;
ParamByName('CompanyName').AsString := Edit1.Text + '%';
Open;
end;
end;

An alternate way of referencing a parameter
(other then ParamByName) is params[TheParameterNumber].

The way that this line:

ParamByName('CompanyName').AsString := Edit1.Text + '%';

can be alternately written is:

Params[0].AsString := Edit1.Text + '%';


The trick to the wildcard is in the concatenating of the
percentage sign at the end of the parameter.
*--snip--*

Please note that I did not write that, though I've forgotten where I originally found it. In your case, you'll want to rework the assignment to the parameter to use the result of Sysutils.Date.

Hope this helps...

-- Lance


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top