Table of Contents

Advertisement

Quick Links

HP NonStop SQL/MP
Programming Manual
for C
Abstract
This manual documents the programming interface to HP NonStop™ SQL/MP for C
and is intended for application programmers who are embedding SQL statements and
directives in a C program.
Product Version
NonStop SQL/MP G06 and H01
Supported Release Version Updates (RVUs)
This publication supports J06.03 and all subsequent J-series RVUs, H06.03 and all subse-
quent H-series RVUs, G06.00 and all subsequent G-series RVUs, and D46.00 and all subse-
quent D-series RVUs, until otherwise indicated by its replacement publications.
Part Number
429847-008
Published
August 2012

Advertisement

Table of Contents
loading

Summary of Contents for HP NonStop SQL/MP

  • Page 1 HP NonStop SQL/MP Programming Manual for C Abstract This manual documents the programming interface to HP NonStop™ SQL/MP for C and is intended for application programmers who are embedding SQL statements and directives in a C program. Product Version NonStop SQL/MP G06 and H01 Supported Release Version Updates (RVUs) This publication supports J06.03 and all subsequent J-series RVUs, H06.03 and all subse-...
  • Page 2 429847-002 NonStop SQL/MP G06 December 2003 429847-003 NonStop SQL/MP G06 December 2004 429847-004 NonStop SQL/MP G06 April 2005 429847-005 NonStop SQL/MP G06 February 2006 429847-007 NonStop SQL/MP G06 and H01 August 2010 429847-008 NonStop SQL/MP G06 and H01 August 2012...
  • Page 3: Legal Notices

    Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.
  • Page 5: Table Of Contents

    HP NonStop SQL/MP Programming Manual for C Index Examples Figures Tables Legal Notices What’s New in This Manual Manual Information New and Changed Information About This Manual Who Should Read This Guide Related Manuals Notation Conventions HP Encourages Your Comments xxii 1.
  • Page 6 Simple Example A More Complex Example The Most Complex Example INSERT Statement Inserting a Single Row Inserting a Null Value Inserting a Timestamp Value 4-10 UPDATE Statement 4-10 Updating a Single Row 4-11 HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 7 5-19 SQLSADISPLAY 5-20 6. Explicit Program Compilation Explicit Program Compilation Developing a C Program in the Guardian Environment Using TACL DEFINEs in the Guardian Environment Specifying the SQL Pragma in the Guardian Environment HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 8 Determining Compatibility With the SQL Executor 8. Program Invalidation and Automatic SQL Recompilation Program Invalidation SQL Compiler Validation Functions Causes of Program Invalidation File-Label and Catalog Inconsistencies Preventing Program Invalidation Automatic SQL Recompilation Causes of Automatic Recompilation HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 9 Declare the SQLDA Structure and Names Buffer 10-24 Declare an SQLSA Structure 10-24 Process the Input Parameters 10-24 Read and Compile the SQL Statement 10-25 Process the Output Variables 10-25 Perform the Database Request and Display the Values 10-27 HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 10 CPRL_GETNUMTABLE_ 11-18 CPRL_GETSPECIALTABLE_ 11-19 CPRL_GETUPSHIFTTABLE_ 11-20 CPRL_INFO_ 11-20 CPRL_READOBJECT_ 11-22 CPRL_UPSHIFT_ 11-23 A. SQL/MP Sample Database B. Memory Considerations SQL/MP Internal Structures Using the SQLMEM Pragma Estimating Memory Requirements Avoiding Memory Stack Overflows HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 11 Using Statement and Cursor Host Variables 10-22 Example 10-4. Allocating the SQLDA Structure 10-30 Example 10-5. Allocating Memory for Parameters and Columns 10-32 Example 10-6. Displaying Output 10-34 Example 10-7. Basic Dynamic SQL Program 10-39 HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 12 Table 5-3. SQLCAGETINFOLIST Procedure Error Codes 5-11 Table 5-4. SQLCAGETINFOLIST Procedure Item Codes 5-11 Table 5-5. SQLSADISPLAY Procedure Display Elements 5-22 Table 6-1. C Compilers Table 6-2. Compilation Mode and Execution Environment HP NonStop SQL/MP Programming Manual for C—429847-008 viii...
  • Page 13: Table

    Table B-1. SQL/MP Data Structures Table B-2. Virtual Memory Requirements for SQL Statements Table D-1. Changes to SQL Data Structures Table D-2. Version 2 SQLDA Structure Fields Table D-3. Version 1 SQLDA Structure Fields HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 14 Contents HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 15: December

    Manual Information HP NonStop SQL/MP Programming Manual for C Abstract This manual documents the programming interface to HP NonStop™ SQL/MP for C and is intended for application programmers who are embedding SQL statements and directives in a C program. Product Version...
  • Page 16 Changed the format of short output_file_number under SQLCADISPLAY on pages and 5-20.  Updated the information in Section 6, Explicit Program Compilation with the information from the SQL Supplement for H-series RVUs.  Corrected Example 9-5 on page 9-16. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 17 Corrected coding error on page 10-50 by shifting code from line 374 to 372.  Changed the real memory from 2 KB to 16 KB pages under Estimating Memory Requirements on page B-4. HP NonStop SQL/MP Programming Manual for C—429847-008 xiii...
  • Page 18 What’s New in This Manual Changes in the G06.26 Manual HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 19: Program Development Manuals

    About This Manual This manual describes the NonStop SQL/MP programmatic interface for the HP implementation of the C language. Using this interface, a C program can access a NonStop SQL/MP database using embedded SQL statements and directives. Who Should Read This Guide This manual is intended for application programmers who are embedding SQL statements and directives in a C program.
  • Page 20: Table I. Nonstop Sql/Mp Library

    About This Manual Related Manuals Table i describes the manuals in the HP NonStop SQL/MP library. Table i. NonStop SQL/MP Library Manual Description Introduction to NonStop SQL/MP Introduces the NonStop SQL/MP relational database management system. SQL/MP Reference Manual Describes the NonStop SQL/MP language...
  • Page 21: Figure I. Nonstop Sql/Mp Library

    About This Manual Related Manuals Figure i shows the manuals in the NonStop SQL/MP library. Figure i. NonStop SQL/MP Library Introduction SQL/MP Glossary to NonStop SQL/MP Reference Manuals SQL/MP Guides SQL/MP Reference Messages Manual Manual SQL/MP SQL/MP Version Installation Management...
  • Page 22: Program Development, System And Oss Manuals

    About This Manual Related Manuals In addition to the NonStop SQL/MP library, program development, Guardian, and OSS manuals can be useful to a C programmer. They are shown in Figure ii and described Table Table iii on page xx, and Table iv on page xx.
  • Page 23 Table ii. Program Development Manuals Manual Description C /C++Programmer’s Guide Describes HP extensions to the C and C++ languages, including how to write applications that run in either the Guardian or OSS environments. nld and noft Manual Describes how to use the native link editor (nld) and the native object file tool (noft).
  • Page 24: Notation Conventions

    Lowercase italic letters indicate variable items that you supply. Items not enclosed in brackets are required. For example: #pragma SQL [ option [ ( option [ , option ]... ) ] HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 25 An ellipsis in a programming example indicates that one or more lines of source code have been omitted. #include <cextdecs(SQLCAFSCODE)> short fserr; EXEC SQL INCLUDE SQLCA; fserr = SQLCAFSCODE ((short *) &sqlca); Punctuation. Parentheses, commas, semicolons, and other symbols not previously described must be entered as shown. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 26: Hp Encourages Your Comments

    [ short first_flg ] /* i */ HP Encourages Your Comments HP encourages your comments concerning this document. We are committed to providing documentation that meets your needs. Send any errors found, suggestions for improvement, or compliments to docsfeedback@hp.com. Include the document title, part number, and any comment, error found, or suggestion for improvement you have concerning this document.
  • Page 27: Advantages Of Using Embedded Sql Statements

    Introduction NonStop SQL/MP is the HP relational database management system (RDBMS) that uses SQL to define and manipulate data in an SQL/MP database. You can run SQL statements interactively by using the SQL/MP conversational interface (SQLCI) or programmatically by embedding SQL statements and directives in a host-language program written in COBOL, C, Pascal, or TAL.
  • Page 28: Declaring And Using Host Variables

    (:). In C statements, you do not need the colon, as shown: EXEC SQL SELECT column1 INTO :host_variable1 FROM =table WHERE column1 > :host_variable2; strcpy(new_name, host_variable1); For more information, see Section 2, Host Variables. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 29: Embedding Sql/Mp Statements And Directives

    EXECUTE and EXECUTE IMMEDIATE RELEASE Error Processing WHENEVER Transaction Control BEGIN WORK, COMMIT WORK, and ROLLBACK WORK Precede an embedded SQL statement or directive with the EXEC SQL keywords and terminate it with a semicolon (;). HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 30: Calling Sql/Mp System Procedures

    Section 4, Data Retrieval and Modification. Calling SQL/MP System Procedures NonStop SQL/MP provides system procedures, written in TAL, that perform various SQL operations and functions. For example, the SQLCADISPLAY procedure returns error information from the SQLDA structure after an SQL statement runs.
  • Page 31: Compiling And Executing A Host-Language Program

    Processing Errors, Warnings, and Status Information NonStop SQL/MP returns error and status information to a host-language program after the execution of each embedded SQL statement or directive. NonStop SQL/MP returns an SQL error or warning number to the SQLCODE variable and more extensive information to these SQL data structures: ...
  • Page 32: Dynamic Sql

    INSERT statement in OPERATION. (This program could also have used the PREPARE and EXECUTE statements to compile and run the statement.) For more information, see Section 10, Dynamic SQL Operations. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 33: Sql/Mp Version Management

    SQL/MP Version Management SQL/MP Version Management Each product version update (PVU) of NonStop SQL/MP has an associated version number. The first two PVUs were version 1 (C10 and C20) and version 2 (C30). Version 300 SQL/MP began using a three-digit version number to allow for software product revisions (SPRs).
  • Page 34 Introduction SQL/MP Version Management HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 35: Specifying A Declare Section

    Host Variables A host variable is a data item you can use in both C statements and NonStop SQL/MP statements to allow communication between the two types of statements. A host variable appears as a C identifier and can be any C data item declared in a Declare...
  • Page 36: Host Variables (Continued)

    A name can contain from 1 to 31 alphanumeric characters, including the underscore (_), and must begin with a letter or an underscore. To avoid conflicts with HP names, do not begin your names with two underscores or end them with one underscore. This example uses a Declare Section with host variable names: EXEC SQL BEGIN DECLARE SECTION;...
  • Page 37: Using Corresponding Sql And C Data Types

    The system default multibyte character set; defcharset is KANJI, unless it is otherwise set defcharset or changed during system generation. An extra byte is generated as a place holder for a null terminator. If a character set is not specified, the character set is UNKNOWN. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 38: Table 2-2. Corresponding Sql And C Numeric, Date-Time, And Interval Data Types

    21 (20 plus an extra byte for the null terminator) if a separate sign is used An INTERVAL data type has an extra byte for a sign. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 39: Data Conversion

    NonStop SQL/MP truncates the right part of the longer string and returns a warning code in the SQLCODE variable. If an input value is too large for an SQL column, NonStop SQL/MP returns error 8300 (file system error encountered). If you are using the SQLCADISPLAY procedure to obtain an error message, SQLCADISPLAY also returns file-system error number 1031.
  • Page 40: Specifying Host Variables In Sql Statements

    For values returned to a host variable, indicator_hostvar is –1 if the value is null or 0 if the value is not null. To insert null values into the database, set indicator_hostvar to a value less than zero. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 41: Fixed-Length Character Data

    DATE, TIME, or TIMESTAMP) or INTERVAL data type. If a host variable must contain date-time or INTERVAL values, define it as a character data type. To cause NonStop SQL/MP to handle the host variable as a scaled value, either use the SETSCALE function or define the variable as C data type fixed.
  • Page 42 /* with blanks on the right. void blank_pad(char *buf, size_t size) size_t i; i = strlen(buf); if (i < size) memset(&buf[i], ' ', size - i); void function(void) EXEC SQL BEGIN DECLARE SECTION; HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 43: Variable-Length Character Data

    For example, the structure employee_info contains the empid and empname fields: EXEC SQL BEGIN DECLARE SECTION; struct employee long empid; char empname[21]; } employee_info; EXEC SQL END DECLARE SECTION; HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 44 Structures To use a field as a host variable in an SQL statement, refer to the field by using the structure name: EXEC SQL SELECT empid, empname INTO :employee_info.empid, :employee_info.empname ... ; HP NonStop SQL/MP Programming Manual for C—429847-008 2-10...
  • Page 45: Decimal Data Types

    For more information about C routines, see the C/C++ Programmer’s Guide. Fixed-Point Data Types HP C does not have a data type that maps directly to a fixed-point number (that is, an SQL numeric data type with scale). If you transfer fixed-point values to integral or floating-point host variables, consider these guidelines: ...
  • Page 46 To use SETSCALE in an expression, apply the SETSCALE function to each operand individually rather than to the result of the expression. For example, this expression adds two prices with a scale of 2 decimal places: SETSCALE (:price1, 2) + SETSCALE (:price2, 2) HP NonStop SQL/MP Programming Manual for C—429847-008 2-12...
  • Page 47: Date-Time And Interval Data Types

    DATETIME Represents a date and time from year to microsecond (logical subsets, such as MONTH TO DAY, are allowed) DATE Represents a date and is a synonym for DATETIME YEAR TO DAY HP NonStop SQL/MP Programming Manual for C—429847-008 2-13...
  • Page 48 To communicate date-time or INTERVAL values between C and SQL statements, declare a character array as a host variable and then use the TYPE AS clause to cause NonStop SQL/MP to interpret the value as a date-time or INTERVAL value. For the syntax of the TYPE AS clause, see Specifying Host Variables in SQL Statements on page 2-6.
  • Page 49 The column definition and representation in the table for 36 years, 7 months is: AGE INTERVAL YEAR(2) TO MONTH Sign Year Separator Month Null  The C compiler creates this structure: struct employee_rec char name[21]; char age[7]; HP NonStop SQL/MP Programming Manual for C—429847-008 2-15...
  • Page 50: Example 2-1. Creating Valid Datetime And Interval Data Types

    Start Date: %s", hv_start_date); /* Fetch the next row of the result table. */ EXEC SQL FETCH get_proj INTO :hv_projdesc,:hv_start_date; /* Close the cursor. */ EXEC SQL CLOSE get_proj; return 0; HP NonStop SQL/MP Programming Manual for C—429847-008 2-16...
  • Page 51: Using Indicator Variables For Null Values

    EXEC SQL SELECT ordernum, partnum, unit_price, qty_ordered INTO :odetail.ordernum, :odetail.partnum, :odetail.unit_price INDICATOR :odetail.unit_price_i, :odetail.qty_ordered INDICATOR :odetail.qty_ordered_i, FROM sales.odetail WHERE ordernum = 300380 AND partnum = 2402 ; if ((odetail.unit_price_i < 0) (odetail.qty_ordered_i < 0)) handle_null_value(); HP NonStop SQL/MP Programming Manual for C—429847-008 2-17...
  • Page 52: Retrieving Rows With Null Values

    However, you cannot use an indicator variable set to –1 in a WHERE clause to retrieve a row that contains a null value. In this case, NonStop SQL/MP does not find the row and returns an sqlcode of 100, even if a column actually contains a null value.
  • Page 53: Advantages Of Using An Invoke Directive

    SQL data types and the C structures generated by the INVOKE directive. Example 2-2 on page 2-20 shows the CREATE TABLE statements that generate the tables, and Example 2-3 on page 2-21 shows the structures generated by the INVOKE directives. HP NonStop SQL/MP Programming Manual for C—429847-008 2-19...
  • Page 54: Example 2-2. Create Table Statements

    (10) CHARACTER SET ISO88591 NOT NULL, type_varchar2 VARCHAR (10) CHARACTER SET KANJI NOT NULL, type_picx1 PIC X(10) CHARACTER SET ISO88591 NOT NULL, type_picx2 PIC X(10) CHARACTER SET KANJI NOT NULL CATALOG $SQL.SQLCAT ; HP NonStop SQL/MP Programming Manual for C—429847-008 2-20...
  • Page 55: Example 2-3. Structures Generated By The Invoke Directive

    /* scale is 2 */ decimal type_dec_u[10]; /* scale is 2 */ unsigned long type_pic_s; char type_picx[11]; char type_picx_long[21]; float type_float_15; double type_float_30; float type_real; double type_dbl_prec; char type_datetime[11]; char type_date[11]; HP NonStop SQL/MP Programming Manual for C—429847-008 2-21...
  • Page 56: Using Indicator Variables With The Invoke Directive

    To prevent this problem, use the PREFIX or NULL STRUCTURE clause for column names that are 30 or 31 characters. The format of the indicator variable name depends on the PREFIX, SUFFIX, and NULL STRUCTURE clauses. HP NonStop SQL/MP Programming Manual for C—429847-008 2-22...
  • Page 57 Record Definition for table \SYS.$VOL.SUBVOL.EMPTBL */ Definition current at 16:07:00 - 05/17/94 struct emptbl_rec { unsigned short empnum; struct { short indicator; char valu[16]; } first_name; char last_name[21]; struct { short indicator; char valu[11]; } retire_date; HP NonStop SQL/MP Programming Manual for C—429847-008 2-23...
  • Page 58: Using Invoke With Sqlci

    Associating a Character Set With a Host Variable By default, NonStop SQL/MP associates a single-byte character set with a host variable. To associate a specific character set such as Kanji or KSC5601 with a host variable, include the CHARACTER SET clause in the host variable declaration using...
  • Page 59: Treatment In C Statements

    EXEC SQL SELECT employee_name INTO :emp_name FROM =employee; emp_name.val[emp_name.len] = '\0'; The last C assignment statement sets the null terminator after the SELECT statement returns the employee name from the EMPLOYEE table. HP NonStop SQL/MP Programming Manual for C—429847-008 2-25...
  • Page 60 Host Variables VARCHAR Data Type HP NonStop SQL/MP Programming Manual for C—429847-008 2-26...
  • Page 61: Sql/Mp Statements And Directives

     Finding Information on page 3-3 Embedding SQL Statements Use this syntax to embed a NonStop SQL/MP statement or directive in a C source file. EXEC SQL sql-statement-or-directive ; sql-statement-or-directive is any SQL statement or directive shown in Table 3-1 on page 3-3.
  • Page 62: Placing Statements And Directives

    Data manipulation language (DML) statements  Data control language (DCL) statements  Data definition language (DDL) statements  Data status language (DSL) statements  Transaction control statements  Dynamic SQL statements (including DECLARE CURSOR) HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 63: Finding Information

    INVOKE SQLRM Generates a structure description of a table SQLPM/C or view. *This statement is documented in one or more of these manuals: SQLRM SQL/MP Reference Manual SQLPM/C SQL/MP Programming Manual for C HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 64 SQLPM/C execution for errors, warnings, and the not found condition for rows. *This statement is documented in one or more of these manuals: SQLRM SQL/MP Reference Manual SQLPM/C SQL/MP Programming Manual for C HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 65 UNLOCK TABLE SQLRM Releases locks held on nonaudited tables and views. *This statement is documented in one or more of these manuals: SQLRM SQL/MP Reference Manual SQLPM/C SQL/MP Programming Manual for C HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 66 Deallocates memory for a dynamic SQL statement referred to through a host variable. *This statement is documented in one or more of these manuals: SQLRM SQL/MP Reference Manual SQLPM/C SQL/MP Programming Manual for C HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 67: Table 3-2. C Compiler Pragmas For Sql/Mp

    The native mode C (NMC) compiler on TNS/R systems ignores this pragma. * This statement is documented in one or more of these manuals: C/C++ Programmer’s Guide SQLPM/C SQL/MP Programming Manual for C HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 68 SQL/MP Statements and Directives Finding Information HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 69: Table 4-1. Sql/Mp Statements For Data Retrieval And Modification

    Updates the values in one or more columns in a single row or a set of rows of a table or protection view. Use when you do not need to test a column value in a row before you update the row. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 70: Data Retrieval And Modification

    A program cannot explicitly open an SQL table or view; however, a program can force NonStop SQL/MP to close a table using the CLOSE TABLES option of the FREE RESOURCES statement.
  • Page 71: Recovering From Sql Error 8204

    If the retry is successful, the SQL executor returns a warning (8204) to the program. However, if the retry fails, the SQL executor returns an error (-8204). HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 72: Single-Row Select Statement

    If columns have been added to a table, the retrieved data values might not be in the expected order. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 73: Using A Column Value To Select Data

    Data Retrieval and Modification Using a Column Value to Select Data NonStop SQL/MP returns these values to sqlcode after a SELECT statement: sqlcode Value Description The SELECT statement was successful. No rows qualified for the SELECT statement specification. <0 An error occurred;...
  • Page 74: Using A Primary Key Value To Select Data

    The server fetches the next set of rows from that position. These examples illustrate several ways to define cursors that reposition on a key value. The illustrations start with a simple solution and proceed to increasingly complex solutions. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 75: Simple Example

    WHERE (LAST_NAME, FIRST_NAME) > :LAST_NAME, :FIRST_NAME ORDER BY LAST_NAME, FIRST_NAME If there is an index on the two columns LAST_NAME and FIRST_NAME in that order, this query is probably as efficient as it can be. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 76: Insert Statement

    SELECT statement. For details, see Required Access Authority on page 7-1. NonStop SQL/MP returns these values to sqlcode after an INSERT statement. sqlcode Value Description The INSERT statement was successful.
  • Page 77: Inserting A Single Row

    EXEC SQL INSERT INTO persnl.employee VALUES (:emp.empnum, :emp.first_name, :emp.last_name, :emp.deptnum, :emp.jobcode, :emp.salary INDICATOR :ind_1); This example uses the NULL keyword instead of an indicator variable: EXEC SQL INSERT INTO persnl.employee VALUES (:emp.empnum, :emp.first_name, :emp.last_name, :emp.deptnum, :emp.jobcode, NULL); HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 78: Inserting A Timestamp Value

    Access Authority on page 7-1. For audited tables and views, NonStop SQL/MP holds a lock on an updated row until the TMF transaction is committed or rolled back. For a nonaudited table, NonStop SQL/MP holds the lock until the program releases it.
  • Page 79: Updating A Single Row

    Data Retrieval and Modification Updating a Single Row NonStop SQL/MP returns these values to sqlcode after an UPDATE statement. sqlcode Value Description The UPDATE statement was successful. No rows were found on a search condition. <0 An error occurred; sqlcode contains the error number.
  • Page 80: Updating Multiple Rows

    DROP TABLE statement. (To delete a set of rows, one row at a time using a cursor, see Using SQL Cursors on page 4-14.) HP NonStop SQL/MP Programming Manual for C—429847-008 4-12...
  • Page 81: Deleting A Single Row

    For details, see Required Access Authority on page 7-1. NonStop SQL/MP returns these values to sqlcode after a DELETE statement. sqlcode Value Description The DELETE statement was successful.
  • Page 82: Using Sql Cursors

    • • • /* Process the row values in the host variable(s). */ • • • /* Branch back to fetch another row. */ EXEC SQL CLOSE cursor1 ; /* Close the cursor. */ .CDD HP NonStop SQL/MP Programming Manual for C—429847-008 4-14...
  • Page 83: Steps For Using A Cursor

    SELECT statement (and sqlcode equals 100). 8. Close the cursor using the CLOSE statement. The CLOSE statement releases the result table established by the OPEN statement. (The FREE RESOURCES statement also releases the result table.) HP NonStop SQL/MP Programming Manual for C—429847-008 4-15...
  • Page 84: Process Access Id (Paid) Requirements

    A program can use a cursor whose declaration does not specify FOR UPDATE to locate rows in a table to delete. NonStop SQL/MP tests the table only for read access when the OPEN statement runs. However, because a DELETE operation requires write access, NonStop SQL/MP checks for write access when you run the DELETE statement.
  • Page 85: Cursor Stability

    Cursor Stability Cursor stability guarantees that a row at the current cursor position cannot be modified by another program. For NonStop SQL/MP to guarantee cursor stability, you must declare the cursor with the FOR UPDATE clause or specify the STABLE ACCESS option.
  • Page 86: Declare Cursor Statement

    Follow these guidelines when you use a DECLARE CURSOR statement:  The cursor name specified in the DECLARE CURSOR statement is an SQL identifier and is not case-sensitive. For example, NonStop SQL/MP considers Cur, cur, CUR, and CuR as equivalent names. ...
  • Page 87: Open Statement

    OPEN statement. When the OPEN statement runs, NonStop SQL/MP defines the set of rows in the result table and places the input host variables in its buffers. If you do not initialize the host variables before you run the OPEN statement, these problems can occur: ...
  • Page 88: Fetch Statement

    CURSOR, OPEN, INSERT, DELETE, UPDATE, and CLOSE statements, that refer to the cursor. NonStop SQL/MP resets values in an SQLSA structure immediately before a FETCH statement runs. If you use an SQLSA value elsewhere in your program, save the value in a variable immediately after the FETCH statement runs.
  • Page 89: Multirow Select Statement

    EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE get_name_address CURSOR FOR SELECT custname, street, city, state, postcode FROM =customer WHERE postcode BETWEEN :begin_code AND :end_code ORDER BY postcode REPEATABLE ACCESS; void list_customers(void) HP NonStop SQL/MP Programming Manual for C—429847-008 4-21...
  • Page 90: Update Statement

    PARTS table: EXEC SQL DECLARE get_by_partnum CURSOR FOR SELECT parts.partnum, parts.partdesc, parts.price, parts.qty_available FROM sales.parts WHERE (parts.partnum >= :parts.partnum ) STABLE ACCESS FOR UPDATE OF parts.partdesc, parts.price, parts.qty_available; HP NonStop SQL/MP Programming Manual for C—429847-008 4-22...
  • Page 91: Multirow Delete Statement

    This example declares a cursor get_by_partnum, fetches data from the PARTS table, tests the data, and then deletes specific rows: EXEC SQL DECLARE get_by_partnum CURSOR FOR SELECT partnum, partdesc, price, qty_available HP NonStop SQL/MP Programming Manual for C—429847-008 4-23...
  • Page 92: Close Statement

    Using Foreign Cursors Foreign cursors are cursors that are not declared in the program or procedure in which they are referenced. Only dynamic cursors can be foreign cursors. Static cursors cannot be foreign cursors. HP NonStop SQL/MP Programming Manual for C—429847-008 4-24...
  • Page 93 /* Loop while not EOF: */ void update_inv_total(void) /* describe input and output here */ exec sql open update_inv.list_by_partnum using descriptor input- sqlda; /* describe input and output here */ exec sql fetch update_inv.list_by_partnum using descriptor output-sqlda; HP NonStop SQL/MP Programming Manual for C—429847-008 4-25...
  • Page 94 Data Retrieval and Modification Using Foreign Cursors /* describe input and output here */ exec sql close update_inv.list_by_partnum; HP NonStop SQL/MP Programming Manual for C—429847-008 4-26...
  • Page 95: Sql/Mp System Procedures

    SQL/MP System Procedures Table 5-1 describes the NonStop SQL/MP system procedures, which are written in TAL, that a C program can call to return various SQL information. These procedures are listed alphabetically. Table 5-1. SQL/MP System Procedures Procedure Description To Return Error and Warning Information...
  • Page 96: Guardian System Procedures

    SQL system procedure that returns error or status information (for example, SQLCADISPLAY or SQLCATOBUFFER). The SQLMSG file contains text in English. You can specify a different SQL message file (for example, a file translated into French) with the =_SQL_MSG_node DEFINE. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 97: Sqlcadisplay

    DEFINE before you start the SQLCI session. If you add or change the DEFINE after you start the session, NonStop SQL/MP returns warning message 10201, which indicates that the DEFINE has been changed but the old message file is still in effect.
  • Page 98 By using the file number, the system opens the file only once and uses the file number for subsequent calls. Otherwise, the system opens the file for each call. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 99 SQL statement that received the error: Display the program name and line number. Suppress the display. The default is Y. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 100 *out_fcb_2; } detail_params; specifies whether sequential I/O is used: Use SIO; ignore output_file_number. Do not use SIO; write to output_file_number. out_fcb_1 specifies the first output file control block if SIO is enabled. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 101 Therefore, you might accordingly need to modify your program.  If there is no text for an error number, NonStop SQL/MP displays this message: No error text found. If you receive this message, the version of the SQL message file might be invalid.
  • Page 102: Sqlcafscode

    Nonzero value (or omitted) First error 0 (zero) Last error The default is the first error. This example calls the SQLCAFSCODE procedure: #include <cextdecs(SQLCAFSCODE)> short fserr; EXEC SQL INCLUDE SQLCA; fserr = SQLCAFSCODE ((short *) &sqlca); HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 103: Sqlcagetinfolist

    SQLCAGETINFOLIST SQLCAGETINFOLIST The SQLCAGETINFOLIST procedure returns error or warning information that NonStop SQL/MP sets in the SQLCA structure. You specify a list of numbers, called item codes (shown in Table 5-4 on page 5-11), to specify the error or warning information, and SQLCAGETINFOLIST returns the information to a structure in your program.
  • Page 104 The SQLCA structure has a fixed set of fields (item codes 1 through 21) for errors and warnings. In addition, SQLCA has a table of records (item codes 22 through 29), with each record describing one error or warning. NonStop SQL/MP uses error_index to access this table to determine the error or warning.
  • Page 105: Table 5-3. Sqlcagetinfolist Procedure Error Codes

    Program ID of the program in which the SQL statement appears. Source code line number of the SQL statement that caused an error. Syntax error location. If there was no syntax error, SQL returns -1. HP NonStop SQL/MP Programming Manual for C—429847-008 5-11...
  • Page 106 Suppress printing this error (0 = False, nonzero = True) Offset into the parameters buffer for parameters associated with the call. NonStop SQL/MP returns -1 if there are no parameters. Number of parameters for this error. Sequence in which the error or warning was set.
  • Page 107: Example 5-1. Example Of The Sqlcagetinfolist Procedure

    /* list of item codes item_list_size, /* number of items (short*) &err_warn, /* result area sizeof err_warn, /* size of result area /* no error index needed max_name_len ); /* Truncate names > 30 HP NonStop SQL/MP Programming Manual for C—429847-008 5-13...
  • Page 108: Sqlcatobuffer

    SQLCATOBUFFER The SQLCATOBUFFER procedure writes to a buffer the error or warning messages that NonStop SQL/MP returns to the program. This buffer is a structure declared in variable declarations in the program. The information returned to the buffer can originate from these subsystems or system components: ...
  • Page 109 Otherwise, the system opens the file for each call. The SQLMSG file contains text in English. You can specify a different SQL message file with the =_SQL_MSG_node DEFINE. For more information, see SQL Message File on page 5-2. HP NonStop SQL/MP Programming Manual for C—429847-008 5-15...
  • Page 110 SQL statement that received the error: Write the program name and line number. Suppress the information. The default is Y. HP NonStop SQL/MP Programming Manual for C—429847-008 5-16...
  • Page 111: Internal_Error_Loc

    Therefore, you might need to modify your program accordingly.  If there is no text for an error number, NonStop SQL/MP displays this message: No error text found If you receive this message, the version of the SQL message file might be invalid.
  • Page 112: Sqlgetcatalogversion

    Note. Although version 340 SQL/MP software supports the SQLGETCATALOGVERSION procedure, HP might not support this procedure in a future RVU. If you are running version 300 (or later) SQL/MP software, use the GET VERSION OF CATALOG statement to return the version of a catalog.
  • Page 113: Sqlgetobjectversion

    Note. Although version 340 SQL/MP software supports the SQLGETOBJECTVERSION procedure, HP might not support this procedure in a future RVU. If you are running version 300 (or later) SQL/MP software, use the GET VERSION statement to return the version of an SQL object.
  • Page 114: Sqlsadisplay

    Note. Although version 340 SQL/MP software supports the SQLGETSYSTEMVERSION procedure, HP might not support this procedure in a future RVU. If you are running version 300 (or later) SQL/MP software, use the GET VERSION OF SYSTEM statement to return the version of a system.
  • Page 115: Detail_Params

    If you omit this value or set it to a negative value, SQLSADISPLAY displays information at your home terminal. NonStop SQL/MP ignores this parameter if detail_params specifies sequential I/O (SIO). detail_params determines whether the program uses sequential I/O (SIO) or Enscribe I/O to write to the output file.
  • Page 116: Example 5-2. Example Of The Sqlsadisplay Display

    Example 5-2. Example of the SQLSADISPLAY Display SQL statistics @ \sanfran.$system.accts.prog10.#333.2 process 12,250 Records Records Disc Message Message Lock Table Name Accessed Used Reads Count Bytes \sanfran.$sqlvol.accts.tab10 3245 \sanfran.$vol001.fy96.employee 9987231 99999 \sanfran.$sqlvol.accts.tab20 HP NonStop SQL/MP Programming Manual for C—429847-008 5-22...
  • Page 117: Explicit Program Compilation

    Explicit Program Compilation This section describes the explicit compilation of a NonStop C program containing embedded SQL statements and directives in the Guardian, HP NonStop Open System Services (OSS), and PC host environments using TNS, TNS/R and TNS/E compilation tools.
  • Page 118: Table 6-1. C Compilers

    H-series host compiler for TNS/E The HP Enterprise Toolkit—NonStop Edition (ETK) and PC command line are not supported on D-series systems. Instead, use the native C cross compiler of the Tandem Development Suite (TDS). For more information, see the C/C++ Programmer’s Guide for NonStop Systems.
  • Page 119: Figure 6-1. Explicit Sql Compilation Of A C Program On Tns

    Valid SQL Program File Ready for Execution on TNS, TNS/R, or TNS/E Systems In an OSS environment on a TNS/R system, Steps 2 through 5 can be invoked with the c89 utility. VST003.vsd HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 120: Figure 6-2. Explicit Sql Compilation Of A C Program On Tns/R

    Run the SQL compiler. SQL Program File Valid SQL Program File Ready for Execution on TNS/R Systems Only In an OSS environment, Steps 2 through 4 can be invoked with the c89 utility. VST003R.vsd HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 121: Developing A C Program In The Guardian Environment

    Program Invalidation and Automatic SQL Recompilation. Developing a C Program in the Guardian Environment In the Guardian environment, you can develop a C program to run in either the Guardian or OSS environment. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 122: Using Tacl Defines In The Guardian Environment

    Running the SQL Compiler in the Guardian Environment on page 6-12 for a description of the STOREDDEFINES option. For information about using DEFINEs in the OSS environment, see Developing a C Program in the OSS Environment on page 6-28. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 123: Specifying The Sql Pragma In The Guardian Environment

    SQLMAP | NOSQLMAP specifies whether the compiler listing includes an SQL map. This map enables you to determine SQL statements using output from the Measure program. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 124 SQL source RTDUs. The CPPSOURCE option is not valid with the RELEASE1 option or a macro expansion that contains any part of an SQL statement. This option is intended primarily for use with the Distributed Workbench Facility (DWF). HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 125: Running The Tns C Compiler In The Guardian Environment

    For single-module programs that run in the Guardian environment, specify the RUNNABLE pragma to generate an executable program object file. To direct the TNS C compiler to generate an object file that runs in the OSS environment, specify the SYSTYPE OSS pragma. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 126: Running The Tns/R Nmc And Tns/E Ccomp Compiler In The Guardian Environment

    ZZBInnnn (where nnnn is a unique four-digit number) in your current default volume and subvolume. compiler-option modifies the compiler operation by specifying a compiler pragma or defining a preprocessor symbol as follows: HP NonStop SQL/MP Programming Manual for C—429847-008 6-10...
  • Page 127: Binding Sql Program Files In The Guardian Environment

    Environment pragma is any valid compiler pragma. NonStop SQL/MP supports Tandem floating-point format but not IEEE floating- point format. The floating-point format for TNS/R native compilation is Tandem by default. However, for TNS/E native compilation, the floating-point format is IEEE by default. Follow these guidelines when compiling C programs that contain embedded SQL/MP statements: ...
  • Page 128: Running The Sql Compiler In The Guardian Environment

    SQL object code for each statement, determines an optimized execution plan for each SQL statement against the database, and stores the code and plan in the SQL object program. Optionally, you can invoke the EXPLAIN utility during SQL HP NonStop SQL/MP Programming Manual for C—429847-008 6-12...
  • Page 129: Required Access Authority

    Generates a listing of the SQL statements in the program file, including any warning or error messages that occurred.  Sets the SQL SENSITIVE and SQL VALID flags in the program file label if the compilation is successful. HP NonStop SQL/MP Programming Manual for C—429847-008 6-13...
  • Page 130 SQL compiler directs the listing. list-file can be a disk file name, process name (including a spooler collector), or a device name (including a terminal, magnetic tape unit, or line printer) as follows: HP NonStop SQL/MP Programming Manual for C—429847-008 6-14...
  • Page 131 SQL compiled. (SQLCOMP does not store the settings for the =_DEFAULTS DEFINE in the program file.) STOREDDEFINES applies only to programs that have been SQL compiled. HP NonStop SQL/MP Programming Manual for C—429847-008 6-15...
  • Page 132 SQL compiler produces an SQL program file. OBJECT (the default) directs the compiler to generate an SQL object code, depending on whether errors occur and whether the FORCE or NOFORCE option is in effect. HP NonStop SQL/MP Programming Manual for C—429847-008 6-16...
  • Page 133 REGISTERONLY ON directs the SQL compiler to register a program in the specified catalog without compiling the SQL statements in the program or creating a new program file. The SQL compiler marks the program’s file label as SQL HP NonStop SQL/MP Programming Manual for C—429847-008 6-17...
  • Page 134 310 (or later). If you restore a program using the SQLCOMPILE option, the RESTORE program invokes the recompilation of the program by using the SQLCOMP CHECK option specified during the last explicit SQL compilation. HP NonStop SQL/MP Programming Manual for C—429847-008 6-18...
  • Page 135 During explicit SQL compilation, the CHECK INOPERABLE PLANS option directs the SQL compiler to store similarity information in the program file (even if the similarity check is not enabled for the table or protection view). HP NonStop SQL/MP Programming Manual for C—429847-008 6-19...
  • Page 136 CONTROL directives and DDL statements.) Other SQL statements retain their existing execution plans. The COMPILE INVALID PLANS option stores similarity information in the program file and updates the program’s USAGES tables. HP NonStop SQL/MP Programming Manual for C—429847-008 6-20...
  • Page 137: Using Current Statistics

    Using Current Statistics For the SQL compiler to generate the best execution plan, it must have the current statistics for referenced tables. NonStop SQL/MP does not automatically update these statistics. A program must run the UPDATE STATISTICS statement to generate current statistics in a catalog.
  • Page 138 This PARAM command specifies the $sql.utils.binserv program file and the $sql.scratch subvolume for the subsequent SQLCOMP process: PARAM BINSERV $sql.utils.binserv, SWAPVOL $sql.scratch SQLCOMP /IN cobj,OUT $s.#clst,NOWAIT/ CATALOG $sql.sqlcat For more information about the PARAM command, see the TACL Reference Manual. HP NonStop SQL/MP Programming Manual for C—429847-008 6-22...
  • Page 139 The SQL executor then tries to resolve the problem at run time by automatically recompiling the statement. At run time, the uncompiled statement causes an error in these situations: HP NonStop SQL/MP Programming Manual for C—429847-008 6-23...
  • Page 140: Sql Program File Format

    SQL Source Statement 2 SQL Source Statements Stored by the • C Compiler • • SQL Source Statement n Execution Plans Generated by the SQL Compiler SQL Object Code Including Stored DEFINEs VST004.vsd HP NonStop SQL/MP Programming Manual for C—429847-008 6-24...
  • Page 141: Sql Compiler Listings

    ROLLBACK WORK SQL - SLT Index = 0, Run-Unit = begin BEGIN WORK SQL - SLT Index = 0, Run-Unit = commit_transaction COMMIT WORK SQL - SLT Index = 0, Run-Unit = do_add_to_partloc HP NonStop SQL/MP Programming Manual for C—429847-008 6-25...
  • Page 142 The EXPLAIN utility has these report options:  EXPLAIN PLAN Report on page 6-27  EXPLAIN DEFINES Report on page 6-27 HP NonStop SQL/MP Programming Manual for C—429847-008 6-26...
  • Page 143 This example shows an OBEY command file report. In an actual report, each subvol- name, guardian-name, and define-name would be replaced by the actual name. ALTER DEFINE =_DEFAULTS, VOLUME subvol-name ALTER DEFINE =_DEFAULTS, CATALOG subvol-name ADD DEFINE define-name, FILE guardian-name ADD DEFINE define-name, FILE guardian-name HP NonStop SQL/MP Programming Manual for C—429847-008 6-27...
  • Page 144: Developing A C Program In The Oss Environment

    You can also develop a C program in the Guardian environment that runs in the OSS environment by specifying the SYSTYPE OSS pragma when you compile the program. For more information, see Developing a C Program in the Guardian Environment page 6-5. HP NonStop SQL/MP Programming Manual for C—429847-008 6-28...
  • Page 145: Using Tacl Defines In The Oss Environment

    MAP DEFINE and a class CATALOG DEFINE: add_define =emptab class=map file=\\ny.\$dsk2.fy94.empfile add_define =sqlcat class=catalog subvol=\$sql.sqlcat  System names or the names of volumes where OSS objects reside must be seven characters or fewer. HP NonStop SQL/MP Programming Manual for C—429847-008 6-29...
  • Page 146: Using The C89 Utility In The Oss Environment

    C compiler to compile the pgm1 source file into the pgm1o object file: c89 -c pgm1 NonStop SQL/MP supports Tandem floating-point format but not IEEE floating-point format. The floating-point format for TNS/R native compilation is Tandem by default. However, for TNS/E native compilation, the floating-point format is IEEE by default.
  • Page 147 You can also accelerate a program file by specifying the -O flag when you run the C compiler. For more information about the TNS/R accelerator, see the Accelerator Manual. For more information about the TNS/E accelerator, see the Object Code Accelerator (OCA) Manual. HP NonStop SQL/MP Programming Manual for C—429847-008 6-31...
  • Page 148 The input object file to the SQL compiler can be either an OSS file (code 180) or a Guardian file (code 101). However, if you specify a Guardian file as input, you must use its OSS path name format: /G/volume/subvolume/file-id HP NonStop SQL/MP Programming Manual for C—429847-008 6-32...
  • Page 149 This option instructs the compiler about which security mode must be used while communicating with the NSK host. This option works with compilers supported on windows operating system. For example: c89, and c99. The syntax is: -Wsqlconnect = mode HP NonStop SQL/MP Programming Manual for C—429847-008 6-33...
  • Page 150 For more information about NSK security, see the Security Management Guide. HP_NSK_CONNECT_MODE This environment variable is introduced in H06.25/J06.07 RVU and can be set to any of the following values:  legacy  secure_quiet  secure_warn HP NonStop SQL/MP Programming Manual for C—429847-008 6-34...
  • Page 151: Developing A C Program In A Pc Host Environment

    Developing a C Program in a PC Host Environment You can compile SQL/MP applications on the PC by using either the HP Enterprise Toolkit—NonStop Edition (ETK) or the command-line cross compiler (c89) directly from the command line in Windows. You must connect to an HP NonStop operating system host (TNS/R or TNS/E) for SQL compile time operations and to run an application.
  • Page 152: Static Sql Statements

    CURSOR statement (and in the same RTDU as the DECLARE CURSOR statement).  A dynamic CONTROL directive does not affect static SQL statements in the program except as described under Dynamic SQL Statements on page 6-36. HP NonStop SQL/MP Programming Manual for C—429847-008 6-36...
  • Page 153: Dynamic Sql Statements

    A static CONTROL TABLE directive does not affect dynamic SQL statements. To use a CONTROL TABLE directive with dynamic SQL statements, specify a dynamic CONTROL TABLE directive by using the PREPARE and EXECUTE (or EXECUTE IMMEDIATE) statements. HP NonStop SQL/MP Programming Manual for C—429847-008 6-37...
  • Page 154: Using Compatible Compilation Tools

    SQL executor that can run the program. Generated by the SQL compiler. The oldest version of the SQL catalog in which the program can be registered. Generated by the SQL compiler. HP NonStop SQL/MP Programming Manual for C—429847-008 6-38...
  • Page 155 EXEC SQL EXECUTE dynamic_statement RETURNING :hv_hosv; You cannot, however, use the GET VERSION OF PROGRAM statement with the EXECUTE IMMEDIATE statement. For the syntax of the GET VERSION statement, see the SQL/MP Reference Manual. HP NonStop SQL/MP Programming Manual for C—429847-008 6-39...
  • Page 156 Explicit Program Compilation SQL Program Files HP NonStop SQL/MP Programming Manual for C—429847-008 6-40...
  • Page 157: Program Execution

    ID of the program owner. When a user executes this program, the process uses the privileges of the program owner and accesses only the resources to which the program owner has access. PROGID programs enable one user to HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 158: Using Tacl Defines

    Guardian system procedures. You can also specify the =_SORT_DEFAULTS DEFINE to control sort operations. To determine the DEFINE set used when an SQL program was compiled, use the EXPLAIN DEFINES option of the SQLCOMP command. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 159: Entering The Tacl Run Command

    OSS shell prompt. You can also use the OSS run command to run a program file using HP attributes (for example, a CPU or priority for the process). For information about the run command, see the Open System Services Shell and Utilities Reference Manual or the run (1) reference pages.
  • Page 160: Running A Program At A Low Pin

    A high PIN ranges from 256 through 65,535 (or the maximum number).  PIN 255 is reserved. Figure 7-1 shows various processes running in a processor on an HP NonStop system. Figure 7-1. Processes Running on a NonStop System Processor (CPU) NonStop...
  • Page 161: Interactive Commands

    15 of the create-options parameter set to 1: #include <cextdecs(PROCESS_CREATE_, ...)> error := PROCESS_CREATE_(program_file:length, create_options); Bit 15=1 */ (You can also use the NEWPROCESS or NEWPROCESSNOWAIT procedure, which always forces a new process to run at a low PIN.) HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 162: Pathway Environment

    SET SERVER or ALTER SERVER command. (The default for the HIGHPIN server attribute is OFF.) For more information, see the Guardian Programmer’s Guide. For information about converting a C-series program to use D-series features, see the Guardian Application Conversion Guide. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 163: Determining Compatibility With The Sql Executor

    DETAIL option. For programs registered in version 300 or later catalogs, you can also query the PROGRAMS.PROGRAMFORMATVERSION column. However, for version 300 or later SQL/MP software, HP recommends that you use the GET VERSION OF PROGRAM statement with the FORMAT option. You can enter this statement from SQLCI or in a C program.
  • Page 164 Program Execution Determining Compatibility With the SQL Executor HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 165: Program Invalidation And Automatic Sql Recompilation

    82 and 83. Item code 82 indicates whether the file is an SQL program (1=SQL program, 0=other), and item code 83 indicates whether the program file is valid (1=valid, 0=invalid). HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 166: Causes Of Program Invalidation

    Dropping a partition on a table or index  Dropping an index or constraint on a table  Moving a partition on a table  Enabling or disabling the similarity check for a table or protection view HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 167 Adding an index to a table using the CREATE INDEX statement with the NO INVALIDATE option  Adding or dropping comments on an SQL object  Executing an UPDATE STATISTICS statement with the NO RECOMPILE option specified for a table HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 168: File-Label And Catalog Inconsistencies

    Recompilation File-Label and Catalog Inconsistencies Because NonStop SQL/MP records SQL validity in both the program’s file label and in the PROGRAMS catalog table, inconsistencies can occur. An invalid program file is sometimes recorded as valid in the catalog, or a valid program file is recorded as invalid in the catalog.
  • Page 169: Automatic Sql Recompilation

    Automatic SQL recompilation uses the default volume and catalog settings used for the explicit SQL compilation and the set of DEFINEs in effect at SQL load time (that is, when the SQL executor runs the first SQL statement in the program). HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 170: Causes Of Automatic Recompilation

    To control the automatic recompilation, specify the RECOMPILEALL option (the default) to cause the recompilation of the entire program or the RECOMPILEONDEMAND option to limit the recompilation to statements actually run. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 171 8-8. 1. A valid SQL program named PROG refers to an SQL table named TAB in a SELECT statement. During explicit SQL compilation, NonStop SQL/MP generates an execution plan, which includes the TAB redefinition timestamp, for the SELECT statement and stores the plan in the PROG program file.
  • Page 172: Recompilation (Continued)

     The SQL statement referenced a DEFINE that did not exist during explicit SQL compilation.  The program was explicitly compiled with the SQLCOMP FORCE option, and the SQL statement generated an error. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 173: Run-Time Recompilation Errors

    1. Explicitly compile the program using the CHECK INOPERABLE PLANS option. 2. Enable the similarity check using DDL statements for each table or protection view referenced in the program. (NonStop SQL/MP implicitly enables the similarity check for other SQL objects.) Note.
  • Page 174 You must explicitly enable the similarity check for a table or protection view, including any underlying tables for the view, as shown in these DDL statements. (NonStop SQL/MP implicitly enables the similarity check for other SQL objects.) CREATE TABLE table-name ...
  • Page 175 COMPILE-TIME-TABLE, the CHECK INOPERABLE PLANS option returns SQL warning 4315.)  RUN-TIME-TABLE is the table the program accesses at run time. RUN-TIME-TABLE must have the similarity check enabled for the CHECK HP NonStop SQL/MP Programming Manual for C—429847-008 8-11...
  • Page 176 Comments on columns, constraints, indexes, or tables  Catalog where the table is registered  Help text  Number of columns–RUN-TIME-TABLE can have more columns than COMPILE-TIME-TABLE, but the common columns of both tables must have HP NonStop SQL/MP Programming Manual for C—429847-008 8-12...
  • Page 177 TABLE1 = Fail SELECT DISTINCT * FROM table1 TABLE1 = Pass SELECT COUNT (*) FROM table1 TABLE1 = Pass, SELECT columna FROM table1 WHERE columnb relation-operator TABLE2 = Pass (SELECT COUNT(*) FROM table2) HP NonStop SQL/MP Programming Manual for C—429847-008 8-13...
  • Page 178 In this case, the similarity check fails and the statement is automatically recompiled. HP NonStop SQL/MP Programming Manual for C—429847-008 8-14...
  • Page 179 You do not have to explicitly enable the similarity check for a collation, because collations always have the similarity check implicitly enabled. Two collations are similar only if they are equal. NonStop SQL/MP uses the CPRL_COMPAREOBJECTS_ procedure to compare the two collations. Consequently, two tables that contain character columns associated with collations are similar only if the collations are equal.
  • Page 180 Program Invalidation and Automatic SQL Preventing Automatic Recompilations Recompilation HP NonStop SQL/MP Programming Manual for C—429847-008 8-16...
  • Page 181: Error And Status Reporting

    If the procedure is part of a compilation unit that consists of more than one procedure, place the INCLUDE STRUCTURES directive in the global declarations area or in the declarations area of the first procedure. The directive then applies to all procedures in the compilation unit. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 182 For more information, see the C/C++ Programmer’s Guide.  You must include the SQLGETSYSTEMVERSION procedure declaration from the cextdecs header file in your program, because the option generates a call to this procedure. For example: #include <cextdecs (SQLGETSYSTEMVERSION, ...)> HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 183: Generating Structures With Different Versions

    C compiler in the map at the end of the source-file listing. For example, a version 310 C compiler listing includes this line: Host Object SQL Version = 310 For more information about versions of NonStop SQL/MP, see the SQL/MP Version Management Guide. Sharing Structures Sharing a single SQLCA and SQLSA structure among modules of an object file saves a large amount of memory space.
  • Page 184: Returning Error And Warning Information

    Using the WHENEVER directive  Checking information from the SQLCA structure Checking the sqlcode Variable NonStop SQL/MP returns an error or warning code to sqlcode after the execution of each embedded SQL statement or directive as follows: Value Status Error <...
  • Page 185: Example 9-1. Checking The Sqlcode Variable

    /* The SETSCALE function represents the scale to SQL */ /* Check any for errors and warnings: */ if (sqlcode < 0) handle_errors(); if (sqlcode > 0 && sqlcode != 100) handle_warnings(); /* End of do_sql_insert */ HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 186: Using The Whenever Directive

    EXEC SQL WHENEVER SQLERROR CALL :sql_error; EXEC SQL WHENEVER SQLWARNING CALL :sql_warning; Note. NonStop SQL/MP sometimes returns values other than 100 for a not-found condition. For example, SQL error 8230 indicates that a subquery did not return any rows, and SQL error 8423 indicates that an indicator variable was not specified for a null output value.
  • Page 187 SQL statement instead of using WHENEVER SQLERROR. This example shows how to enable and disable the WHENEVER directive: EXEC SQL WHENEVER SQLERROR CALL :err_func; /* enables checking EXEC SQL WHENEVER SQLERROR; /* disables checking HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 188 GOTO format and disable it at the end of the function. This example enables and disables the WHENEVER directive: void func(void) EXEC SQL WHENEVER SQLERROR GOTO :error_handler; /* error_handler function */ EXEC SQL WHENEVER SQLERROR; /* disable WHENEVER */ HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 189: Example 9-2. Enabling And Disabling The Whenever Directive

    If a host variable receives the null value as the result of an aggregate function, specify a corresponding indicator variable and test the result of the indicator variable. Otherwise, NonStop SQL/MP returns an error specifying that no indicator variable was provided rather than the “not-found” condition. A WHENEVER NOT FOUND directive does not detect this condition.
  • Page 190: Example 9-3. Using The Whenever Directive

    /* Specify WHENEVERs globally for errors and warnings: */ EXEC SQL WHENEVER SQLWARNING CALL :handle_warnings; EXEC SQL WHENEVER SQLERROR CALL :handle_errors; /* Forward declare error handling code: */ void handle_warnings(void); void handle_errors(void); HP NonStop SQL/MP Programming Manual for C—429847-008 9-10...
  • Page 191 INSERT INTO =parts (partnum, price, partdesc) VALUES ( :in_parts_rec.in_partnum, SETSCALE (:in_parts_rec.in_price, 2), :in_parts_rec.in_partdesc); /* End TMF transaction: EXEC SQL COMMIT WORK; void handle_errors(void) SQLCADISPLAY( (short *) &sqlca); exit(EXIT_FAILURE); void handle_warnings(void) warning_sum++; SQLCADISPLAY( (short *)&sqlca,,,,'N','Y'); HP NonStop SQL/MP Programming Manual for C—429847-008 9-11...
  • Page 192: Returning Information From The Sqlca Structure

    Returning Information From the SQLCA Structure Returning Information From the SQLCA Structure NonStop SQL/MP returns run-time information, including errors and warnings, for the most recently run SQL statement to the SQL communications area (SQLCA). The SQLCA structure can contain up to seven error or warning codes (in any combination) that might be returned by a single SQL statement or directive.
  • Page 193: Returning Performance And Statistics Information

    Error and Status Reporting Returning Performance and Statistics Information Returning Performance and Statistics Information NonStop SQL/MP returns performance and statistics information to the SQL statistics area (SQLSA) after the execution of these DML statements:  An INSERT, UPDATE, or DELETE statement ...
  • Page 194: Table 9-4. C Identifiers Generated By The Include Sqlsa Directive

    9-16 shows the layout of a version 330 (or later) SQLSA structure (length is 1790 bytes). (For the version 1 and version 2 SQLSA structures, see Appendix D, Converting C Programs.) HP NonStop SQL/MP Programming Manual for C—429847-008 9-14...
  • Page 195: Example 9-4. Version 300-325 Sqlsa Structure

    } stats[16]; } dml; struct PREPARE_TYPE short input_num; short input_names_len; short output_num; short output_names_len; short name_map_len; short sql_statement_type; long output_collations_len; } prepare; } u; } sqlsa; HP NonStop SQL/MP Programming Manual for C—429847-008 9-15...
  • Page 196: Example 9-5. Version 330 (Or Later) Sqlsa Structure

    } stats[16]; } dml; struct PREPARE_TYPE_R330 short input_num; short input_names_len; short output_num; short output_names_len; short name_map_len; short sql_statement_type; long output_collations_len; } prepare; } u; } sqlsa_r330; HP NonStop SQL/MP Programming Manual for C—429847-008 9-16...
  • Page 197: Table 9-5. Sqlsa Structure Fields

    Identification field. Set eye_catcher to eye_catcher SQLSA_EYE_CATCHER. Current product version of SQLSA. (Subsequent version NonStop SQL/MP PVUs can change this value.) Structure for the return of statistics after the execution of a DML statement. Number of tables accessed by a DML statement; num_tables maximum is 16.
  • Page 198 CONTROL TABLE _SQL_STATEMENT_DCL 7 LOCK, UNLOCK, FREE RESOURCES _SQL_STATEMENT_GET 8 GET VERSION... To use these declarations, copy the sqlh header file using an #include directive. Length of the output collation buffer. output_collations_len HP NonStop SQL/MP Programming Manual for C—429847-008 9-18...
  • Page 199: Dynamic Sql Operations

    SQL statement, and then sends the results back to the PC application. (An example of a server that uses dynamic SQL is the HP NonStop ODBC Server.) HP NonStop SQL/MP Programming Manual for C—429847-008 10-1...
  • Page 200: Dynamic Sql Statements

    CLOSE Closes an SQL cursor and frees the result table defined by the associated SELECT statement. These statements are described following. For the syntax of each statement, see the SQL/MP Reference Manual. HP NonStop SQL/MP Programming Manual for C—429847-008 10-2...
  • Page 201: Dynamic Sql Features

    Dynamic SQL Features Dynamic SQL Features SQLDA Structure, Names Buffer, and Collation Buffer NonStop SQL/MP uses the SQLDA structure to return information about input parameters and output variables in dynamic SQL statements. The SQLDA structure also provides a pointer to these buffers: ...
  • Page 202 Note. Although version 300 (and later) C compilers allow the RELEASE1 and RELEASE2 options, HP might not support these options in a future RVU. If you are using a version 300 (or later) C compiler to generate version 1 or version 2 data structures, replace the RELEASE1 or RELEASE2 option with the VERSION 1 or VERSION 2 option of the INCLUDE STRUCTURES directive.
  • Page 203: Table 10-2. C Identifiers Generated By The Include Sqlda Directive

    Table 10-3. SQLDA Structure Fields (page 1 of 2) Field Name Description An identifying field that a program must initialize. NonStop SQL/MP does eye_catcher not return a value to eye_catcher. Number of input or output parameters the SQLDA structure can contain.
  • Page 204 For input parameters, a program sets the ind_ptr location to –1 if the user entered a null value. For output columns, NonStop SQL/MP sets the ind_ptr location to –1 if the column value is null. A program that does not process null values should set ind_ptr to an invalid address.
  • Page 205: Example 10-1. Sqlda Structure And Buffers

    [collation-buffer-length]; Calculating the Lengths of the Names and Collation Buffers NonStop SQL/MP returns a name to the names buffer as a VARCHAR item. The C compiler determines length in bytes of the names buffer using this formula: length = (name-string-size + 11) * sqlvar-count The 11 bytes added to name-string-size is derived from the length (2 bytes), table name (8 bytes), and period separator (1 byte).
  • Page 206: Table 10-4. Sqlda Data Type Declarations

    SQLDA Structure, Names Buffer, and Collation Buffer Using Declarations for the SQLDA Structure HP provides declarations in the sqlh file that you can use for the SQLDA data_type and precision fields. Use the #include directive to copy these declarations into a C program.
  • Page 207 _SQL_DTINT_MI_S Minute to Second _SQL_DTINT_H_S Hour to Second _SQL_DTINT_D_S Day to Second _SQL_DTINT_F_F Fraction to Fraction _SQL_DTINT_S_F Second to Fraction _SQL_DTINT_MI_F Minute to Fraction _SQL_DTINT_H_F Hour to Fraction _SQL_DTINT_D_F Day to Fraction HP NonStop SQL/MP Programming Manual for C—429847-008 10-9...
  • Page 208: Table 10-5. Sqlda Date-Time And Interval Declarations

    _SQL_DTINT_QUAL_D_S Day to Second _SQL_DTINT_QUAL_D_F Day to Fraction _SQL_DTINT_QUAL_H_MI Hour to Minute _SQL_DTINT_QUAL_H_S Hour to Second _SQL_DTINT_QUAL_H_F Hour to Fraction _SQL_DTINT_QUAL_S_S Second to Second _SQL_DTINT_QUAL_S_F Second to Fraction _SQL_DTINT_QUAL_F_F Fraction to Fraction HP NonStop SQL/MP Programming Manual for C—429847-008 10-10...
  • Page 209: Input Parameters And Output Variables

    COLUMNS.CHARACTERSET. If the character sets do not match, NonStop SQL/MP returns an error. However, if the program expects an unknown character set and the CHARACTERSET value for the parameter or column indicates a single-byte character set, NonStop SQL/MP does not return an error.
  • Page 210 SQLDA structure to get information about the input parameters and obtain pointers to the input values. NonStop SQL/MP returns data to a program through output variables. Output variables are user-specified areas in the program. Output variables can be host variables or individual data buffers to which the program (through the SQLDA structure) contains pointers.
  • Page 211 The value stored in host_var2 is used for the parameter named ?b. If you use three host variables, NonStop SQL/MP uses the value in the first host variable for both occurrences of parameter ?a. The value in the second host variable is used for parameter ?b, and the value in the third host variable remains unused.
  • Page 212 DESCRIBE INPUT or DESCRIBE. After you have set var_ptr to point to the data, you can no longer use var_ptr to access the names buffer and must loop through the names buffer to get the names. HP NonStop SQL/MP Programming Manual for C—429847-008 10-14...
  • Page 213: Example 10-2. Getting Parameter Values

    /* number of bytes of input /* value actually read char *lastchar; /* last character read /* for advancing pointer num_entries = input_sqlda_ptr->num_entries; printf("\nPlease provide values for the input parameters:/n); HP NonStop SQL/MP Programming Manual for C—429847-008 10-15...
  • Page 214: Null Values

    If the parameter or output variable is not null, the var_ptr field specifies the value. HP NonStop SQL/MP Programming Manual for C—429847-008 10-16...
  • Page 215 After DESCRIBE INPUT runs and for each input parameter described in an sqlvar array in the input SQLDA structure, NonStop SQL/MP sets null_info to -1 if the input parameter in the prepared statement allows a null value (that is, if the prepared statement included a null indicator).
  • Page 216: Dynamic Allocation Of Memory

    The XMEM pragma causes the C compiler to use the large-memory model. 2. Declare a template for the SQLDA structure and names buffer using the INCLUDE SQLDA directive. Use a value of 1 for the SQLDA and names buffer sizes and HP NonStop SQL/MP Programming Manual for C—429847-008 10-18...
  • Page 217 6. Allocate space for the required number of SQLDA data structures to describe the parameters and output variables using the malloc function. 7. Allocate space for the values input to the program or output from the database, again using the malloc function. HP NonStop SQL/MP Programming Manual for C—429847-008 10-19...
  • Page 218: Using Dynamic Sql Cursors

    DECLARE CURSOR statement and any DESCRIBE, DESCRIBE INPUT, OPEN, FETCH, and CLOSE statements (for extended dynamic SQL statements, where the cursor and statement names are stored in host variables). Foreign cursors do not have this restriction. HP NonStop SQL/MP Programming Manual for C—429847-008 10-20...
  • Page 219 DECLARE CURSOR, PREPARE, OPEN, FETCH, and CLOSE statements. For each new statement and cursor name, store the name in the host variable before executing the statement. Thus, you code the statements only once. HP NonStop SQL/MP Programming Manual for C—429847-008 10-21...
  • Page 220: Example 10-3. Using Statement And Cursor Host Variables

    EXEC SQL OPEN :cur; EXEC SQL FETCH :cur INTO column host variables; EXEC SQL CLOSE :cur; /* Call a function to display results */ /* End of loop WHILE not EOF */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-22...
  • Page 221: Developing A Dynamic Sql Program

    However, you must declare the error handling functions before you declare the directives. EXEC SQL WHENEVER SQLERROR CALL :handle_error; EXEC SQL WHENEVER SQLWARNING CONTINUE; For more information about the WHENEVER directive, see Section 9, Error and Status Reporting. HP NonStop SQL/MP Programming Manual for C—429847-008 10-23...
  • Page 222: Specify The Include Structures Directive

    NAMES INTO :*input_namesbuf_ptr; 5. Loop through the sqlvar in the input SQLDA structure. Loop n times, where n is the number of parameters from the input_num field. On each iteration of the loop: HP NonStop SQL/MP Programming Manual for C—429847-008 10-24...
  • Page 223: Read And Compile The Sql Statement

    3. Compile the SQL statement using the PREPARE statement: EXEC SQL PREPARE :statement_name FROM :statement_buffer; Process the Output Variables If the output_num field in the SQLSA structure is greater than zero (0) after the PREPARE statement runs, perform these steps: HP NonStop SQL/MP Programming Manual for C—429847-008 10-25...
  • Page 224 6. To show column headings (similar to SQLCI), loop through the names buffer to read the corresponding name for each column and display the column names. HP NonStop SQL/MP Programming Manual for C—429847-008 10-26...
  • Page 225: Perform The Database Request And Display The Values

    1. Begin a TMF transaction: EXEC SQL BEGIN WORK; 2. Run the statement: If there were input parameters: EXEC SQL EXECUTE :statement_name USING DESCRIPTOR :*input_sqlda_ptr; If there were no input parameters: EXEC SQL EXECUTE :statement_name; HP NonStop SQL/MP Programming Manual for C—429847-008 10-27...
  • Page 226 _SQL_STATEMENT_DELETE _SQL_STATEMENT_DDL _SQL_STATEMENT_CONTROL _SQL_STATEMENT_DCL _SQL_STATEMENT_GET A program can use these values to allocate memory for the number of input parameters and output variables, and for the input and output names buffer length. HP NonStop SQL/MP Programming Manual for C—429847-008 10-28...
  • Page 227: Allocate Memory For The Sqlda Structures And Names Buffers

    SQLSA structure. num_input_vars = sqlsa.u.prepare.input_num; if (num_input_vars > 0) allocate_sqlda(num_input_vars); in_nameslen = sqlsa.u.prepare.input_names_len; if (in_nameslen > 0) allocate_namesbuf(in_nameslen); HP NonStop SQL/MP Programming Manual for C—429847-008 10-29...
  • Page 228: Example 10-4. Allocating The Sqlda Structure

    SQL ignores any unused memory. In this call, input_namesbuf_ptr is a pointer to the memory allocated for an input names buffer: typedef char (*arrayptr) [1000]; if (in_nameslen > 0) input_namesbuf_ptr = (arrayptr) malloc(in_nameslen); HP NonStop SQL/MP Programming Manual for C—429847-008 10-30...
  • Page 229 Table 10-4 page 10-8. To include declarations for these literals, use the #include directive to copy the sqlh file. HP NonStop SQL/MP Programming Manual for C—429847-008 10-31...
  • Page 230: Example 10-5. Allocating Memory For Parameters And Columns

    /* Allocate memory for the parameter or column; assign */ /* address to the var_ptr field in the input SQLDA. sqlda_ptr->sqlvar[i].var_ptr=(long) malloc (mem_reqd); } /* end of loop for memory for each parameter value /* or column value return (0); HP NonStop SQL/MP Programming Manual for C—429847-008 10-32...
  • Page 231: Allocate And Fill In Output Variables

    5. Write the value at the location pointed to by the var_ptr field from the SQLVAR array. The steps to use depend on the data type of the value. The sequence just described displays names and values repetitively. For example: EMPNUM 2000 EMPNAME JANE ROBERTS EMPNUM 1566 HP NonStop SQL/MP Programming Manual for C—429847-008 10-33...
  • Page 232: Example 10-6. Displaying Output

    /* Pointer to retrieved data int data_len; /* Data buffer size char name_array[40]; /* Buffer for null terminated column name, in the format tablename.colname + 1 + 30 characters ) char *lastchar; /* Last character read HP NonStop SQL/MP Programming Manual for C—429847-008 10-34...
  • Page 233 /* depending on the data type. /* (For complete code, see sample program.) /* End of SWITCH statement to display values according to data type /* End of loop to process each column HP NonStop SQL/MP Programming Manual for C—429847-008 10-35...
  • Page 234: Developing A Dynamic Sql Pathway Server

    Follow these guidelines to develop a C server that interfaces with Pathway and uses dynamic SQL statements. Except for constructing the SQL statement, these steps are not unique to servers using NonStop SQL/MP. You perform these steps in addition to the tasks you would perform for any dynamic SQL program.
  • Page 235: Dynamic Sql Sample Programs

    To run this program, you need a DEFINE that points to the employee table in the sample database. A complete set of DEFINEs might look like this: SET DEFMODE ON ALTER DEFINE =_DEFAULTS, CATALOG \SYS1.$VOL1.TESTCAT ALTER DEFINE =_DEFAULTS, VOLUME \SYS1.$VOL1.TESTVOL HP NonStop SQL/MP Programming Manual for C—429847-008 10-37...
  • Page 236 Please enter the comparison criteria: (for example: > 500, = 1000, <= 250) > 500 THE AVERAGE SALARY IS: 52250 48> The commented program listing appears in Example 10-7 on page 10-39. HP NonStop SQL/MP Programming Manual for C—429847-008 10-38...
  • Page 237: Example 10-7. Basic Dynamic Sql Program

    /* C differs from Pascal and COBOL in requiring that the /* INCLUDE SQLDA statement appear within a DECLARE section. */ exec sql BEGIN DECLARE SECTION; exec sql INCLUDE SQLDA (osqlda,1) ; exec sql END DECLARE SECTION; /* ------------------------------------------------------- */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-39...
  • Page 238 /* communicate what your variable is like to SQL; you /* might want to look at the data_type field and adjust /* Here, we're just putting it into a LONG and ignoring /* scale. HP NonStop SQL/MP Programming Manual for C—429847-008 10-40...
  • Page 239 -- to find average salary based on job code\n"); printf("3 -- to find average salary based on department number\n\n"); fgets(temp, (int)sizeof(temp), stdin); sscanf(temp, "%d", &sel_index); /* Initialize column and predicate to blanks: memset(column, ' ', 9); memset(predicate, ' ', 10); HP NonStop SQL/MP Programming Manual for C—429847-008 10-41...
  • Page 240: Detailed Dynamic Sql Program

    Declares an SQLDA to describe input parameters and another to describe output variables. Because the program is allocating memory at run time, the SQLDA is declared as a template and allocated dynamically when the query is run. HP NonStop SQL/MP Programming Manual for C—429847-008 10-42...
  • Page 241 ORDERS.ORDERNUM 300350 ORDERS.CUSTNUM 543 ORDERS.ORDERNUM 800660 ORDERS.CUSTNUM 3210 ORDERS.ORDERNUM 400410 ORDERS.CUSTNUM 7654 --- 4 row(s) selected. Enter SQL statement or SAME to reuse last statement or END: >>end; End of current session 34> HP NonStop SQL/MP Programming Manual for C—429847-008 10-43...
  • Page 242: Example 10-8. Detailed Dynamic Sql Program

    /* memory for: /* sizeof( struct SQLDA_TYPE ) + /* (num_sqlda_entries - 1) * sizeof( struct SQLVAR_TYPE ) /* ----------------------------------------------------------- */ exec sql include sqlda (dummy_da, 1, dummy_names, 1); typedef struct SQLDA_TYPE *sqldaptr; HP NonStop SQL/MP Programming Manual for C—429847-008 10-44...
  • Page 243: Detailed Dynamic Sql Program

    /* and we want to reference it as type char in the function /* prototype /* ----------------------------------------------------------------- */ /* Terminator character when requesting input param values (EOL) /* ----------------------------------------------------------------- */ #define PARAM_TERMINATOR (char) '\n' HP NonStop SQL/MP Programming Manual for C—429847-008 10-45...
  • Page 244 = *len_ptr; nb += 2; /* advance nb to skip the /* 2-byte length prefix /* get null terminated name in name_array */ if (name_len == 0) strcpy(name_array, "(EXPR)"); /* default name else HP NonStop SQL/MP Programming Manual for C—429847-008 10-46...
  • Page 245 ( *len_ptr <= 38) { if ( *len_ptr != 0 ) /* filter zero length */ strncpy( data_array, data_ptr, *len_ptr ); data_array[ *len_ptr ] = '\0'; printf( "%-40s %s\n", name_array, data_array ); fflush (stdout); else HP NonStop SQL/MP Programming Manual for C—429847-008 10-47...
  • Page 246 /* ------------------------------------------------- */ } /* end: switch stmt */ } /* end: for loop */ /* place a space line */ printf("\n"); fflush( stdout ); return (0); } /* end: display_result */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-48...
  • Page 247 { printf("**** Error: Param name is too long. Try again.\n"); fflush( stdout ); return (-1); /* get null terminated param name in name_array */ if (name_len == 0) name_array[0] = '\0'; /* unnamed param */ else HP NonStop SQL/MP Programming Manual for C—429847-008 10-49...
  • Page 248 ( ( data_read = get_string( in_out_ptrs.char_ptr, data_len, 0, PARAM_TERMINATOR )) < 0 ) { /* input info too long; or some problem */ printf("\n**** Error: Input data is too long.\n"); fflush(stdout); return (-1); HP NonStop SQL/MP Programming Manual for C—429847-008 10-50...
  • Page 249 /* 32 bit unsigned numeric */ in_out_ptrs.uinteger_ptr = (unsigned long *) sqlda->sqlvar[i].var_ptr; dummy = NULL; *in_out_ptrs.uinteger_ptr = strtoul (data_array, &dummy, 10); break; /* ------------------------------------------- */ } /* end: inner switch */ break; HP NonStop SQL/MP Programming Manual for C—429847-008 10-51...
  • Page 250 "UNSIGNED 16BIT NUMERIC" ); break; /* ------------------------------------------------------- */ case _SQLDT_32BIT_S : /* 32 bit signed binary strcpy( datatype_name, "SIGNED 32BIT NUMERIC" ); break; /* ------------------------------------------------------- */ case _SQLDT_32BIT_U : /* 32 bit unsigned binary */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-52...
  • Page 251 "TRAILING SIGN EMBEDDED DECIMAL" ); break; /* ------------------------------------------------------- */ default: strcpy( datatype_name, "UNEXPECTED" ); break; /* ------------------------------------------------------- */ } /* end: switch */ return (datatype_name); } /* end get_dtname */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-53...
  • Page 252 /* at while-loop exit break; else { while ( (c = getchar()) != '\n' ) { /* consume the input */ } return (-1); /* array too small else /* null termination rqsted */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-54...
  • Page 253 { printf("**** Error: Input query is too long.\n"); fflush( stdout ); goto try_again; if ( ( strncmp(host1, "E", 1) == 0 ) || ( strncmp(host1, "e", 1) == 0 ) ) return (-1); HP NonStop SQL/MP Programming Manual for C—429847-008 10-55...
  • Page 254 _SQLDT_16BIT_U : /* UNSIGNED SMALLINT */ case _SQLDT_32BIT_S : /* INTEGER case _SQLDT_32BIT_U : /* UNSIGNED INTEGER case _SQLDT_64BIT_S : /* SIGNED LARGEINT /*--------------------------------------------*/ /* set scale information to 0 */ /*--------------------------------------------*/ HP NonStop SQL/MP Programming Manual for C—429847-008 10-56...
  • Page 255 /* data types to the nearest equivalent data types /* and by setting scale information to 0 /* sqlda.num_entries is assumed to have a valid value. */ /* Return: 0 if successful /* -1 if failure HP NonStop SQL/MP Programming Manual for C—429847-008 10-57...
  • Page 256 /*--------------------------------------------*/ /* Extract length from bits 8:15 /*--------------------------------------------*/ mem_reqd = sqlda->sqlvar[i].data_len & 0377; break; /* ---------------------------------------------------- */ default: /* UNSUPPORTED types printf( "\n**** Error: Unsupported Datatype: %s\n", get_dtname( sqlda->sqlvar[i].data_type )); return (-1); HP NonStop SQL/MP Programming Manual for C—429847-008 10-58...
  • Page 257 /* initialized, even when the program does not handle null */ /* values */ for (i=0; i < num_entries; i++) sqlda -> sqlvar[i].ind_ptr = NULL; return (sqlda); /* successful allocation and init. */ } /* end allocate_sqlda */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-59...
  • Page 258 ( (char *) cname_o ); /* free o/p names buffer 1027 1028 cname_i = cname_o = NULL; /* init pointers */ 1029 1030 } /* cleanup */ 1031 1032 main () 1033 HP NonStop SQL/MP Programming Manual for C—429847-008 10-60...
  • Page 259 1086 1087 /***************************************************************/ 1088 /* Allocate input and output sqlda and names buffers 1089 /***************************************************************/ 1090 out_numvars = sqlsa.u.prepare.output_num; 1091 out_nameslen = sqlsa.u.prepare.output_names_len; 1092 in_numvars = sqlsa.u.prepare.input_num; 1093 in_nameslen = sqlsa.u.prepare.input_names_len; 1094 HP NonStop SQL/MP Programming Manual for C—429847-008 10-61...
  • Page 260 ("\n"); fflush( stdout ); 1150 SQLCADISPLAY ( (int *) &sqlca ); 1151 if (sqlcode < 0) /* errors present 1152 1153 exec sql rollback work; /* abort transaction */ 1154 goto enter_input; /* try again HP NonStop SQL/MP Programming Manual for C—429847-008 10-62...
  • Page 261 1204 goto enter_input; 1205 1206 1207 } /* if out_numvars > 0 */ 1208 1209 if (out_numvars > 0) 1210 { /*************************************************/ 1211 /* SELECT statement 1212 /*************************************************/ 1213 HP NonStop SQL/MP Programming Manual for C—429847-008 10-63...
  • Page 262 1264 1265 } /* while loop */ 1266 1267 /* ----------------------------------------------------------- */ 1268 /* FETCH error. Close cursor. Get next request */ 1269 /* ----------------------------------------------------------- */ 1270 if (sqlcode < 0) 1271 HP NonStop SQL/MP Programming Manual for C—429847-008 10-64...
  • Page 263 /* Process next query 1313 /* ----------------------------------------------------- */ 1314 exec sql commit work; 1315 1316 goto enter_input; 1317 1318 exit: 1319 printf("\nEnd of current session\n"); 1320 fflush (stdout); 1321 } /* end of main */ HP NonStop SQL/MP Programming Manual for C—429847-008 10-65...
  • Page 264 Dynamic SQL Operations Detailed Dynamic SQL Program HP NonStop SQL/MP Programming Manual for C—429847-008 10-66...
  • Page 265: Character Processing Rules (Cprl) Procedures

    A C program can call character processing rules (CPRL) procedures to process these collation objects:  SQL collation––A NonStop SQL/MP object with file code 941 generated by the CREATE COLLATION statement  Collation object––A Guardian file with file code 199 generated by the...
  • Page 266: Cextdecs Header File

    All other CPRL return codes are negative, so they can be distinguished from file-system errors, which are always positive. The condition code (CC) setting has no meaning after the execution of a CPRL procedure. HP NonStop SQL/MP Programming Manual for C—429847-008 11-2...
  • Page 267: Cprl_Are

    HP NonStop SQL/MP Programming Manual for C—429847-008 11-3...
  • Page 268: Cprl_Arealphas

    The input string contains a character not in the specified character class. inputstring is an array containing the string to be scanned. inputstringlength is the number of bytes to be scanned in inputstring. HP NonStop SQL/MP Programming Manual for C—429847-008 11-4...
  • Page 269: Cprl_Arenumerics

    The input string contains a character not in the specified character class. inputstring is an array containing the data to be scanned. inputstringlength is the number of bytes in inputstring to be scanned. HP NonStop SQL/MP Programming Manual for C—429847-008 11-5...
  • Page 270: Cprl_Compare1Encoded

    –4 The version of the SQL collation or collation object is not supported. string1 is an array containing the first string to be compared. string1 is assumed to be in encoded form. HP NonStop SQL/MP Programming Manual for C—429847-008 11-6...
  • Page 271: Cprl_Compare

    CPRL_COMPARE_ ( char *string1 /* i */ ,short string1length /* i */ ,char *string2 /* i */ ,short string2length /* i */ ,short *result /* o */ ,long cprladdr ); /* i */ HP NonStop SQL/MP Programming Manual for C—429847-008 11-7...
  • Page 272: Cprl_Compareobjects

    The CPRL_COMPAREOBJECTS_ procedure compares two SQL collations or collation objects to determine whether they are equal. #include <cextdecs(CPRL_COMPAREOBJECTS_)> short CPRL_COMPAREOBJECTS_ ( long cprladdr1 /* i */ ,long cprladdr2 ); /* i */ HP NonStop SQL/MP Programming Manual for C—429847-008 11-8...
  • Page 273: Cprl_Decode

    The SQL collation or collation object is invalid. –4 The version of the SQL collation or collation object is not supported. –20 The user-specified buffer is not large enough to receive the returned string. HP NonStop SQL/MP Programming Manual for C—429847-008 11-9...
  • Page 274: Cprl_Downshift

    The version of the SQL collation or collation object is not supported. –20 The user-specified buffer is not large enough to receive the returned string. –21 The collations in the two specified SQL collations or collation objects do not match. HP NonStop SQL/MP Programming Manual for C—429847-008 11-10...
  • Page 275: Cprl_Encode

    CPRL_ENCODE_ ( char *decodedstring /* i */ ,short decodedstringlength /* i */ ,char *encodedstring /* o */ ,short encodedstringmaxlength /* i */ ,short *encodedstringlength /* o */ ,long cprladdr ); /* i */ HP NonStop SQL/MP Programming Manual for C—429847-008 11-11...
  • Page 276: Cprl_Getalphatable

    The CPRL_GETALPHATABLE_ procedure extracts ALPHAS character class information for single-byte character sets from an SQL collation or collation object. #include <cextdecs(CPRL_GETALPHATABLE_)> short CPRL_GETALPHATABLE_ ( char *array /* o */ ,long cprladdr ); /* i */ HP NonStop SQL/MP Programming Manual for C—429847-008 11-12...
  • Page 277: Cprl_Getcharclasstable

    The SQL collation or collation object is invalid. –4 The version of the SQL collation or collation object is not supported. –5 The user-specified character class does not exist in the specified SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-13...
  • Page 278: Cprl_Getdownshifttable

    If the call is successful, CPRL_GETDOWNSHIFTTABLE_ sets each byte in array to the downshifted version of the corresponding character in the SQL collation or collation object. If the call is unsuccessful, array is not modified. HP NonStop SQL/MP Programming Manual for C—429847-008 11-14...
  • Page 279: Cprl_Getfirst

    (If CPRL_GETFIRST_ is successful, firststringmaxlength and firststringlength are equal.) cprladdr is a pointer to the SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-15...
  • Page 280: Cprl_Getlast

    (If CPRL_GETLAST_ is successful, laststringlength and laststringmaxlength are equal.) cprladdr is a pointer to the SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-16...
  • Page 281: Cprl_Getnextinsequence

    The returned value is padded with blanks as necessary to fill nextstring for this length. In most cases, set nextstring to the same value as inputstring. HP NonStop SQL/MP Programming Manual for C—429847-008 11-17...
  • Page 282: Cprl_Getnumtable

    The corresponding character code in the SQL collation or collation object is not numeric. If the call is unsuccessful, array is not modified. cprladdr is a pointer to the SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-18...
  • Page 283: Cprl_Getspecialtable

    The corresponding character code in the SQL collation or collation object is not in the SPECIALS character class. If the call is unsuccessful, array is not modified. cprladdr is a pointer to the SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-19...
  • Page 284: Cprl_Getupshifttable

    [ short *cprlsize /* o */ ,[ short *is1to1 /* o */ ,[ short *lengtheningfactor ] /* o */ ,[ short *characterset /* o */ ,[ short *version ] ); /* o */ HP NonStop SQL/MP Programming Manual for C—429847-008 11-20...
  • Page 285 SQL collation or collation object: UNKNOWN ISO88595 ISO88591 ISO88596 ISO88592 ISO88597 ISO88593 ISO88598 ISO88594 ISO88599 version is the format version of the SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-21...
  • Page 286: Cprl_Readobject

    If you are concerned about stack size limitations, use this procedure with caution. bufferlength is the size of buffer in bytes. objectlength is the actual length in bytes of the collation object read into buffer. HP NonStop SQL/MP Programming Manual for C—429847-008 11-22...
  • Page 287: Cprl_Upshift

    CPRL_UPSHIFT_ returns the upshifted string. The values for inputstring and shiftedstring can be equal, but other values can cause unpredictable results. HP NonStop SQL/MP Programming Manual for C—429847-008 11-23...
  • Page 288 SQL collation or collation object. HP NonStop SQL/MP Programming Manual for C—429847-008 11-24...
  • Page 289: Sql/Mp Sample Database

    SQL/MP Sample Database This appendix describes the NonStop SQL/MP sample database included on the product site update tape (SUT). Many examples in this manual (in addition to other SQL/MP manuals) refer to this sample database. You can create your own copy of the sample database and access it using SQLCI commands or by embedding SQL statement in a host-language program.
  • Page 290: Figure

    PARTLOC Table * suppnum loc_code Legend suppname_kanji partnum suppname_katakana qty_on_hand One to one suppname_english One to many street The PARTLOC table can city be partitioned by the state value of LOC_CODE. postcode VST007.vsd HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 291: Example A-1. Copylib File For Sample Database

    } location; #pragma SECTION JOB /* Record Definition for \SYS1.$VOL1.PERSNL.JOB /* Definition current at 09:54:02 - 11/10/96 struct job_type { unsigned short jobcode; struct { short len; char val[19]; } jobdesc; Sales (SALES) HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 292 #pragma SECTION PARTS /* Record Definition for \SYS1.$VOL1.SALES.PARTS /* Definition current at 09:54:08 - 11/10/96 struct parts_type { unsigned short partnum; char partdesc[19]; long price; /* scale is 2 */ long qty_available; HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 293 #pragma SECTION ERRORS /* Record Definition for \SYS1.$VOL1.INVENT.ERRORS /* Definition current at 09:54:14 - 11/10/96 struct errors_type { long errors_date long errors_time long errors_id short errors_sql char errors_text1[241]; char errors_text2[241]; HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 294 SQL/MP Sample Database HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 295: Memory Considerations

    DECLARE CURSOR statement for dynamic cursors that do not use cursor or statement host variables SQLIVARS Each input host variable specified in the program SQLOVARS Each output host variable specified in the program HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 296: Using The Sqlmem Pragma

    Some statements require no extra extended memory, but other statements generate a run-time call to the SQL executor and use the extra memory. The SQL executor uses extended memory to run and uses the memory shown in this table for parameters and data structures. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 297: Table B-2. Virtual Memory Requirements For Sql Statements

    UPDATE STATISTICS Do not count these SQL statements and directives:  BEGIN DECLARE SECTION and END DECLARE SECTION  CONTROL EXECUTOR, CONTROL QUERY, and CONTROL TABLE  DECLARE CURSOR  INVOKE  WHENEVER HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 298: Avoiding Memory Stack Overflows

    SQL error 8003. If there is not enough stack space to call the routine, the executor abends without returning a message.  At least 1024 words of stack space are available. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 299 RUN command. For more information, see the TACL Reference Manual.  Programmatically, set the memory-pages parameter of the NEWPROCESS or PROCESS_CREATE_ system procedure. For more information, see the Guardian Procedure Calls Reference Manual. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 300 Memory Considerations Avoiding Memory Stack Overflows HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 301: Using A Local Partition

    SQL objects. In some cases, the design of NonStop SQL/MP allows for local autonomy. For example, if a DDL change alters a table on \NODEA when \NODEB is unavailable, an SQL program file on \NODEB that uses the altered \NODEA table is not marked as invalid.
  • Page 302: Using Current Statistics

    SQL warning and file-system error even if your query does not try to retrieve any rows from the unavailable partition. Executing the UPDATE STATISTICS statement eliminates both these problems. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 303: Skipping Unavailable Partitions

    Use the SKIP UNAVAILABLE PARTITION option of the CONTROL TABLE directive to cause NonStop SQL/MP to skip a partition that is not available and to open the next available partition that satisfies the search condition of a query. (NonStop SQL/MP also returns warning message 8239 to the SQLCA structure.) The SKIP UNAVAILABLE...
  • Page 304 Maximizing Local Autonomy Skipping Unavailable Partitions HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 305: Generating Sql Data Structures

    Converting C Programs A C program developed for NonStop SQL/MP version 1 or version 2 software can run on SQL/MP version 300 (or later) software without any changes to its embedded SQL statements or directives. However, to use new SQL features, you must modify and recompile the program.
  • Page 306: Generating Sqlda Structures

    SQLDA structures:  A version 300 (or later) SQLDA structure  A version 1 or 2 SQLDA structure  A version 300 (or later) SQLDA structure and a version 1 or 2 SQLDA structure HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 307: Generating A Version 300 (Or Later) Sqlda Structure

    4. Add an INCLUDE STRUCTURES directive with the ALL VERSION 2 option: EXEC SQL INCLUDE STRUCTURES ALL VERSION 2; Or specify only the SQLDA VERSION 2 option: EXEC SQL INCLUDE STRUCTURES SQLDA VERSION 2; HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 308: Version 2 Sqlda Structure

    DESCRIBE INPUT and DESCRIBE statements return one sqlvar entry for each input parameter or each output variable. Data type of the parameter or output variables. For the table of data type data_type values, see Section 10, Dynamic SQL Operations. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 309 Extended address of the actual data (value of input parameter or var_ptr column). NonStop SQL/MP does not return var_ptr; a program must initialize var_ptr to point to the input and output data buffers Address of a flag that indicates whether a parameter or column is ind_ptr actually null.
  • Page 310: Version 1 Sqlda Structure

    Number of input parameters or output variables the SQLDA structure can num_entries accommodate. Group item that describes input parameters or database columns. The sqlvar DESCRIBE INPUT and DESCRIBE statements return one sqlvar entry for each input parameter or each output variable. HP NonStop SQL/MP Programming Manual for C—429847-008...
  • Page 311 Bits 8:15 contain the storage size of the item. Extended address of the actual data (value of input parameter or var_ptr column). NonStop SQL/MP does not return var_ptr; a program must initialize var_ptr to point to the input and output data buffers. Using a Combination of SQLDA Structures Version 300 (or later) SQL/MP software does not support different versions of SQLDA structures in the same compilation unit.
  • Page 312: Planning For Future Pvus

    Planning for Future PVUs Planning for Future PVUs If you are converting a C program developed for NonStop SQL/MP version 1 or version 2 software to use version 300 (or later) features and to run on NonStop SQL/MP version 300 (or later) software, consider making these changes in the program for compatibility with future NonStop SQL/MP PVUs.
  • Page 313 CHANGE command similarity check considerations 8-13 description ALTER VIEW statement effect on SQL validity Altering SQL file attribute SELECT command 6-12 Arguments, C compiler, RUN command SET EXTENDSTACK command ASSIGN command, TACL HP NonStop SQL/MP Programming Manual for C—429847-008 Index-1...
  • Page 314 6-33 CPRL_GETCHARCLASSTABLE_ 11-1 CALL format, WHENEVER directive CAST function CPRL_GETDOWNSHIFTTABLE_ 11-1 Catalog authority for program execution CPRL_GETFIRST_ 11-15 CHECK options 8-10 CPRL_GETLAST_ 11-16 SQLGETCATALOGVERSION 5-18 CPRL_GETNEXTINSEQUENCE_ 11-1 version considerations 8-10 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-2...
  • Page 315 8-12 CPRL_GETSPECIALTABLE_ COMMIT WORK statement 10-28 procedure 11-19 Communications area, SQL CPRL_GETUPSHIFTTABLE_ See SQLCA structure procedure 11-20 Compilation CPRL_INFO_ procedure 11-20 automatic recompilation CPRL_READOBJECT_ procedure 11-22 C compiler syntax CPRL_UPSHIFT_ procedure 11-23 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-3...
  • Page 316 UPDATE statement 4-22 INVOKE directive 2-14 SELECT statement 4-21 Date-time data type with INVOKE directive 2-14 stability of cursor 4-17 DDL operations, invalidating Virtual sequential block buffering (VSBB) 4-17 WHERE clause 4-21 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-4...
  • Page 317 10-12 See SQL/MP directives Pathway server 10-36 Disk process (DP2) SQLDA structure 10-3 SQLCADISPLAY SQLSA statistics 9-13 SQLCAFSCODE statements 10-2 SQLCATOBUFFER 5-14 Dynamic SQL, statement compilation 6-23 Distributed database, maximizing local autonomy HP NonStop SQL/MP Programming Manual for C—429847-008 Index-5...
  • Page 318 SQL validation run-time SQL recompilation File number of SQLMSG file 5-4, 5-15 UPDATE statement 4-11 File Utility Program (FUP) EXEC SQL keywords DUPLICATE command EXECUTE IMMEDIATE statement FILEINFO command description HP NonStop SQL/MP Programming Manual for C—429847-008 Index-6...
  • Page 319 Index, SQL, changes and program file validity Help text, similarity check rules 8-12 INDICATOR clause with host variable HIGHPIN object-file attribute Indicator parameter HIGHPIN run option, TACL RUN function 10-17 command names buffer 10-18 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-7...
  • Page 320 Measure program SQLCAGETINFOLIST parameter 5-10 MEM option, TACL Memory management dynamic allocation 10-18 JULIANTIMESTAMP procedure 4-10 estimating use SQLMEM pragma Memory model 10-18, 10-29 Memory stack overflows Key tags, similarity check rules 8-12 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-8...
  • Page 321 NULL keyword with SQLGETOBJECTVERSION 5-19 with INSERT statement OPEN procedure 10-36 with UPDATE statement 4-12 OPEN statement 4-15, 4-19, 4-22, 4-24 NULL STRUCTURE clause with INVOKE directive 2-23 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-9...
  • Page 322 OWNER attribute, similarity check rules 8-12 description SQLMEM B-2, SQL, specifying Parallel execution plans SYSTYPE automatic recompilation XMEM similarity check XVAR PARAM command, TACL PREFIX clause, INVOKE statement 2-23 for SQL program file HP NonStop SQL/MP Programming Manual for C—429847-008 Index-10...
  • Page 323 RECOMPILEALL option, SQL compiler 6-17, Program file, SQL RECOMPILEONDEMAND option, SQL binding object file 6-11 compiler 6-17 execution Record descriptions, tables and views 2-19 SQL compilation 6-12 Records, SQLSA statistics 9-14 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-11...
  • Page 324 2-12, 2-13 single-row UPDATE statement 4-11 single row SQLSA statistics 9-14 Semicolon (;) in SQL statements 1-3, UPDATE statement 4-10, 4-22 SENSITIVE flag, SQL RTDU (run time data unit) HP NonStop SQL/MP Programming Manual for C—429847-008 Index-12...
  • Page 325 Source file, C compiler SQL sensitive flag SQL comments, Declare Section SQL statements SQL communications area See SQL/MP statements See SQLCA structure SQL statistics area SQL compiler interface (SCI) See SQLSA structure SQL structures, internal HP NonStop SQL/MP Programming Manual for C—429847-008 Index-13...
  • Page 326 5-4, 5-15 data conversion SQLCADISPLAY procedure declaration SQLCATOBUFFER procedure 5-15 dynamic SQL use 10-23 SQLOVARS data structure WHENEVER directive SQLSA structure SQLCOMP command declaration 9-13 description 6-12 description 9-13 EXPLAIN DEFINES option HP NonStop SQL/MP Programming Manual for C—429847-008 Index-14...
  • Page 327 4-10 similarity check 8-13 UPDATE STATISTICS ALTER VIEW error 8204 BEGIN WORK 10-27 execution plans 6-21 coding guidelines local autonomy coding in source file program invalidation 8-3, COMMIT WORK 10-28 CREATE CONSTRAINT HP NonStop SQL/MP Programming Manual for C—429847-008 Index-15...
  • Page 328 SUFFIX clause with INVOKE TABLES table 8-11 statement 2-23 Table, SQL Swap file volume for SQL compiler 6-22 changes and program file validity SWAPVOL option, PARAM command 6-22 declaring record descriptions 2-19 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-16...
  • Page 329 4-12 collation check 8-15 scale for numeric data 2-12, 2-13 INSERT statement 4-10 set of rows 4-12 program validation time single row 4-11 run-time check using parameter 10-12 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-17...
  • Page 330 WHENEVERLIST option, SQL pragma Variable-length character data, host WHERE CURRENT OF clause, UPDATE variable declaration statement 4-22 VERIFIEDWRITES attribute, similarity WRITEREAD procedure check rules 8-12 VERIFY utility, SQL Version management C compiler 6-36, HP NonStop SQL/MP Programming Manual for C—429847-008 Index-18...
  • Page 331 6-30 : (colon) with host variable 1-2, ; (semicolon) in SQL statements 1-3, =_DEFAULTS DEFINE, TACL 6-27 =_SORT_DEFAULTS DEFINE ? (question mark), unnamed parameter 10-11 \ (backslash), OSS shell escape character 6-29 HP NonStop SQL/MP Programming Manual for C—429847-008 Index-19...

Table of Contents