7.5.29 SET DESCRIPTOR

Table of Contents Previous Next


7 Reference : 7.5 ECPGPlus Statements : 7.5.29 SET DESCRIPTOR

Use the SET DESCRIPTOR statement to assign a value to a descriptor area using information provided by the client application in the form of a host variable or an integer value. The statement comes in two forms; the first form is:
EXEC SQL [FOR array_size] SET DESCRIPTOR descriptor_name
VALUE
column_number descriptor_item = host_variable;
EXEC SQL [FOR array_size] SET DESCRIPTOR descriptor_name
COUNT = integer;
array_size is an integer value or a host variable that contains an integer value specifying the number of rows to fetch. If you omit the FOR clause, the statement is executed once for each member of the array.
descriptor_name specifies the name of a descriptor (as a single-quoted string literal), or a host variable that contains the name of a descriptor.
Include the VALUE clause to describe the information stored in the descriptor.
column_number identifies the position of the variable within the descriptor.
descriptor_item specifies the type of the descriptor item.
host_variable specifies the name of the host variable that contains the value of the item.
For example, a client application might prompt a user for a dynamically created query:
To execute a dynamically created query, you must first prepare the query (parsing and validating the syntax of the query), and then describe the input parameters found in the query using the EXEC SQL DESCRIBE INPUT statement.
After describing the query, the query_params descriptor contains information about each parameter required by the query.
Then, you can use EXEC SQL GET DESCRIPTOR to retrieve the name of each parameter. You can also use EXEC SQL GET DESCRIPTOR to retrieve the type of each parameter (along with the number of parameters) from the descriptor, or you can supply each value in the form of a character string and ECPG will convert that string into the required data type.
The data type of the first parameter is numeric; the type of the second parameter is varchar. The name of the first parameter is sal; the name of the second parameter is job.
Use GET DESCRIPTOR to copy the name of the parameter into the param_name host variable:
To associate a value with each parameter, you use the EXEC SQL SET DESCRIPTOR statement. For example:
Now, you can use the EXEC SQL EXECUTE DESCRIPTOR statement to execute the prepared statement on the server.

7 Reference : 7.5 ECPGPlus Statements : 7.5.29 SET DESCRIPTOR

Table of Contents Previous Next