zoukankan      html  css  js  c++  java
  • DB2应用中嵌入式SQL取值入本地变量

    Declare section for host variables in C and C++ embedded SQL applications

    You must use an SQL declare section to identify host variable declarations. SQL declare sections alert the precompiler to any host variables that can be referenced in subsequent SQL statements.
    For example:
       EXEC SQL BEGIN DECLARE SECTION; 
         char  varsql;     /* allowed */ 
       EXEC SQL END DECLARE SECTION; 

    The C or C++ precompiler only recognizes a subset of valid C or C++ declarations as valid host variable declarations. These declarations define either numeric or character variables. Host variables can be grouped into a single host structure. You can declare C++ class data members as host variables.

    A numeric host variable can be used as an input or output variable for any numeric SQL input or output value. A character host variable can be used as an input or output variable for any character, date, time, or timestamp SQL input or output value. The application must ensure that output variables are long enough to contain the values that they receive.

    You can define, name, and use a host variable within the SQL declare section. In the following example, a struct type called staff_record is first defined. Then the variable named staff_detail is declared as being of type staff_record:
    EXEC SQL BEGIN DECLARE SECTION ;
    
    typedef struct {
    	short id;
    	VARCHAR name[10+1]; 
    	short years; 
    	double salary; 
    } staff_record;
    
    staff_record staff_detail;
    
    EXEC SQL END DECLARE SECTION ;
    ...
    SELECT id, name, years, salary 
    	FROM staff 
    	INTO :staff_detail 
    	WHERE id = 10;
    ...
  • 相关阅读:
    win10环境下 jdk8安装点击下一步没反应解决办法
    selenium 常见鼠标 键盘事件
    selenium 输入框有默认值,用键盘事件解决
    selenium 键盘事件
    selenium 鼠标事件
    sql length
    ecshop Uncaught transport.js/parseResult() error: can't parse to JSON 错误解决
    j2EE基础知识
    mybatis入门知识
    JVM入门
  • 原文地址:https://www.cnblogs.com/sthv/p/5760684.html
Copyright © 2011-2022 走看看