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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a data parameter into a Command SQL statement - how?

Status
Not open for further replies.

mp9

Programmer
Sep 27, 2002
1,379
GB
Hello,

Apologies if this is a simple question. Am running CR10, querying an Oracle database, connected via OLEDB.

Am using a Command in Database Expert, SQL as follows:

SELECT ID_NUMBER, EVENT_TIME FROM ALL_EVENTS

Also have a Parameter Field called StartDate, which a value of type Date.

I want to pass the Parameter through to the Command and since EVENT_TIME is a DateTime field I thought I could try:

SELECT ID_NUMBER, EVENT_TIME FROM ALL_EVENTS
WHERE EVENT_TIME > '{?StartDate}'

which syntactically parses but dosen't return any results... so I'm guessing the '{?StartDate}' is incorrect.

What should the syntax be?

[pc2]
 
you might need to put brackets around your parameter name outside of the quotes

eg ('{?StartDate}')
 
is your event_time field formatted as a date field?

if it is its a long shot but try putting to_date around your parameter

eg to_date(('{?StartDate}'),'DD/MM/YYYY')
 
you could try the to_date without the inner brackets...

to_date('{?StartDate}','DD/MM/YYYY')

but if that dont work i would give up and put the parameter in the record selection
 
Remove the quotes:

SELECT ID_NUMBER, EVENT_TIME
FROM ALL_EVENTS
WHERE EVENT_TIME > {?StartDate}

I'm assuming you are creating the date parameter within the command.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top