Consultor Eletrônico



Kbase P88585: ESQL-92: How to declare and use indicator variables with the INTO clause of a SELECT statement?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/07/2004
Status: Unverified

GOAL:

ESQL-92: How to declare and use indicator variables with the INTO clause of a SELECT statement?

FACT(s) (Environment):

Progress 9.x

FACT(s) (Environment):

OpenEdge 10.x

FIX:

The following sample code from the "Progress Embedded SQL-92 Guide and Reference" shows how to declare and use indicator variables with the INTO clause of a SELECT statement:
/*
** 1. Define host and indicator variables in the DECLARE SECTION
*/
EXEC SQL BEGIN DECLARE SECTION ;
char last_name_v[20];
char email_addr_v[20] ;
long email_i ;
EXEC SQL END DECLARE SECTION ;
/*
** C Language statements here, to set a value for the INOUT host
** variable last_name_v. Typically, accept a string from a user
** interface.
*/
/*
** 2. Execute the SELECT statement with an INTO clause.
*/
EXEC SQL
SELECT email_addr
INTO :email_addr_v INDICATOR:email_i
FROM PERSONNEL
WHERE last_name = :last_name_v ;
/*
** Evaluate the SQLCODE and take appropriate program action.
*/
if (SQLCA.SQLCODE == 0)
/*
** Successful SELECT 3. Evaluate the indicator variable
** 4. Take appropriate program action
*/
{
if (email_i == 0)
printf ("Email address for %s is: %s\n",last_name_v,
email_addr_v) ;
elseif (email_i == -1)
printf ("No email address on record for %s\n", last_name_v) ;
else printf ("Email address for %s too long to process\n",
last_name_v) ;
}
else
/*
** SQL_NOT_FOUND and Error Handling Routines here
*/