Using Parameters

What is a Parameter?

Parameter is a placeholder for a variable that contains a value of some type that is passed to a database server along with the SQL text at the query execution time. Also, parameter can hold values returned by a server after query or stored procedure execution.

You can benefit from using of parameters in the following situations:

Adding Parameters to a Query Text

There are two types of parameters, that you can add to a query text:

  • Named parameter
  • Unnamed parameter

Named Parameters

Parameters are declared using :

For example:

SELECT
  employee.*
FROM
  hr.employee
WHERE
  employee.title = :job AND
  employee.vacation_hours <= :level

:job and :level are parameters in this query.

Unnamed Parameters

Unnamed parameters can be specified as ? symbol.

For example:

SELECT
  employee.*
FROM
  hr.employee
WHERE
  employee.title = ? AND
  employee.vacation_hours <= ?

Modifying Parameter Values and Types

When you run a query that contains parameters with empty values, you will automatically be prompted to initialize them.

To set parameter values and types, click Edit Parameters on the SQL toolbar, or main menu. In the Edit Parameters dialog box, set parameter type, value, and other properties.

Note
When you execute a query with preset parameter values, you will not be automatically prompted to edit them. To edit parameters, press F8 or select Edit Parameters on the SQL toolbar.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for MySQL.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for MySQL?