home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
static1.zip
/
static1.sqc
Wrap
Text File
|
2002-11-18
|
3KB
|
88 lines
/******************************************************************************
**
** Source File Name = static.sqc
**
** Licensed Materials - Property of IBM
**
** (C) COPYRIGHT International Business Machines Corp. 1995, 1999
** All Rights Reserved.
**
** US Government Users Restricted Rights - Use, duplication or
** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
**
**
** PURPOSE: This sample program demonstrates the use of static SQL.
** It will output the entry in the FIRSTNME column where
** the entry in the LASTNAME column equals "JOHNSON".
** Otherwise, an error message is printed.
**
** EXTERNAL DEPENDENCIES :
** - Ensure existence of database for precompile purposes.
** - Precompile with the SQL precompiler (PREP in DB2)
** - Bind to a database (BIND in DB2)
** - Compile and link with the compiler supported on your platform.
**
** For more information about these samples see the README file.
**
** For more information on programming in C, see the:
** - "Programming in C and C++" section of the Application Development Guide
** For more information on building C applications, see the:
** - "Building C Applications" section of the Application Building Guide.
**
** For more information on the SQL language see the SQL Reference.
**
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utilemb.h"
EXEC SQL INCLUDE SQLCA; /* :rk.1:erk. */
int main(int argc, char *argv[])
{ int rc = 0;
char dbAlias[15] ;
char user[15] ;
char pswd[15] ;
EXEC SQL BEGIN DECLARE SECTION; /* :rk.2:erk. */
char firstname[13];
EXEC SQL END DECLARE SECTION;
/* checks the command line arguments */
rc = CmdLineArgsCheck1( argc, argv, dbAlias, user, pswd );
if ( rc != 0 ) return( rc ) ;
printf("\n\nSample C program: STATIC\n");
/* initialize the embedded application */
rc = EmbAppInit( dbAlias, user, pswd);
if ( rc != 0 ) return( rc ) ;
EXEC SQL SELECT FIRSTNME INTO :firstname /* :rk.4:erk. */
FROM employee
WHERE LASTNAME = 'JOHNSON';
EMB_SQL_CHECK("SELECT statement"); /* :rk.5:erk. */
printf( "First name = %s\n", firstname );
/* pmr28801 start */
EXEC SQL SELECT FIRSTNME INTO :firstname
FROM employee
WHERE LASTNAME = 'JOHNSON'
UNION SELECT FIRSTNME FROM employee WHERE LASTNAME = 'JOHNSON';
EMB_SQL_CHECK("pmr28801 no.1");
/* pmr28801 end */
/* terminate the embedded application */
rc = EmbAppTerm( dbAlias);
return( rc ) ;
}
/* end of program : STATIC.SQC */