0

I have an MS Access query that connects to an Oracle Express database via an ODBC connection.

I've figured out a way to trace the SQL that is sent from MS Access to the ODBC connection. This is what the ODBC SQL looks like (I've formatted it a bit for readability):

SQLExecDirect: 
SELECT 
    "INSP_ID" ,
    "ROAD_ID" ,
    "INSP_DATE" ,
    "CONDITION"  
FROM 
    "USER1"."ROAD_INSP" "b" 
WHERE 
    ("INSP_DATE" = (
            SELECT MAX("a"."INSP_DATE" )  
            FROM "USER1"."ROAD_INSP" "a" 
            WHERE   (("a"."ROAD_ID" = "b"."ROAD_ID" ) 
                AND ("a"."INSP_DATE" BETWEEN  ? AND  ? ))))   <-------- Question marks

As you might have noticed, the last line has question marks instead of values.

This is because the MS Access query prompts the user to enter values via parameter prompts.

Parameters

However, I'm not sure what these question marks are supposed to represent. I know that they originated from the MS Access parameter prompts, but what do they mean to Oracle, and how does Oracle get the parameter values?

User1974
  • 1,517
  • 25
  • 54

1 Answers1

1

This is called a parameterized statement. At the basic level, such a query is executed in two stages: first a query with parameter markers (those question marks) is compiled on the server side, then the actual parameter values are bound to the query and the query is run, returning only results that match the criteria (obviously).

User1974
  • 1,517
  • 25
  • 54
mustaccio
  • 28,207
  • 24
  • 60
  • 76