HPlogo ALLBASE/SQL Reference Manual: HP 9000 Computer Systems > Chapter 10 SQL Statements A - D

Assignment (=)

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The assignment statement is used in a procedure to assign a value to a local variable or procedure parameter.

Scope

Procedures only

SQL Syntax

  {:LocalVariable
   :ProcedureParameter}= Expression;

Parameters

LocalVariable

identifies the local variable to which a value is being assigned. The variable name has a : prefix. Local variables are declared in the procedure definition using the DECLARE statement.

ProcedureParameter

identifies the procedure parameter to which a value is being assigned. The procedure parameter has a : prefix. Parameters are declared in parentheses following the procedure name in the procedure definition.

Expression

identifies an expression whose value is assigned to the local variable. The Expression may include anything that is allowed in an SQL expression except host variables, subqueries, column references, dynamic parameters, aggregate functions, date/time functions involving column references, string functions, TID functions, and long column functions. Local variables, built-in variables, and procedure parameters may be included. See Chapter 8 “Expressions” for more information.

Description

  • Host variables are not allowed anywhere in procedures, including Expressions assigned to local variables or parameters. However, local variables, built-in variables, and parameters may be used in an Expression anywhere a host variable would be allowed in an application program.

  • The data type of the expression result must be compatible with that of the parameter or variable to which it is being assigned.

Authorization

Anyone can use the assignment statement in a procedure definition.

Example

   :msg = 'Vendor number found in "Orders" table.';
   :SalesPrice = :OldPrice;
   :NewPrice = :SalesPrice*.80;
   :nrows = ::sqlerrd2;
Feedback to webmaster