Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread 3 question on parameters
Sat, Oct 10 2009 7:23 AMPermanent Link

"Sorin H"
Hello

I want to run a parameterised query like:
"SELECT ...WHERE OrderDate BETWEEN DATE TongueromDate AND DATE TongueillDate AND
Type = Tongueype"

1 What should be the value of the params.DataType of the dates parameters on
the TQuery?
2 How to assign a value to the dates parameters (on the right format)?
3.If the pType parameter doesn't have a value, I have to change the where
statement  or there is a better way?

Thanks Sorin

Sat, Oct 10 2009 7:27 AMPermanent Link

"Sorin H"
4th question

Where can I find some help about working with parameters on the ElevateDB
Manager?
I open the parameters list but there i'm stuck.

Thanks Sorin

Sat, Oct 10 2009 10:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin

>1 What should be the value of the params.DataType of the dates parameters on
>the TQuery?

Without testing I'd guess string since that's what you would enter into a statement if you were typing it in full, and you'll probably need QuotedStr to make sure its got the quotes round it

>2 How to assign a value to the dates parameters (on the right format)?

Again a guess query.ParamByName('pFromDate').AsString := QuotedStr(Engine.DateToSQLStr(Date))

>3.If the pType parameter doesn't have a value, I have to change the where
>statement or there is a better way?

You'll have to change the WHERE clause. As it is you'll have a test "Type = NULL" which will cause an exception

Roy Lambert [Team Elevate]
Sat, Oct 10 2009 11:29 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin

>Where can I find some help about working with parameters on the ElevateDB
>Manager?

Tim's brain Smiley

>I open the parameters list but there i'm stuck.

The steps are

1. prepare the query
2. click on the parameter tab if its not the current one
3. click on the parameter you want to set a value for
4. Look down at the bottom. There's a difficult to spot TEdit. Type your parameter in here (including any quotes needed)
5. Set the type using the drop down list to the right of the TEdit
6. Click the little button to the right of the type button and that sets the parameter value

Roy Lambert [Team Elevate]
Sun, Oct 11 2009 3:18 AMPermanent Link

"Sorin H"

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
> The steps are
>
> 1. prepare the query
> 2. click on the parameter tab if its not the current one
> 3. click on the parameter you want to set a value for
> 4. Look down at the bottom. There's a difficult to spot TEdit. Type your
> parameter in here (including any quotes needed)
> 5. Set the type using the drop down list to the right of the TEdit
> 6. Click the little button to the right of the type button and that sets
> the parameter value

Thanks for support Roy

Still something is missing.
I create a new.Sql.
Add the sql statement with the parameters.
Click on Prepare and this raise the #700 error on the first parameter
position.

Sorin

Sun, Oct 11 2009 3:40 AMPermanent Link

"Sorin H"
"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message

> Without testing I'd guess string since that's what you would enter into a
> statement if you were typing it in full, and you'll probably need
> QuotedStr to make sure its got the quotes round it
>
>>2 How to assign a value to the dates parameters (on the right format)?
>
> Again a guess query.ParamByName('pFromDate').AsString :=
> QuotedStr(Engine.DateToSQLStr(Date))

I try with QuotedStr and without but on both cases it raise an error.
Looks like the parameter isn't replaced with the assingned value.

Thanks Sorin

Sun, Oct 11 2009 4:04 AMPermanent Link

Peter
Sorin

It is my understanding that the DATE predicate isn't required for parameterised queries. In my system, a query similar to yours, but without the  
"DATE", works just fine.

select * from Event where EventDate BETWEEN TongueromDate AND TongueillDate

Regards

Peter
Sun, Oct 11 2009 6:07 AMPermanent Link

Uli Becker
Sorin,

> I want to run a parameterised query like:
> "SELECT ...WHERE OrderDate BETWEEN DATE TongueromDate AND DATE TongueillDate AND
> Type = Tongueype"

sql.add('SELECT ...WHERE OrderDate BETWEEN TongueromDate AND TongueillDate');
ParamByName('pFromDate').asDate := MyFromDate;
ParamByName('pTillDate').asDate := MyTillDate;

Uli
Sun, Oct 11 2009 8:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


You're dead right. I've learnt something else. Confusing isn't it Smiley

Roy Lambert
Sun, Oct 11 2009 8:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Sorin


In that case there's something wrong with the sql. Can you post the exact code you're using.

Roy Lambert [Team Elevate]
Page 1 of 2Next Page »
Jump to Page:  1 2
Image