How do you create parameterize SQL commands?

How do you create parameterize SQL commands?

A parameterized query is a query in which at least one of the fields of the WHERE clause is parameterized, The value of the field is specified by a question mark symbol(). For example : The following SQL statement is based on a query on the database in the sample Flight Reservation application :

SELECT Flights.Departure, Flights.Flight_Number, Flights.Day_Of_Week FROM Flights Flights WHERE (Flights.Departure=?) AND (Flights.Day_Of_Week=?)

SELECT defines the columns to include in the query.

FROM specifies the path of the database.

WHERE (optional) specifies the conditions, or filters to use in the query. Departure is the parameter that represents the departure point of a flight.

Day_Of_Week is the parameter that represents the day of the week of a flight.

When creating a database checkpoint, you insert a db_check statement into your test script. When we parameterize the SQL statement in your checkpoint, the db_check function has a fourth, optional, argument: the parameter_array argument. A statement similar to the following is inserted into your test script :

db_check(\"list1.cdl\", \"dbvf1\", NO_LIMIT, dbvf1_params);

The parameter_array argument will contain the values to substitute for the parameters in the parameterized checkpoint.


By:UMANG
Date:2031-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related TESTING Subjective Links

TESTING Subjective interview questions and answers for experienced and fresher