PRO*C에서 에러 처리하기 (SQLSTATE, SQLCODE, SQLCA)

제품 : PRECOMPILERS
작성날짜 : 1997-02-06
디자인상의 문제, 코딩상의 문제, 하드웨어 문제, 비정상적인 값의 입력 등등....
프로그램을 수행하다 보면 다양한 에러들을 접하게 된다. 프로그램을 정상적으로
수행하기 위해서는 이들 에러에 대한 적절한 대책이 필요 한데, 특히 SQL문의
수행과 관련된 에러의 처리는 데이타의 무결성을 유지하고, 정확한 트랜젝션
수행의 기본이 된다. PRO*C에서는 SQL문과 관련된 에러를 처리하기 위한 다양한
방법을 제공하고 있는데, 크게 상태 변수(SQLSTATE, SQLCODE)를 사용하는 방법과 SQLCA를 활용하는 방법으로 나눠볼 수 있다.
1) MODE OPTION값에 따른 ERROR 처리
* MODE = ANSI 일때
SQLSTATE나 SQLCODE중에 하나는 반드시 사용해야 한다.
SQLCA는 선택적이다.
* MODE = ORACLE
SQLCA를 사용해야 한다.
SQLSTATE나 SQLCODE는 선언해도 사용되지 않는다.
2) SQLCODE
SQLCODE는 SQL문을 수행한 STATUS CODE 값을 가지고 있다.
이 변수는 LONG으로 선언해서 사용해야 한다.
< 예제 >
DECLARE SQL BEGIN DECLARE SECTION;
int emp_number, dept_number;
EXEC SQL END DECLARE SECTION;
long SQLCODE;
3) SQLSTATE 상태 변수 (status variable)
SQLCODE와 달리 SQLSTATE는 에러와 warning을 모두 저장하고 있고, character
5자리의 값을 가지고 있다. SQLSTATE를 사용하기 위해서는 반드시 CHAR SQLSTATE[6]; 으로 선언해야 한다.
SQLSTATE 상태 코드는 예외의 유형을 구분해주는 CLASS 두 자리와 구체적인
예외를 말해주는 3자리의 SUBCLASS로 구성된다. 이들 CODE값과 그 의미는 PROGRAMMER*S GIDE TO THE ORACLE PRO*C/C++ PRECOMPILER의 Handling
runtime error편에 자세히 나와 있다.
4) SQLCA(COMMUNICATION AREA)의 사용
SQLCA는 ORACLE COMMUNICATION을 다루는 C STRUCT를 말한다. 이는 상태 코드,
경고 FLAG, 처리된 ROW 수, PARSING ERROR, 기타 에러 메세지에 관한 정보를
담고 있다.
* SQLCA의 선언
EXEC SQL INCLUDE SQLCA; 또는 # include <sqlca.h>
* SQLCA STRUCTURE와 의미
- sqlcaid : identifier
- sqlcabc : SQLCA의 총size
- sqlcode : 최근에 실행된 SQL문의 상태코드
0 에러 없이 정상 수행
>0 SQL문이 수행되기는 했지만 exception이 발생
<0 SQL문 수행 안됨. sqlca.sqlerr[4]로 내용 확인 가능
- sqlerrm : 에러 메세지 길이(sqlerrml)와 메시지 내용(sqlerrmc)
메세지는 총 70자리 까지 밖에 저장되지 않음. 이 이상
의 메세지를 보려면 sqlglm()을 이용해야 한다.(sqlcpr.h
에 정의)
만약 sqlcode가 0일때 sqlerrmc의 내용을 보면 이전에
수행된 에러 메시지가 남아 있으므로 sqlcode < 0일때만
사용하는 것이 바람직하다.
- sqlerrd : SQL문 수행과 관련된 각종 INTEGER정보들
sqlerrd[0], sqlerrd[1], sqlerrd[3], sqlerrd[5]
: 현재 사용하고 있지 않음
sqlerrd[2] : 처리된 row수. cascade를 처리된 row수는 제외됨.
Array processing을 하는 중에 에러가 발생했다면, 이
변수에는 정상적으로 처리된 row의 수를 return하게
된다.
sqlerrd[4] : SQL문에서 parse error가 발생한 지점. ( 0부터 시작)
- sqlwarn : warning flag. 해당 warning 발생시 W를 set한다.
sqlwarn[0] : warning 발생 여부 set
sqlwarn[1] : character data의 경우truncated 여부 set
indicator변수를 사용하면 원래의 size 확인 가능.
sqlwarn[2] : NULL 값이 group함수에 사용되었는지를 set
sqlwarn[3] : select한 column과 bind한 column의 갯수가 다른
경우 set
sqlwarn[4] : where절이 없는update, delete문 수행 시 set.
where절이 없이 수행된다는 것은 비정상적인 상황
이기 때문에 warning을 한다.
sqlwarn[5]: EXEC SQL CREATE {PROCEDURE/FUNCTION |
                            PACKAGE|PACKAGE BODY]문 수행시 컴파일 에러
발생시 set
5) WHENEVER문 사용법
디폴트로 컴파일된 프로그램은 오라클 에러나, warning을 무시하고, 가능하다면
프로그램 수행을 계속한다. 비정상적인 동작에 적절한 조치를 취하기 위해 자동
으로 에러나 warning의 발생을 감지하려면 WHENEVER문을 사용하면 된다.
WHENEVER문의 scope rule은 위치에 의해 결정되는 것이지, logical하게
결정되는 것이 아니라는 점을 주의해야 한다. 그러므로 수행될 SQL 문 이전에 WHENEVER절을 위치하도록 해야 한다. 그리고, 다음 WHENEVER절이 나타나기
이전까지만 효과가 있다.
WHENEVER SQLWARING문을 사용하려면 반드시 SQLCA를 선언해야 한다.
* SYNTAX
EXEC SQL WHENEVER <condition> <action>;
* CONDITION유형
SQLWARNING / SQLERROR / NOT FOUND
* ACTION 유형
- CONTINUE :WHENEVER문을 사용하지 않은 것과 동일한 결과
- DO
- GOTO <label>
- STOP : COMMIT되지 않은 WORK은 모두 ROLLBACK 시킴.
condition과 action을 적절히 혼합하여 사용하면 되는데, 조심해야 할 사항은
WHENEVER SQLERROR GOTO <lable>을 사용할때 무한 loop에 걸리지 않도록 주의
해야 한다. (대신에 WHENEVER SQLERROR CONTINUE를 사용하는 것이 좋다.)
다음은 WHENEVER ...... DO 구문을 사용한 간단한 예제이다.
EXEC SQL WHENEVER SQLERROR DO handle_insert_error(*Insert Error*);
EXEC SQL INSERT INTO emp (empno, ename,deptno)
VALUES (:v_empno, :v_ename, :v_deptno);
EXEC SQL WHENEVER SQLERROR DO handle_delete_error(*delete Error*);
handle_insert_error(char *stmt)
switch(sqlca.sqlcode)
{ case        -1 :  /*duplicate l\key value */
break;
case -1401 : /*value too large*/
break;
default : /*do somthing here too*/
break;
handle_delete_error(char *stmt)
printf("%s\n\n", stmt);
if ( sqlca.sqlerrd[2] == 0 )
{    /* no rows deleted */
else
}

Given the ECPGget_sqlca call, it looks like you're using code generated by Postgres' ECPG precompiler rather than code generated by Pro*C. Add oname=sessiondb.c to your proc command-line and make sure you're compiling the proper code.

Similar Messages

  • PRO*C VERSION MATRIX 및 VERSION 별 특성

    제품 : PRECOMPILERS
    작성날짜 : 1998-02-19
    PRO*C version matrix 및 version 별 지원 내용
    ===========================================
    [1] PRO*C 의 version 별 지원 내용
    RDBMS 의 version 과 PRO*C 의 version 별 지원내용은 다음과 같다.
    PRO*    Last    RDBMS    Languages
    Version Version Version
    ======================================================================
    1.3     1.3.20  <6.0.35      PRO*C
    1.4     1.4.15/6 6.x          "
    1.5     1.5.10   7.0.x        "
    1.6     1.6.7    7.1.x        "
    1.6     1.6.9    7.2.x        "
    2.0     2.0.6    7.1.x        "
    2.1     2.1.3    7.2.x        "
    2.2     2.2.?    7.3.x        "
    [2] 각 version 의 pro*c의 precompile option 추가 부분과 header file
    위치는 다음과 같다.
    (1) version 1.4
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PRO14FLAGS
    Header files in:       $ORACLE_HOME/proc/lib
    (2) version 1.5
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PROFLAGS
    Header files in:       $ORACLE_HOME/proc/lib
    (3) verion 1.6 , 1.7,1.8
    Location: $ORACLE_HOME/proc16/demo
    File: proc16.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PCCFLAGS
    Header files in:       $ORACLE_HOME/sqllib/public
    (4) version 2.0, 2.1
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog1.pc": make -f proc.mk EXE=prog OBJS="prog1.o prog2.o"
      and "prog2.pc"
    Where to add options:  add PROFLAGS
    Header files in:       $ORACLE_HOME/sqllib/public
    (5) version 2.2
    Location: $ORACLE_HOME/precomp/demo/proc
    File: proc.mk
    Build from "prog1.pc": make -f proc.mk build EXE=prog OBJS="prog1.o
    prog2.o"
      and "prog2.pc"
    Where to add options:  add PROCFLAGS
    Header files in:       $ORACLE_HOME/precomp/public
    [3]다음은 각 VERSION 별 지원 내용을 살펴 보기로 한다.
    (1) VERSION 1.4
    1. precompiler option 의 추가된 부분은 LINES=YES option지정시 outpute 에
    #line directives 생성 지원되어debugging 에 도움울 줄수 있게
    되었으며, dynamic method 사용시 HOLD_CURSOR=YES option을 사용하여
    cursor의 재사용을 방지할 수 있게 되었다. AREASIZE,REBIND option 이
    없어지고 MODE=ANSI14 option 을 지원 가능하게 되었다. 그러나 이 ANSI14
    option 을 사용시는 4byte inter 인 SQLCODE 를 반드시 declare 해야 한다.
    SQLCHECK=SEMANTICS/SYNTAX/NONE (Default는 SYNTAX) 가 사용되고, 더이상
    log를 db에 기록하지 않게 되었다.
    2  Datatype equivalencing 지원 한다.
        EXEC SQL VAR host_variable IS datatype ;
        EXEC SQL TYPE type is datatype REFERENCE ;
    3. Indicator 변수를 사용가능 ( :host INDICATOR :indicator ) 하게
    되었으며 또한 AT 절에 host 변수를 사용가능하게 되었다. 또host변수
    선언시 auto, extern, static, const, volatile 사용 가능하다.
    4. SQLCA 의 sqlerrd(5) 에 0 based parse offset을 저장하였으나, v2.x 의
    현재 version 에서는 사용되어지지 않고있다..
    5 procedure call 이 가능하게 되었다. (EXEC SQL WHENEVER ... DO
    procedure) .
      또한 EXEC SQL WHENEVER ... DO break; 문이 사용가능하다 .
    6. Precompiler 실행모듈이 각 언어마다 구분되어 pro*c 의 경우function의
    prototypes 생성
       가능하다.
    (2) Version 1.5
    ============
    이 version 은 ORACLE RDBMS 7.x 를 지원하는 pro*c version 으로 완벽한
    ANSI SQL을 지원한다. 또한 NLS 의 support 도 지원가능하다
    1. precompile option 의 변경사항으로는 DBMS=NATIVE/V6/V7 option
    지원하며 FIPS=YES로 설정시 ANSI extension 지원한다.
    2.  data type 변경사항으로는 fixed length datatypes 지원하는 CHARF,
    CHARZ가 사용가능하며 LONG VARCHAR,LONG VARRAW datatypes 지원가능하다.
    또한 MLSLABEL 데이타 타입사용 가능하게 되었는데 이는 variable_lengrh
    의 binary OS label 을 저장할때 사용가능하다.
    3. indicators 없는 host 변수가 null을 fetch하면, DBMS=V6으로
    설정하지 않은 경우는
       ORA-1405를 return 함. PL/SQL table을 파라미터로 하는 stored
    procedures 호출 가능.
    4. 이전 version 에서 space 만 가능했던 (bug) input character string
    데이타 타입이
       terminator를 포함하는 경우도 이를 데이타로 인식 가능
    (3) version 1.6
    ==================
    1.변경된 precompile option 으로 AUTO_CONNECT=YES option
    지원하는데
    이를 지정시는 처음 sql 문 수행시 OPS$<username>으로 자동 connect 된다. 
    또한 CONFIG=<file> option 지원으로 user 의 configuration 의 name 과
    위치를 지정할수 있다. 또한 시스템 config file 사용 가능한데 이의 위치는
    UNIX = $ORACLE_HOME/proc16/pccc.cfg, VMS=ora_pcc:pccc.cfg. 이다.
    2. SQLSTATE 변수는 SQL문 실행 이후에 값이 설정된다. MODE=ANSI로 설정이
    되어 있고, declare section안에 선언되어 있는 경우에만 이값이 설정된다. 
    만일 그렇지 않으면 이 값은 무시된다.만약 SQLCODE가 안에 선언되어 있다면,
    이 두 변수 모두 값이 설정된다.
     만약 SQLCODE가 밖에 선언되어 있다면 SQLSTATE만 설정된다. SQLSTATE는
    coding scheme를 표준화하는데 사용된다. SQLCODE는 declare section
    내부에 선언되거나, SQLSTATE, SQLCA가 사용되지 않는 경우에 사용하게 된다.
    이 점은 1.5 버젼에서 SQLCA를 declare section 밖에 선언하여, SQLCA와
    같이 사용되었던 것과는 차이가 있다.
    3. SQLGLS 함수 지원하는데 이는 마지막 문장을 parse 한 후, 문장의 길이
    및 타입을 return한다. 
    eg) int sqlgls(char *sqlstm ,size_t
    *stmlen,size_t *sqlfc)
    4. select 문에서 stored function 을 call 할수 있다.
    5. 단 SQLCHECK=FULL/SEMANTICS 가 아닌 경우에 FROM 절에서 subquery 가
    가능하다. 이는 PL/SQL 의 semantic check 인 경우는 v7.3 에서 가능하다 .
    (4) Version 1.8
    ================ 
    1. INDICATOR VARIABLE을 사용하지 않고도 NULL FETCH시 ORA-1405 에러가
    발생하지 않도록 UNSAFE_NULL=YES 옵션이 추가됨. UNSAFE_NULL=YES로
    설정하면 ORA-1405 를 방지하기 위해서 DBMS=V6 으로 세팅할 필요없이
    DBMS=V7 으로 할 수 있음. 단, UNSAFE_NULL=YES를 사용하기 위해서는
    MODE=ORACLE 로 설정해야 함.
    2. PACKAGE ARGUMENT로 PL/SQL CURSOR(WEAKLY TYPED)를 사용할 수 있는데
    예를 들면 TYPE GeneralCurTyp IS REF CURSOR;
    3. FROM 절에서 SUBQUERY를 사용할 수 있고 SQLCHECK=SEMANTICS 또는
    SQLCHECK=FULL 옵션을 사용할 수 있음.
    4. PL/SQL 블럭에서 PL/SQL TABLE과 이와 관련된 다음 함수를 지원.
     a_table(index).EXISTS, a_table.COUNT, a_table.FIRST, a_table.LAST,
    a_table.PRIOR(index), a_table.NEXT(index),
    a_table.DELETE(start_index,_index), a_table.DELETE.
    5. WHERE CURRENT OF CURSOR를 이용해서 MULTI-TABLE VIEW를 통해
    KEY-PRESERVED TABLE을 UPDATE 가능.
    (5) version 2.0
    ==================
    RDBMS version 7.3에서 부터 makefile 은
    ins_precomp.mk,env_precomp.mk, proc.mk의 3 개로 나뉘었다.
    Ins_precomp.mk 는 기존의 proc.mk 처럼 precompiler executables 를 build
    하기 위한 routine 이고 env_precomp.mk 는 모든 environment 의 변수와
    libraray 를 포함한다.
    이 file 은 Ins_precomp.mk 와 proc.mk 에 포함되어 사용되어진다.
    1. V1.6과 같이 AUTO_CONNECT, CONFIG 옵션 지원. SYSTEM CONFIGURATION
    FILE은 UNIX에서는 $ORACLE_HOME/proc/pmscfg.h 이고 VMS에서는
    ora_proc20:pmscfg.cfg
    2. V1.6과 같이 SQLSTATE 변수와 SQLGLS 함수가 제공된다.
    3. C PREPROCESSOR가 포함되어서 #define이 EMBEDDED SQL과 함께 이용될 수
    있고 #include 로 PRO*C 헤더화일을 INCLUDE 가능.
    4. 구조체를 HOST 변수로 사용 가능. 이것은 SELECT INTO, FETCH INTO 
    또는 INSERT시 VALUES 절에 사용될 수 있으나 PL/SQL PROCEDURE에 PL/SQL
    RECORD ARGUMENT로 사용할 수는 없음. 구조체 내에 또다른 구조체를 포함할
    수는 없지만 ARRAY는 포함할 수 있음.
    5. HOST 변수를 BEGIN/END DECLARE SECTION 안에 넣을 필요가 없음.
    6. V1.6에서 처럼 SELECT LIST에 STORED FUNCTION의 사용이 가능.
    7. SQLCHECK=FULL/SEMANTOCS를 사용하지 않는 경우 FROM 절에 SUBQUERY를
    쓸 수 있음.
    8. CHARACTER 변수의 BIND TYPE은 MODE 옵션이 아니라 DBMS 옵션에 따라서
    결정됨. DBMS=V6/V6_CHAR 인 경우, CHARACTER는 TYPE 1, DBMS=V7(또는
    NATIVE이고 ORACLE7에 접속할 때) 에서는 TYPE 97.
    9. DBMS=V6_CHAR 는 CHARACTER 변수가 가변 길이 문자열로 다루어질 수
    있도록 함.
    10. SQLVCP 함수는 VARCHAR ARR 변수를 지정한 길이로 만들어 주므로
    VARCHAR를 동적으로 할당할 때 COMPILER가 BYTE ALIGNMENT를 가능하게 함.
    11. PRO*C의 PARSE LEVEL을 설정하는 PARSE 옵션.
    a) NONE - PRO*C V1과 같음(HOST 변수를 DECLARE SECTION에 넣어야 함.
    #define 인식 안함 등)
    b) PARTIAL - HOST 변수를 DECLARE SECTION에 넣어야 함
    c) FULL - PRO*C V2의 기능 모두 지원
    12. EXEC SQL WHENEVER ... DO 함수명(args,...); 와 같이 함수호출시UMENT를
    주고 받을 수 있음.
    13. #ifdef/#ifndef 와 EXEC ORACLE IFDEF/IFNDEF 에서 사용하기 위한
    DEFINE 옵션 지원.
    (6) version 2.1
    ================
    1. PRO*C V1.7에서와 같이 char와 IMPLICIT VARCHAR (VARCHAR=YES 옵션과
    함께 적절한 C 구조체로 선언된 변수) HOST 변수에서 MULTI-BYTE NLS
    CHARACTER 데이타와 MULTI-BYTE 문자열을 지원.
     NLS_CHAR=var1,var2,... 옵션으로 MULTI-BYTE HOST 변수를 지정함.
    MULTI-BYTE 리터럴은 다음과 같이 사용된다.
     EXEC SQL SELECT ... WHERE ENAME = N*이경구*;
     단, 이것은 SQLLIB RUNTIME LIBRARY를 통해서 지원되기 때문에 MULTI-BYTE
    NLS 문자열은 DYNAMIC SQL에서 사용될 수 없음. NCHAR 데이타타입은 DDL 과
    함께 사용될 수 없음.
    2. PRO*C V1.7과 같이 NLS_LOCAL 옵션 지원
    3. DEF_SQLCODE=YES 로 설정하면 PRO*C는 다음 문장을 생성한다.
     #define SQLCODE sqlca.sqlcode
     SQLCA는 반드시 INCLUDE 되어야 하며 SQLCODE 변수는 선언되어서는 안됨.
    4. PRO*C V1.7 과 같이 CURSOR VARIABLE 지원.
    5. VARCHAR=YES 로 설정하면 특정한 구조체를 VARCHAR로 인식할 수 있다. 
    구조체의 형태를 보면
     struct
     short len;
     char arr[n];
     } host_var;
    6. CODE=CPP 로 설정하면 SQLLIB 함수 원형(PROTOTYPE)은 다음과 같이
    extern "C" 형식으로 생성됨.
     extern "C" {
     void sqlora( unsigned long *, void *);
     그리고 "//" 와 같은 COMMENT 처리명령을 인식함. 단, CODE=CPP인 경우
    PARSE 는 자동적으로 PARTIAL로 설정됨.
     CPP_SUFFIX 옵션은 PRECOMPILE된 화일의 확장자를 지정.
    SYS_INCLUDE=(dir1,dir2,...) 옵션은 C 헤더 화일과 다른 위치에 있는 C++
    헤더 화일이 있는 디렉토리를 지정. 이 옵션은 PARSE 옵션이 NONE이 아닌
    경우에만 필요하다. HEADER 화일을 찾는 위치는 SYS_INCLUDE, 현재 디렉토리,
    표준 SYSTEM 디렉토리(UNIX에서 PRO*C 헤더 화일의 위치는
    $ORACLE_HOME/sqllib/public), 그리고 INCLUDE 옵션에 지정된 디렉토리이다.

    제품 : PRECOMPILERS
    작성날짜 : 1998-02-19
    PRO*C version matrix 및 version 별 지원 내용
    ===========================================
    [1] PRO*C 의 version 별 지원 내용
    RDBMS 의 version 과 PRO*C 의 version 별 지원내용은 다음과 같다.
    PRO*    Last    RDBMS    Languages
    Version Version Version
    ======================================================================
    1.3     1.3.20  <6.0.35      PRO*C
    1.4     1.4.15/6 6.x          "
    1.5     1.5.10   7.0.x        "
    1.6     1.6.7    7.1.x        "
    1.6     1.6.9    7.2.x        "
    2.0     2.0.6    7.1.x        "
    2.1     2.1.3    7.2.x        "
    2.2     2.2.?    7.3.x        "
    [2] 각 version 의 pro*c의 precompile option 추가 부분과 header file
    위치는 다음과 같다.
    (1) version 1.4
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PRO14FLAGS
    Header files in:       $ORACLE_HOME/proc/lib
    (2) version 1.5
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PROFLAGS
    Header files in:       $ORACLE_HOME/proc/lib
    (3) verion 1.6 , 1.7,1.8
    Location: $ORACLE_HOME/proc16/demo
    File: proc16.mk
    Build from "prog.pc":  make -f proc.mk prog
    Where to add options:  edit PCCFLAGS
    Header files in:       $ORACLE_HOME/sqllib/public
    (4) version 2.0, 2.1
    Location: $ORACLE_HOME/proc/demo
    File: proc.mk
    Build from "prog1.pc": make -f proc.mk EXE=prog OBJS="prog1.o prog2.o"
      and "prog2.pc"
    Where to add options:  add PROFLAGS
    Header files in:       $ORACLE_HOME/sqllib/public
    (5) version 2.2
    Location: $ORACLE_HOME/precomp/demo/proc
    File: proc.mk
    Build from "prog1.pc": make -f proc.mk build EXE=prog OBJS="prog1.o
    prog2.o"
      and "prog2.pc"
    Where to add options:  add PROCFLAGS
    Header files in:       $ORACLE_HOME/precomp/public
    [3]다음은 각 VERSION 별 지원 내용을 살펴 보기로 한다.
    (1) VERSION 1.4
    1. precompiler option 의 추가된 부분은 LINES=YES option지정시 outpute 에
    #line directives 생성 지원되어debugging 에 도움울 줄수 있게
    되었으며, dynamic method 사용시 HOLD_CURSOR=YES option을 사용하여
    cursor의 재사용을 방지할 수 있게 되었다. AREASIZE,REBIND option 이
    없어지고 MODE=ANSI14 option 을 지원 가능하게 되었다. 그러나 이 ANSI14
    option 을 사용시는 4byte inter 인 SQLCODE 를 반드시 declare 해야 한다.
    SQLCHECK=SEMANTICS/SYNTAX/NONE (Default는 SYNTAX) 가 사용되고, 더이상
    log를 db에 기록하지 않게 되었다.
    2  Datatype equivalencing 지원 한다.
        EXEC SQL VAR host_variable IS datatype ;
        EXEC SQL TYPE type is datatype REFERENCE ;
    3. Indicator 변수를 사용가능 ( :host INDICATOR :indicator ) 하게
    되었으며 또한 AT 절에 host 변수를 사용가능하게 되었다. 또host변수
    선언시 auto, extern, static, const, volatile 사용 가능하다.
    4. SQLCA 의 sqlerrd(5) 에 0 based parse offset을 저장하였으나, v2.x 의
    현재 version 에서는 사용되어지지 않고있다..
    5 procedure call 이 가능하게 되었다. (EXEC SQL WHENEVER ... DO
    procedure) .
      또한 EXEC SQL WHENEVER ... DO break; 문이 사용가능하다 .
    6. Precompiler 실행모듈이 각 언어마다 구분되어 pro*c 의 경우function의
    prototypes 생성
       가능하다.
    (2) Version 1.5
    ============
    이 version 은 ORACLE RDBMS 7.x 를 지원하는 pro*c version 으로 완벽한
    ANSI SQL을 지원한다. 또한 NLS 의 support 도 지원가능하다
    1. precompile option 의 변경사항으로는 DBMS=NATIVE/V6/V7 option
    지원하며 FIPS=YES로 설정시 ANSI extension 지원한다.
    2.  data type 변경사항으로는 fixed length datatypes 지원하는 CHARF,
    CHARZ가 사용가능하며 LONG VARCHAR,LONG VARRAW datatypes 지원가능하다.
    또한 MLSLABEL 데이타 타입사용 가능하게 되었는데 이는 variable_lengrh
    의 binary OS label 을 저장할때 사용가능하다.
    3. indicators 없는 host 변수가 null을 fetch하면, DBMS=V6으로
    설정하지 않은 경우는
       ORA-1405를 return 함. PL/SQL table을 파라미터로 하는 stored
    procedures 호출 가능.
    4. 이전 version 에서 space 만 가능했던 (bug) input character string
    데이타 타입이
       terminator를 포함하는 경우도 이를 데이타로 인식 가능
    (3) version 1.6
    ==================
    1.변경된 precompile option 으로 AUTO_CONNECT=YES option
    지원하는데
    이를 지정시는 처음 sql 문 수행시 OPS$<username>으로 자동 connect 된다. 
    또한 CONFIG=<file> option 지원으로 user 의 configuration 의 name 과
    위치를 지정할수 있다. 또한 시스템 config file 사용 가능한데 이의 위치는
    UNIX = $ORACLE_HOME/proc16/pccc.cfg, VMS=ora_pcc:pccc.cfg. 이다.
    2. SQLSTATE 변수는 SQL문 실행 이후에 값이 설정된다. MODE=ANSI로 설정이
    되어 있고, declare section안에 선언되어 있는 경우에만 이값이 설정된다. 
    만일 그렇지 않으면 이 값은 무시된다.만약 SQLCODE가 안에 선언되어 있다면,
    이 두 변수 모두 값이 설정된다.
     만약 SQLCODE가 밖에 선언되어 있다면 SQLSTATE만 설정된다. SQLSTATE는
    coding scheme를 표준화하는데 사용된다. SQLCODE는 declare section
    내부에 선언되거나, SQLSTATE, SQLCA가 사용되지 않는 경우에 사용하게 된다.
    이 점은 1.5 버젼에서 SQLCA를 declare section 밖에 선언하여, SQLCA와
    같이 사용되었던 것과는 차이가 있다.
    3. SQLGLS 함수 지원하는데 이는 마지막 문장을 parse 한 후, 문장의 길이
    및 타입을 return한다. 
    eg) int sqlgls(char *sqlstm ,size_t
    *stmlen,size_t *sqlfc)
    4. select 문에서 stored function 을 call 할수 있다.
    5. 단 SQLCHECK=FULL/SEMANTICS 가 아닌 경우에 FROM 절에서 subquery 가
    가능하다. 이는 PL/SQL 의 semantic check 인 경우는 v7.3 에서 가능하다 .
    (4) Version 1.8
    ================ 
    1. INDICATOR VARIABLE을 사용하지 않고도 NULL FETCH시 ORA-1405 에러가
    발생하지 않도록 UNSAFE_NULL=YES 옵션이 추가됨. UNSAFE_NULL=YES로
    설정하면 ORA-1405 를 방지하기 위해서 DBMS=V6 으로 세팅할 필요없이
    DBMS=V7 으로 할 수 있음. 단, UNSAFE_NULL=YES를 사용하기 위해서는
    MODE=ORACLE 로 설정해야 함.
    2. PACKAGE ARGUMENT로 PL/SQL CURSOR(WEAKLY TYPED)를 사용할 수 있는데
    예를 들면 TYPE GeneralCurTyp IS REF CURSOR;
    3. FROM 절에서 SUBQUERY를 사용할 수 있고 SQLCHECK=SEMANTICS 또는
    SQLCHECK=FULL 옵션을 사용할 수 있음.
    4. PL/SQL 블럭에서 PL/SQL TABLE과 이와 관련된 다음 함수를 지원.
     a_table(index).EXISTS, a_table.COUNT, a_table.FIRST, a_table.LAST,
    a_table.PRIOR(index), a_table.NEXT(index),
    a_table.DELETE(start_index,_index), a_table.DELETE.
    5. WHERE CURRENT OF CURSOR를 이용해서 MULTI-TABLE VIEW를 통해
    KEY-PRESERVED TABLE을 UPDATE 가능.
    (5) version 2.0
    ==================
    RDBMS version 7.3에서 부터 makefile 은
    ins_precomp.mk,env_precomp.mk, proc.mk의 3 개로 나뉘었다.
    Ins_precomp.mk 는 기존의 proc.mk 처럼 precompiler executables 를 build
    하기 위한 routine 이고 env_precomp.mk 는 모든 environment 의 변수와
    libraray 를 포함한다.
    이 file 은 Ins_precomp.mk 와 proc.mk 에 포함되어 사용되어진다.
    1. V1.6과 같이 AUTO_CONNECT, CONFIG 옵션 지원. SYSTEM CONFIGURATION
    FILE은 UNIX에서는 $ORACLE_HOME/proc/pmscfg.h 이고 VMS에서는
    ora_proc20:pmscfg.cfg
    2. V1.6과 같이 SQLSTATE 변수와 SQLGLS 함수가 제공된다.
    3. C PREPROCESSOR가 포함되어서 #define이 EMBEDDED SQL과 함께 이용될 수
    있고 #include 로 PRO*C 헤더화일을 INCLUDE 가능.
    4. 구조체를 HOST 변수로 사용 가능. 이것은 SELECT INTO, FETCH INTO 
    또는 INSERT시 VALUES 절에 사용될 수 있으나 PL/SQL PROCEDURE에 PL/SQL
    RECORD ARGUMENT로 사용할 수는 없음. 구조체 내에 또다른 구조체를 포함할
    수는 없지만 ARRAY는 포함할 수 있음.
    5. HOST 변수를 BEGIN/END DECLARE SECTION 안에 넣을 필요가 없음.
    6. V1.6에서 처럼 SELECT LIST에 STORED FUNCTION의 사용이 가능.
    7. SQLCHECK=FULL/SEMANTOCS를 사용하지 않는 경우 FROM 절에 SUBQUERY를
    쓸 수 있음.
    8. CHARACTER 변수의 BIND TYPE은 MODE 옵션이 아니라 DBMS 옵션에 따라서
    결정됨. DBMS=V6/V6_CHAR 인 경우, CHARACTER는 TYPE 1, DBMS=V7(또는
    NATIVE이고 ORACLE7에 접속할 때) 에서는 TYPE 97.
    9. DBMS=V6_CHAR 는 CHARACTER 변수가 가변 길이 문자열로 다루어질 수
    있도록 함.
    10. SQLVCP 함수는 VARCHAR ARR 변수를 지정한 길이로 만들어 주므로
    VARCHAR를 동적으로 할당할 때 COMPILER가 BYTE ALIGNMENT를 가능하게 함.
    11. PRO*C의 PARSE LEVEL을 설정하는 PARSE 옵션.
    a) NONE - PRO*C V1과 같음(HOST 변수를 DECLARE SECTION에 넣어야 함.
    #define 인식 안함 등)
    b) PARTIAL - HOST 변수를 DECLARE SECTION에 넣어야 함
    c) FULL - PRO*C V2의 기능 모두 지원
    12. EXEC SQL WHENEVER ... DO 함수명(args,...); 와 같이 함수호출시UMENT를
    주고 받을 수 있음.
    13. #ifdef/#ifndef 와 EXEC ORACLE IFDEF/IFNDEF 에서 사용하기 위한
    DEFINE 옵션 지원.
    (6) version 2.1
    ================
    1. PRO*C V1.7에서와 같이 char와 IMPLICIT VARCHAR (VARCHAR=YES 옵션과
    함께 적절한 C 구조체로 선언된 변수) HOST 변수에서 MULTI-BYTE NLS
    CHARACTER 데이타와 MULTI-BYTE 문자열을 지원.
     NLS_CHAR=var1,var2,... 옵션으로 MULTI-BYTE HOST 변수를 지정함.
    MULTI-BYTE 리터럴은 다음과 같이 사용된다.
     EXEC SQL SELECT ... WHERE ENAME = N*이경구*;
     단, 이것은 SQLLIB RUNTIME LIBRARY를 통해서 지원되기 때문에 MULTI-BYTE
    NLS 문자열은 DYNAMIC SQL에서 사용될 수 없음. NCHAR 데이타타입은 DDL 과
    함께 사용될 수 없음.
    2. PRO*C V1.7과 같이 NLS_LOCAL 옵션 지원
    3. DEF_SQLCODE=YES 로 설정하면 PRO*C는 다음 문장을 생성한다.
     #define SQLCODE sqlca.sqlcode
     SQLCA는 반드시 INCLUDE 되어야 하며 SQLCODE 변수는 선언되어서는 안됨.
    4. PRO*C V1.7 과 같이 CURSOR VARIABLE 지원.
    5. VARCHAR=YES 로 설정하면 특정한 구조체를 VARCHAR로 인식할 수 있다. 
    구조체의 형태를 보면
     struct
     short len;
     char arr[n];
     } host_var;
    6. CODE=CPP 로 설정하면 SQLLIB 함수 원형(PROTOTYPE)은 다음과 같이
    extern "C" 형식으로 생성됨.
     extern "C" {
     void sqlora( unsigned long *, void *);
     그리고 "//" 와 같은 COMMENT 처리명령을 인식함. 단, CODE=CPP인 경우
    PARSE 는 자동적으로 PARTIAL로 설정됨.
     CPP_SUFFIX 옵션은 PRECOMPILE된 화일의 확장자를 지정.
    SYS_INCLUDE=(dir1,dir2,...) 옵션은 C 헤더 화일과 다른 위치에 있는 C++
    헤더 화일이 있는 디렉토리를 지정. 이 옵션은 PARSE 옵션이 NONE이 아닌
    경우에만 필요하다. HEADER 화일을 찾는 위치는 SYS_INCLUDE, 현재 디렉토리,
    표준 SYSTEM 디렉토리(UNIX에서 PRO*C 헤더 화일의 위치는
    $ORACLE_HOME/sqllib/public), 그리고 INCLUDE 옵션에 지정된 디렉토리이다.

  • Problem with Pro*C/C++ complie in linux

    I install Oracle8.1.7 in my Mandrake 7.2 ( like redhat7.1) , and it works well except with proc not works well.
    when I complie the precomp demo program, it gives much errors. I note the proc config file length was zero.
    The following is errors I get when do:
    cd precomp/demo/proc
    make -f demo_proc.mk sample1
    it print very large errors, like follow:
    Pro*C/C++: Release 8.1.7.0.0 - Production on PGFZNe 7TB 6 11:46:04 2001
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    System default option values taken from: /home/u01/precomp/admin/pcscfg.cfg
    Error at line 33, column 11 in file /usr/include/stdio.h
    # include <stddef.h>
    ..........1
    PCC-S-02015, unable to open include file
    Error at line 38, column 11 in file /usr/include/stdio.h
    # include <stdarg.h>
    ..........1
    PCC-S-02015, unable to open include file
    Error at line 29, column 10 in file /usr/include/bits/types.h
    #include <stddef.h>
    .........1
    PCC-S-02015, unable to open include file
    Error at line 14, column 10 in file /usr/include/_G_config.h
    when I run proc without file, it print options as following:
    Pro*C/C++: Release 8.1.7.0.0 - Production on Mon Jul 9 11:19:38 2001
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    System default option values taken from: /home/u01/precomp/admin/pcscfg.cfg
    Option Name Current Value Description
    auto_connect no Allow automatic connection to ops$ account
    char_map charz Mapping of character arrays and strings
    close_on_commitno Close all cursors on COMMIT
    code kr_c The type of code to be generated
    comp_charset multi_byte The character set type the C compiler supports
    config default Override system configuration file with another
    cpp_suffix none Override the default C++ filename suffix
    dbms native v6/v7/v8 compatibility mode
    def_sqlcode no Generate '#define SQLCODE sqlca.sqlcode' macro
    define none Define a preprocessor symbol
    duration transaction Set pin duration for objects in the cache
    dynamic oracle Specify Oracle or ANSI Dynamic SQL Semantics
    errors yes Whether error messages are sent to the terminal
    errtype none Name of the list file for intype file errors
    fips none FIPS flagging of ANSI noncompliant usage
    header none Specify file extension for Precompiled Headers
    hold_cursor no Control holding of cursors in the cursor cache
    iname none The name of the input file
    include none Directory paths for included files
    intype none The name of the input file for type information
    lines no Add #line directives to the generated code
    lname none Override default list file name
    ltype none The amount of data generated in the list file
    maxliteral 1024 Maximum length of a generated string literal
    maxopencursors 10 Maximum number of cached open cursors
    mode oracle Code conformance to Oracle or ANSI rules
    nls_char none Specify National Language character variables
    nls_local no Control how NLS character semantics are done
    objects yes Support object types
    oname none The name of the output file
    oraca no Control the use of the ORACA
    pagelen 80 The page length of the list file
    parse full Control which non-SQL code is parsed
    prefetch 1 Number of rows pre-fetched at cursor OPEN time
    release_cursor no Control release of cursors from cursor cache
    select_error yes Control flagging of select errors
    sqlcheck syntax Amount of compile-time SQL checking
    sys_include none Directory where system header files are found
    threads no Indicates a multi-threaded application
    type_code oracle Use Oracle or ANSI type codes for Dynamic SQL
    unsafe_null no Allow a NULL fetch without indicator variable
    userid none A username/password [@dbname] connect string
    varchar no Allow the use of implicit varchar structures
    version recent Which version of an object is to be returned
    PCC-F-02135, CMD-LINE: User asked for help
    How can I do to solve this problem now?
    Note: I need pro*c/c++ to works well in my project.
    Thank you very much for your kindly help!
    chen chuanwen: [email protected]
    null

    Sorry! I have not explain it clearly.
    To solve it , you do following :
    1. locate stdarg.h ( or find /usr -name stdarg.h ), assume you find a stdarg.h in /usr/lib/gcc-lib/XXX/XXX/include/stdarg.h
    2.ln -s /usr/lib/gcc-lib/XXX/XXX/include/stdarg.h /usr/include/stdarg.h or cp /usr/lib/gcc-lib/XXX/XXX/include/stdarg.h /usr/include
    ( above 2 step was to make Pro*C can find stdarg.h in /usr/include )
    3. for file stddef.h do like step 1,2
    4. append a line in your Pro*C config file:
    CODE=ANSI_C
    null

  • PLS-S-00487, Invalid reference to variable while compiling PRO*C program

    Hi,
    I am writing a PRO*C code and get an error in compilation.
    Code is as below:
    +#include <stdio.h>+
    +#include <string.h>+
    EXEC SQL INCLUDE sqlca.h;
    int main(int argc , char **argv)
    +{+
    int i;
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR connString[100];
    struct emp_record
    +{+
    char name[25];
    char dept[10];
    int id;
    int salary;
    int comm;
    int tot_sal;
    +}e1;+
    EXEC SQL END DECLARE SECTION;
    strcpy (connString.arr, "abcd/efgh@ijkl");
    connString.len = strlen ( connString.arr);
    +printf("\n Connection is [%d][%s]",connString.len,connString.arr);+
    +EXEC SQL CONNECT :connString;+
    +if(sqlca.sqlcode!=0)+
    +{+
    +printf("\nFailed to Connect, sqlcode is %d\n",sqlca.sqlcode);+
    +printf("\nOracle Message = %s", sqlca.sqlerrm.sqlerrmc);+
    +exit(-1);+
    +}+
    +else+
    +{+
    +printf("\nConnected\n");+
    +}+
    +EXEC SQL EXECUTE+
    +BEGIN+
    +emp_calc ( :e1.name,+
    +:e1.id,+
    +:e1.salary,+
    +:e1.tot_sal+
    +);+
    +END;+
    +END-EXEC;+
    +if(sqlca.sqlcode!=0)+
    +{+
    +printf("Oracle Error:[%d][%s]",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);+
    +}+
    +}+
    Procedure code is:
    +CREATE OR REPLACE PROCEDURE "EMP_CALC" (+
    +pi_empname in emp.ename%type,+
    +pi_empno in emp.empno%type,+
    +pi_sal in emp.sal%type,+
    +po_totsal out NUMBER)+
    +is+
    +begin+
    +po_totsal := 1.1 * pi_sal;+
    +dbms_output.put_line('Total Salary is:' || po_totsal);+
    +end;+
    *My main aim is to use elements of a structure in procedure call as parameters*
    *But when I compile I get error on such usage as follows:*
    Pro*C/C++: Release 11.2.0.3.0 - Production on Tue Apr 30 16:59:22 2013
    Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
    System default option values taken from: /mtsapp1/ora11g/product/11.2.0.3/dbhome_1/precomp/admin/pcscfg.cfg
    Error at line 52, column 20 in file singleStructOra.pc
    emp_calc ( :e1.name,
    ...................1
    PLS-S-00487, Invalid reference to variable 'E1'
    Error at line 52, column 1 in file singleStructOra.pc
    emp_calc ( :e1.name,
    1
    PLS-S-00000, Statement ignored
    Semantic error at line 50, column 1, file singleStructOra.pc:
    BEGIN
    1
    PCC-S-02346, PL/SQL found semantic errors
    *I would like to know how to resolve this compilation error and how do I use members of structures in such a procedure call.*
    Thanks....

    Sadly PL/SQL blocks do not understand structs (or arrays). DML statements do understand them.
    This is not very clearly stated in the manual, but it does say:
    http://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_08arr.htm#autoId33
    Restrictions on Arrays of Structs
    The following restrictions apply to the use of arrays of structs in Pro*C/C++:
    Arrays of structs (just as with ordinary structs) are not permitted inside an embedded PL/SQL block.
    http://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_07pls.htm#autoId13
    Do not use C pointer or array syntax in PL/SQL blocks. The PL/SQL compiler does not understand C host-variable expressions and is, therefore, unable to parse them.
    Although the example uses an array of structs, simple structs also fail. I have always had to copy the fields to and from simple variables when calling stored procedures.
    regards,
    David

  • Error in using Array in pro*C

    My test pro*C code is as follows:
    long empIdArray[50];
    EXEC ORACLE OPTION (SELECT_ERROR=NO);
    EXEC SQL
    SELECT emp_id INTO :empIdArray
    FROM emp ;
    /* check error*/
    if ((sqlca.sqlcode != 0) && (sqlca.sqlcode != 1403) && (sqlca.sqlcode != -1405))
    printf("The sqlca.sqlcode <%d>(%s) occured when retrieving data from the emp.", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
    }else if (sqlca.sqlcode == 1403){ /*check no_data_found error*/
    printf("NO Data found error (%s) occured when retrieving data from the emp.", sqlca.sqlerrm.sqlerrmc);
    }else{
    printf("Select successful");
    When running the above code, the error code checking falls in the no_data_found section irrespective of the number of rows in the emp table. As per the documentation, if the number of rows in the emp table is more than 50, then the select statement should bring the first 50 rows. If emp table contains less than 50 rows, the select statement will fetch that much rows.
    Any idea why I'm getting the no_data_found error?

    thanks for reply but,
    I got it, It was a silly error ....the tutorial i referred was old jakarta lib jstl 1.0 based so the URI was http://java.sun.com/jstl/core given into it .but, i was using jstl 1.1 for which URI is http://java.sun.com/jsp/jstl/core. just changed in <tablib> at jsp made the error go away. :)

  • Java File and JSP Page

    I am to create a link verification program -- a simple java file with the database connection & some business logic and a JSP page that instantiates the my java file. It won't work. Everytime I run the jsp page, it gives me java.lang.NullPointerException. Can anyone give me some directions? The web server I am using is JRun.
    Thank you
    Below are my code:
    JSP Page:
    <%--      Verify Links
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@ page import="java.sql.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="pro.*" %>
    <html>
    <head>
    <title>Results</title>
    </head>
    <body>
    <%
    try{
    LinkConnection newconn = new LinkConnection();
    newconn.initialize();
    newconn.query();
    newconn.close();
    }catch (ClassNotFoundException cnfe)
    out.println(cnfe);
    catch (SQLException sqle)
    out.println(sqle);
    catch (NullPointerException npe)
    out.println(npe);
    %>
    </body>
    </html>
    Java Code:
    package pro;
    import java.io.*;
    import java.sql.*;
    import java.net.*;
    public class LinkConnection {
    Connection con;
    ResultSet RS;
    Statement Stmt;
    public void initialize() throws SQLException, ClassNotFoundException
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("XXXX", "XXXX", "XXXX");
    public void query() throws SQLException
    Statement Stmt=con.createStatement();
    String strSQL="Select guideline_name, guideline_url from pgt_guidelines";
    ResultSet RS=Stmt.executeQuery(strSQL);
    while (RS.next())
    String guidelinename = RS.getString("guideline_name");
    String guidelineurl = ("http://" + RS.getString("guideline_url"));
    try {
    URL url = new URL(guidelineurl);
    HttpURLConnection link=(HttpURLConnection)url.openConnection();
    System.out.println("<font color='blue'>");
    System.out.println(guidelinename);
    System.out.println("<br>");
    System.out.println(guidelineurl);
    System.out.println("</font>");
    System.out.println("<font color='red'>");
    System.out.println(link.getResponseCode());
    System.out.println("</font>");
    System.out.println("<br />");
              }catch (Exception e)
              {System.out.println("<font color='yellow'>Error Link </font>")
    public void close() throws SQLException {     
    RS.close();
    Stmt.close();
    con.close();

    i'm having the same problem, what is the solution to this
    A Servlet Exception Has Occurred
    java.lang.NullPointerException
         at test.Lesson.runSql(Lesson.java:80)
    ===== Lesson.java file =====
    package test;
    import java.sql.* ;
    import java.io.Serializable;
    public class Lesson {
         public Lesson( ) { }
    //Line 9
         public String runSql ( ) {
              String browserOutput = "";
              Connection sqlca = null;
              Statement sqlStatement = null;
              ResultSet myResultSet = null;
    //Line 16
              /* Connect to database, run SQL and produce output */
              try { 
                   /* Connection to the database */
                   Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                   String theDatabase ="jdbc:mysql://localhost/employee";
                   sqlca = DriverManager.getConnection(theDatabase,"usr","pwd");
    //Line 24
                   /* Construct and execute the sql, positioning before the
                   first row in the result set */
                   sqlStatement = sqlca.createStatement();
                   myResultSet = sqlStatement.executeQuery
    //Line 29
                   ("select emp_id, " +
                        "emp_lname, " +
                        "city, " +
                        "state," +
                        "zip_code, " +
                        "emp_fname " +
                        "from employee " +
                        "where emp_id < 250 " +
                        "order by emp_lname, emp_fname");
    //Line 39
                   /* Construct the heading for the table */
                   browserOutput =
                        "<div align=left>"+
                        "<table border=0 align=left width=520>" +
                        "<caption><i><b>" +
                        "Employee Listing</b></i></caption>" ;
    //Line 46
                   /* Construct the column headings for the table */
                   browserOutput +=
                        "<th align=left>Emp_id</th>" +
                        "<th>First Name</th>" +
                        "<th>Last Name</th>" +
                        "<th>City</th>" +
                        "<th>State</th>" +
                        "<th>Zip</th>" ;
    //Line 55
                   /* Move to next row and & its contents to the html output */
                   while(myResultSet.next()) {
                        browserOutput += "<TR><TD>" +
                   myResultSet.getObject("emp_id").toString() + "</TD><TD>" +
                   myResultSet.getObject("emp_fname").toString()+"</TD><TD>" +
                   myResultSet.getObject("emp_lname").toString() + "</TD><TD>" +
                   myResultSet.getObject("city").toString() + "</TD><TD>" +
                   myResultSet.getObject("state").toString() + "</TD><TD>" +
                   myResultSet.getObject("zip_code").toString() + "</TD></TR>" ;
    //Line 66
                   }//end of while
                   sqlStatement.close();
                   sqlca.close();
              }//end of try
              catch (SQLException e) {
    //Line 72
                   browserOutput = " Error: SQLException: " + e.getMessage();
                   browserOutput= " Error: SQLState: " + e.getSQLState();
                   browserOutput= " VendorError: " + e.getErrorCode();
              }//end of SQLException
              catch (Exception e) {
                   browserOutput = " Error: JDBC Class creation: " + e.getMessage();
              }//end of Exception
    /**Line 80**/     finally {
                   try { sqlca.close(); }
                   catch(SQLException e) {
                   browserOutput = " Error: Closing connection: " + e.getMessage();
              }//end of finally
         /* Complete the html and return it to the Java Server Page */
         browserOutput += "</table>" + "</div>" ;
         return browserOutput;
         } //end of runSql
    }//end of Lesson

  • Embedde SQL Examples

    Hello,
    i installed the 11.1 Database for 32 bit windows on my system.
    I want to use the embedded sql interface.
    I am missing the examples for visual Studio, the description in the documentation is for the old Studio (6.0)
    and i am not getting it to work.
    The Precompiler doesn't run correctly.
    Is it possible to display the proc.exe file statement in an output window, i only the the error.
    1>------ Erstellen gestartet: Projekt: ProcSample, Konfiguration: Debug Win32 ------
    1>Oracle Precompiler
    1>Pro*C/C++: Release 11.1.0.6.0 - Production on Di Dez 1 17:07:58 2009
    1>Copyright (c) 1982, 2007, Oracle. All rights reserved.
    1>System-Standardoptionswerte aus: c:\oracle\product\11.1.0\db_1\precomp\admin\pcscfg.cfg
    1>Optionsname Aktueller Wert Beschreibung
    1>-------------------------------------------------------------------------------
    1>auto_connect Nein Automatische Anmeldung bei Account ops$
    1> zulassen
    1>char_map charz Zuordnung von Zeichen-Arrays und Zeichenfolgen
    1>close_on_commitNein Alle Cursor bei COMMIT schlie▀en
    1>cmax 100 CMAX-Wert f³r Connection-Pool
    1>cmin 2 CMIN-Wert f³r Connection-Pool
    1>cincr 1 CINCR-Wert f³r Connection-Pool
    1>ctimeout 0 CTIMEOUT-Wert f³r Connection-Pool
    1>cnowait 0 CNOWAIT-Wert f³r Connection-Pool
    1>common_parser Nein Mit Common SQL Frontend parsen
    1>code ansi_c Der zu generierende Codetyp
    1>comp_charset multi_byte Der Zeichensatztyp, den der C Compiler
    1> unterst³tzt
    1>config default Systemkonfigurationsdatei durch andere Datei
    1> au▀er Kraft setzen
    1>cpool Nein Unterst³tzung von Connection-Pooling
    1>cpp_suffix kein Standardmõ▀iges C++ Dateinamensuffix au▀er
    1> Kraft setzen
    1>db2_array Nein Unterst³tzung von DB2 Array
    1> Insert/Select-Syntax
    1>dbms native v6/v7/v8-Kompatibilitõts-Modus
    1>def_sqlcode Nein Makro '#define SQLCODE sqlca.sqlcode'
    1> generieren
    1>define WIN32_LEAN_AND_Prõprozessor-Symbol definieren
    1>duration transaction Pin-Dauer f³r Objekte im Cache festlegen
    1>dynamic oracle Oracle oder ANSI Dynamic SQL Semantics angeben
    1>errors Ja Angabe, ob Fehlermeldungen an das Terminal
    1> gesendet werden
    1>errtype kein Name der Listendatei f³r Intype-Dateifehler
    1>events Nein Publish/Subscribe-Ereignisbenachrichtigungen
    1> unterst³tzen
    1>fips none FIPS-Flagging von nicht konformer ANSI-Nutzung
    1>header kein Dateinamenerweiterung f³r vorkompilierte Header
    1> angeben
    1>hold_cursor Nein Halten von Cursorn im Cursor-Cache
    1> kontrollieren
    1>implicit_svpt Nein Impliziter Savepoint vor gepufferter
    1> Insert-Anweisung
    1>iname kein Name der Eingabedatei
    1>include kein Verzeichnispfade f³r enthaltene Dateien
    1>intype kein Name der Eingabedatei f³r Typinformationen
    1>lines Nein #line-Anweisungen zu dem generierten Code
    1> hinzuf³gen
    1>lname kein Standard-Listendateiname au▀er Kraft setzen
    1>ltype none In der Listendatei generierte Datenmenge
    1>maxliteral 1024 Max. Lõnge des generierten
    1> Zeichenfolgenliterals
    1>maxopencursors 10 Max. Anzahl von ge÷ffneten Cursorn im Cache
    1>max_row_insert 0 Max. Anzahl von Zeilen, die in Insert-Anweisung
    1> gepuffert werden m³ssen
    1>mode oracle Code-▄bereinstimmung mit Oracle- oder
    1> ANSI-Regeln
    1>native_types Nein Unterst³tzung von systemeigenem Float/Double
    1>nls_char kein Lõnderspezifische Zeichenvariablen angeben
    1>nls_local Nein NLS-Zeichensemantik kontrollieren
    1>objects Ja Objekttypen unterst³tzen
    1>oname kein Name der Ausgabedatei
    1>oraca Nein Benutzung von ORACA kontrollieren
    1>outline no Kategorie, in der Outlines erstellt werden
    1> [yes/no/<category name>]
    1>outlnprefix kein Prõfix des Outline-Namens
    1>pagelen 80 Seitenlõnge der Listendatei
    1>parse none Kontrollieren, welcher Nicht-SQL-Code
    1> analysiert wird
    1>prefetch 1 Anzahl von Zeilen, die im Voraus beim Íffnen
    1> des Cursors (mit OPEN) abgerufen wurden
    1>release_cursor Nein Freigabe von Cursorn aus Cursor-Cache
    1> kontrollieren
    1>runoutline Nein Wenn ja, Outlines in der Datenbank erstellen
    1>select_error Ja Flagging von Select-Fehlern kontrollieren
    1>sqlcheck syntax Umfang der SQL-Pr³fung beim Kompilieren
    1>stmt_cache 0 Gr÷▀e des Anweisungs-Caches
    1>sys_include kein Verzeichnis, in dem System-Header-Dateien
    1> gespeichert sind
    1>threads Nein Gibt eine Multi-Threaded-Anwendung an
    1>type_code oracle Oracle- oder ANSI-Codes f³r Dynamic SQL
    1> verwenden
    1>unsafe_null Nein NULL-Fetch ohne Indikatorvariable zulassen
    1>userid kein Connect-String Benutzername/Kennwort [@dbname]
    1>utf16_charset nchar_charset Zeichensatz-Form, wie von UTF16-Variablen
    1> benutzt
    1>varchar Nein Benutzung von impliziten Varchar-Strukturen
    1> zulassen
    1>version recent Angabe, welche Version eines Objekts
    1> zur³ckgegeben werden muss
    1>win32_threads Nein Unterst³tzung von standardmõ▀igem lokalen
    1> Windows-Threading
    1>PCC-F-02135, CMD-LINE: Benutzer hat Hilfe angefordert
    1>Project : error PRJ0019: Ein Tool hat einen Fehlercode aus folgender Quelle zurückgegeben: "Oracle Precompiler"
    1>Das Buildprotokoll wurde unter "file://c:\Users\behli\Documents\Visual Studio 2008\Projects\ProcSample\ProcSample\Debug\BuildLog.htm" gespeichert.
    1>ProcSample - 1 Fehler, 0 Warnung(en)
    ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
    When i compile the file on the command line:
    proc.exe sample.pc
    it works correctly.
    Can anybody help me?
    Geetings
    Thomas

    Your question has everything to do with Microsoft and nothing to do with the topic of this forum which is "Database >> Installation."
    To get help either post in the correct .NET related forum or ask Microsoft how to make their tool work properly.

  • Howto cleanup memory after an exception

    Hello Forum,
    i wrote a small test program that only creates and deletes a table with createStatement("someSQL") and execute().
    After this is done i call terminateStatement ();
    That all works fine if only one instance of this program is running.
    If I start a second instance, a SQLException may be thrown
    like "table exist" or "table does not exist". That is ok !
    Now The question :-) :
    In the catch statement i call terminateStatement() too
    but the use of memory grows and grows .
    What is the right way to clean up memory if a SQLException it thrown without terminating the connection or delete the environment with
    mpOraEnvironment->terminateConnection (mpOraConnection);
    Environment::terminateEnvironment (mpOraEnvironment);
    Greetings from Duesseldorf

    Hi Andreas,
    In Pro*C, you can make use of the SQLCA structure, e.g., sqlca.sqlcode, sqlca.sqlerrd[2], etc. for sepecific error handling depending on the needs.
    At the same time, may be you wanna check-out Section 9 (Handling Runtime Error) of the Pro*C/C++ Precompiler Programmer's Guide.
    Cheers,
    Chew

  • Multiple SQL_HANDLE_DBC handles do not work on Linux

    Hello,
    I am seeing the following error from the SQL Server Driver For Linux when I attempt to execute a query on a SECOND connection within my application:
    SQLSTATE: IM001
    Native Error Code: 0
    Message: [unixODBC][Driver Manager]Driver does not support this function
    I have compiled/run the test case I have on Windows and the code executes without issue.
    Here is my test case:
    // SQLGetData.cpp
    // g++ -M64 -I$ODBC/include -L$ODBC/lib -g -lodbc sqlgetdata.cpp
    // cl sqlgetdata2.cpp odbc32.lib
    // CREATE TABLE tstDFRBLB(col1 varbinary(max))
    #if defined(_WIN32)
    #include <windows.h>
    #endif
    #include <stdlib.h>
    #include <stdio.h>
    #include <sql.h>
    #include <sqlext.h>
    void checkError ( SQLRETURN rc, const char *cstr )
    if( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO ) {
    return ;
    } else if( rc == SQL_INVALID_HANDLE ) {
    fprintf( stderr, "Error: invalid handle: %s.\n", cstr ) ;
    } else {
    fprintf( stderr, "Unknown Error occured in %s: code %d.\n", cstr, rc ) ;
    void checkStmtError( SQLRETURN rc, SQLHSTMT stmth )
    if(rc != SQL_SUCCESS) {
    int i = 1 ;
    SQLSMALLINT length;
    SQLINTEGER sqlcode;
    SQLCHAR *sqlstate = (SQLCHAR *) malloc(100 * sizeof(SQLCHAR));
    SQLCHAR *message = (SQLCHAR *) malloc(1000 * sizeof(SQLCHAR));
    while ( SQLGetDiagRec( SQL_HANDLE_STMT, stmth, i, sqlstate, &sqlcode,
    message, 1000, &length ) == SQL_SUCCESS ) {
    printf( "\nSQLSTATE: %s\n", sqlstate ) ;
    printf( "Native Error Code: %ld\n", sqlcode ) ;
    printf( "Message: %s\n", message ) ;
    i++ ;
    delete sqlstate;
    delete message;
    int main( int ac, char **av )
    SQLHENV envh ;
    SQLHDBC dbch ;
    SQLHDBC dbch2 ;
    SQLRETURN rc ;
    SQLHSTMT stmth ;
    const char *select_stmt = "SELECT * FROM tstDFRBLB" ;
    /* Allocate a environment handl */
    rc = SQLAllocHandle( SQL_HANDLE_ENV, // Handle type
    SQL_NULL_HANDLE,
    &envh // SQLHENV handle (environment)
    checkError( rc, "SQLAllocHandle - SQL_HANDLE_ENV" ) ;
    /* Set environment attributes */
    rc = SQLSetEnvAttr( envh, // Environment handle
    SQL_ATTR_ODBC_VERSION, // Attribute to set
    (SQLPOINTER) SQL_OV_ODBC3,// New attribute
    SQL_NTS // SQL_NTS (null terminated)
    checkError( rc, "SQLSetEnvAttr" ) ;
    /* Allocate a database connection handle */
    rc = SQLAllocHandle( SQL_HANDLE_DBC, // Handle Type
    envh, // Where to attatch the new handle
    &dbch // Pointer to new handle
    checkError( rc, "SQLAllocHandle - SQL_HANDLE_DBC" ) ;
    /* Establish a connection */
    SQLCHAR outStr[1024];
    SQLSMALLINT outSize;
    rc = SQLDriverConnect(dbch, NULL,
    #if defined(_WIN32)
    (SQLCHAR*)"DSN=MSSQL_2012_NC_64;UID=*****;PWD=*****;DATABASE=qe1;", 57,
    #else
    (SQLCHAR*)"DSN=mssql-2012-md_64;UID=*****;PWD=*****;DATABASE=qe1;", 57,
    #endif
    outStr, sizeof(outStr), &outSize, SQL_DRIVER_NOPROMPT);
    /* Allocate a second database connection handle */
    rc = SQLAllocHandle( SQL_HANDLE_DBC, // Handle Type
    envh, // Where to attatch the new handle
    &dbch2 // Pointer to new handle
    checkError( rc, "SQLAllocHandle - SQL_HANDLE_DBC" ) ;
    rc = SQLSetConnectAttr(dbch2,
    SQL_ODBC_CURSORS,
    (SQLPOINTER)SQL_CUR_USE_DRIVER,
    (SQLINTEGER)NULL); // this value is ignored
    checkError( rc, "SQLSetConnectAttr - SQL_ODBC_CURSORS" ) ;
    rc = SQLDriverConnect(dbch2, NULL,
    #if defined(_WIN32)
    (SQLCHAR*)"DSN=MSSQL_2012_NC_64;UID=*****;PWD=*****;DATABASE=qe1;", 57,
    #else
    (SQLCHAR*)"DSN=mssql-2012-md_64;UID=*****;PWD=*****;DATABASE=qe1;", 57,
    #endif
    outStr, sizeof(outStr), &outSize, SQL_DRIVER_NOPROMPT);
    rc = SQLAllocHandle( SQL_HANDLE_STMT, dbch2, &stmth ) ;
    checkError( rc, "SQLAllocHandle - SQL_HANDLE_STMT" ) ;
    ** Read the value back
    rc = SQLExecDirect( stmth, (SQLCHAR*)select_stmt, SQL_NTS ) ;
    checkStmtError( rc, stmth );
    char outWData[168000];
    SQLLEN outInd = 0;
    while ( SQLFetch( stmth ) == SQL_SUCCESS )
    rc = SQLGetData( stmth, 1, SQL_C_BINARY, outWData, sizeof(outWData), &outInd );
    checkStmtError( rc, stmth );
    if(outInd == SQL_NULL_DATA) {
    printf("Data Returned: NULL\n");
    else {
    printf("Data Returned Length %d\n", outInd);
    rc = SQLMoreResults(stmth);
    checkStmtError( rc, stmth );
    /* Disconnect from the database */
    rc = SQLDisconnect( dbch2 ) ;
    checkError( rc, "SQLDisconnect" ) ;
    /* Free connection and environment handles */
    rc = SQLFreeHandle( SQL_HANDLE_DBC, dbch2 ) ;
    checkError( rc, "SQLDisconnect" ) ;
    /* Disconnect from the database */
    rc = SQLDisconnect( dbch ) ;
    checkError( rc, "SQLDisconnect" ) ;
    /* Free connection and environment handles */
    rc = SQLFreeHandle( SQL_HANDLE_DBC, dbch ) ;
    checkError( rc, "SQLDisconnect" ) ;
    SQLFreeHandle( SQL_HANDLE_ENV, envh ) ;
    checkError( rc, "SQLDisconnect" ) ;
    return EXIT_SUCCESS ;
    Thank you for any help/advice.
    Dave
    David Ritter

    Hi David,
    According to your description, the code running smoothly in windows, and getting this problem when using SQL Server driver for linux.
    So, what's the version of your SQL Server driver for linux?
    As per the error message, the function is not supported, so could you please check the configuration of the driver or there are some limitation in the driver you used?
    Please follow these links to have a check:
    The ODBC Driver 11 for SQL Server on 64-bit Red Hat Enterprise Linux 5 and 64-bit Red Hat Enterprise Linux 6.
    You can download the ODBC driver for Red Hat at
    Microsoft ODBC Driver for SQL Server.
    The ODBC Driver 11 for SQL Server on 64-bit SUSE Linux Enterprise 11 Service Pack 2. This driver is currently available as a Community Technology Preview (CTP).
    You can download the ODBC driver for SUSE Linux at
    Microsoft ODBC Driver 11 for SQL Server on SUSE Linux.
    If you have any feedback on our support, please click
    here.
    Iric Wen
    TechNet Community Support

  • Error: ORA-01012: not logged on

    Hi all,
    i have a program to update 2 tables and will commit every transaction for each table. firstly, my program will commit transaction in Table A then once it's done, it will commit Table B and loop again(both table) until all transactions finish.But at the end of the process, i get the error msg:
    Error: ORA-01012: not logged on
    I suspected this error because of COMMIT issue in my program.
    Kindly need someone to assist me.
    Here i attached my code for your reference.
    EXEC SQL DECLARE fs_cursor CURSOR FOR SELECT fs.FILE_ID FROM FILE_STATUS fs
    where fs.JOB_ID = 'brm_pymntd01l' and fs.status = 'N'
    FOR UPDATE OF fs.STATUS;
    EXEC SQL OPEN fs_cursor;
    EXEC SQL WHENEVER NOT FOUND DO break;
    for (;;)
    rec_ctr = 0;
    /** Reset the sqlcode **/
    sqlca.sqlcode=0;
    EXEC SQL FETCH fs_cursor INTO :FILEID;
    EXEC SQL DECLARE ft_cursor CURSOR FOR SELECT FT.RECORD_ID FROM FILE_DETAIL FT WHERE FT.STATUS = 'N' AND FT.FILE_ID = :FILEID;
              EXEC SQL OPEN ft_cursor;
    EXEC SQL WHENEVER NOT FOUND DO break;           
    if ( sqlca.sqlcode == 0)
    for (;;)
                   EXEC SQL FETCH ft_cursor INTO :RECORD_ID;
    EXEC SQL DECLARE fd_cursor ...
    FROM FILE_DETAIL fd where fd.RECORD_ID = :RECORD_ID and fd.file_id = :FILEID FOR UPDATE OF fd.STATUS;
    EXEC SQL OPEN fd_cursor;
    /** Reset the sqlcode **/
    sqlca.sqlcode=0;
    EXEC SQL FETCH fd_cursor INTO :COL1, :COL2, :COL3, :COL4, :COL5, :COL6, :COL7, :COL8, :COL9,
    :COL10, :COL11, :COL13, :COL14, :COL15,
    :COL16, :COL19, :COL20, :COL21, :COL22, :COL24, :COL25, :COL26, :COL27, :STATUS;
    if (validate_record(dbschema,logfp,&ebuf))
    trim_spaces();
    process_flag = process(ctxp, database, &ebuf, logfp, dbschema);
    time(&status_upd_date);
    strcpy(current_time, ctime(&status_upd_date));
    if(process_flag == PROCESS_SUCCESS)
    if (updateChargeEvent == 1) {
    PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "*******Update Charge Event\0");
    ret = update_charge_event(ctxp, database, &ebuf, ACCOUNT_NO, PAYMENT_DATE);
    if(ret != 1)
    strcpy(NEW_STATUS, "P");
    sprintf(msg,"Transaction [PUKAL update status] error. Please check cm.pinlog.");
    strcpy(REC_ERROR_CODE, ERR_GET_UPD_PUKAL_EVENT);
    strcpy(REC_ERROR_DESCR,msg);
    log(msg, logfp);
    log("\n",logfp);
    }else{
    strcpy(NEW_STATUS, "C");
    strcpy(NEXT_BILL_T, NEXT_BILL_DATE);
    else if (rebateSucess != 0)
    strcpy(NEW_STATUS, "P");
    sprintf(msg,"Transaction [apply_rebate] error. Please check cm.pinlog.");
    strcpy(REC_ERROR_CODE, ERR_GET_APPLY_REBATE);
    strcpy(REC_ERROR_DESCR,msg);
    log(msg, logfp);
    log("\n",logfp);
    else {
    strcpy(NEXT_BILL_T, NEXT_BILL_DATE);
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    COL23 = :NEXT_BILL_DATE,
    COL27 = :COLUMN_27
    WHERE RECORD_ID = :RECORD_ID;
    else
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    ERROR_CODE = :REC_ERROR_CODE,
    ERROR_DESC = :REC_ERROR_DESCR
    WHERE RECORD_ID = :RECORD_ID;
    ret = JOB_WARNING;
    else
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_DETAIL
    SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY'),
    ERROR_CODE = :REC_ERROR_CODE,
    ERROR_DESC = :REC_ERROR_DESCR
    WHERE RECORD_ID = :RECORD_ID;
    ret = JOB_WARNING;
    else{   
    PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "Error running query");
    printf("\nError: %.70s \n",sqlca.sqlerrm.sqlerrmc);
    EXEC SQL CLOSE fd_cursor;
         EXEC SQL COMMIT;
         rec_ctr ++;
         EXEC SQL CLOSE ft_cursor;
    time(&status_upd_date);
    strcpy(current_time, ctime(&status_upd_date));
    if (rec_ctr > 0)
    /* Check if all records had failed, one record had failed
    or everything is successfully processed. Then update
    file_status table. */
    int ret_status;
    ret_status = updateFileStatus(dbschema, FILEID, logfp);
    if (ret_status == ALL_REC_FAILED)
    strcpy(NEW_STATUS, "F");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    else if (ret_status == ONE_REC_FAILED)
    strcpy(NEW_STATUS, "P");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    else if (ret_status == ALL_SUCCESS)
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
    /* Else do nothing error handling is done within
    * the function. */
    else{}
    else{
    /*If its an empty file, update file_status to 'C'
    so that the program will no longer fetch this record
    on the next run. */
    strcpy(NEW_STATUS, "C");
    EXEC SQL UPDATE FILE_STATUS SET STATUS = :NEW_STATUS,
    STATUS_UPD_DATE = to_date(:current_time,'DY MON DD hh24:mi:ss YYYY')
    WHERE CURRENT OF fs_cursor;
         EXEC SQL COMMIT WORK RELEASE;
    //process by not update by per transaction at staging
         EXEC SQL CLOSE fs_cursor;
    if(sqlca.sqlcode == 0)
    ret = JOB_SUCCESS;
    else
    EXEC SQL ROLLBACK WORK RELEASE;
    Thank a lots!

    what data did not get COMMITted?

  • Com.ibm.db2.jcc.b.SqlException: DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000

    Hi,
    We are running WebLogic 10.3.0 on RHEL 5.3 with JRockit JDK 1.6 and DB2 Version 8 on mainframe running z/OS 1.9.
    We are getting below exception in webLogic logs from connection pool connecting to DB2 database.
    >
    ####<Jul 23, 2010 10:05:49 AM EDT> <Warning> <JDBC> <testing.us.test.net> <testingDB2> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1279893949615> <BEA-001129> <Received exception while creating connection for pool "TestDB2Pool": DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000, SQLERRMC=MON_HEAP_SZ, DRIVER=3.53.70>
    ####<Jul 23, 2010 10:05:49 AM EDT> <Info> <JDBC> <testing.us.test.net> <testingDB2> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1279893949616> <BEA-001156> <Stack trace associated with message 001129 follows:
    com.ibm.db2.jcc.b.SqlException: DB2 SQL Error: SQLCODE=-973, SQLSTATE=00000, SQLERRMC=MON_HEAP_SZ, DRIVER=3.53.70
         at com.ibm.db2.jcc.b.bd.a(bd.java:679)
         at com.ibm.db2.jcc.b.bd.a(bd.java:60)
         at com.ibm.db2.jcc.b.bd.a(bd.java:127)
         at com.ibm.db2.jcc.b.jb.a(jb.java:4016)
         at com.ibm.db2.jcc.t4.bb.l(bb.java:403)
         at com.ibm.db2.jcc.t4.bb.d(bb.java:141)
         at com.ibm.db2.jcc.t4.b.Oc(b.java:1305)
         at com.ibm.db2.jcc.t4.b.b(b.java:1225)
         at com.ibm.db2.jcc.t4.b.B(b.java:5129)
         at com.ibm.db2.jcc.t4.b.c(b.java:783)
         at com.ibm.db2.jcc.t4.b.b(b.java:726)
         at com.ibm.db2.jcc.t4.b.a(b.java:409)
         at com.ibm.db2.jcc.t4.b.<init>(b.java:345)
         at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:197)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(ConnectionEnvFactory.java:316)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:217)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1109)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1033)
         at weblogic.common.resourcepool.ResourcePoolImpl.createResources(ResourcePoolImpl.java:574)
         at weblogic.jdbc.wrapper.Connection.run(Connection.java:268)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    >
    Below is snippet of my datasource configuration.
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/jdbc-data-source" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/jdbc-data-source http://www.bea.com/ns/weblogic/jdbc-data-source/1.0/jdbc-data-source.xsd">
    <name>TestingDB2</name>
    <jdbc-driver-params>
    <url>jdbc:db2://DB2.testing.us.com:50003/TestingDB</url>
    <driver-name>com.ibm.db2.jcc.DB2Driver</driver-name>
    <properties>
    <property>
    <name>maxRetriesForClientReroute</name>
    <value>2</value>
    </property>
    <property>
    <name>retryIntervalForClientReroute</name>
    <value>5</value>
    </property>
    <property>
    <name>user</name>
    <value>testuser</value>
    </property>
    <property>
    <name>resultSetHoldability</name>
    <value>2</value>
    </property>
    <property>
    <name>enableSysplexWLB</name>
    <value>true</value>
    </property>
    <property>
    <name>enableConnectionConcentrator</name>
    <value>true</value>
    </property>
    <property>
    <name>databaseName</name>
    <value>DB2QA</value>
    </property>
    <property>
    <name>maxTransportObjects</name>
    <value>108</value>
    </property>
    </properties>
    <password-encrypted>{3DES}eh4WI16Xb8E=</password-encrypted>
    </jdbc-driver-params>
    <jdbc-connection-pool-params>
    <initial-capacity>40</initial-capacity>
    <max-capacity>215</max-capacity>
    <capacity-increment>1</capacity-increment>
    <shrink-frequency-seconds>300</shrink-frequency-seconds>
    <highest-num-waiters>2147483647</highest-num-waiters>
    <connection-creation-retry-frequency-seconds>15</connection-creation-retry-frequency-seconds>
    <connection-reserve-timeout-seconds>10</connection-reserve-timeout-seconds>
    <test-frequency-seconds>300</test-frequency-seconds>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <ignore-in-use-connections-enabled>true</ignore-in-use-connections-enabled>
    <inactive-connection-timeout-seconds>300</inactive-connection-timeout-seconds>
    <test-table-name>SYSIBM.SYSDUMMY</test-table-name>
    <login-delay-seconds>1</login-delay-seconds>
    <statement-cache-size>300</statement-cache-size>
    <statement-cache-type>LRU</statement-cache-type>
    <remove-infected-connections>true</remove-infected-connections>
    <seconds-to-trust-an-idle-pool-connection>15</seconds-to-trust-an-idle-pool-connection>
    <statement-timeout>-1</statement-timeout>
    <pinned-to-thread>false</pinned-to-thread>
    </jdbc-connection-pool-params>
    <jdbc-data-source-params>
    <jndi-name>TestingDB2</jndi-name>
    <global-transactions-protocol>None</global-transactions-protocol>
    </jdbc-data-source-params>
    </jdbc-data-source>
    Please help me on this.
    - BoyelT

    Thanks Joe. I will test the standalone client program you provided.
    Below are links I found on web on SQL CODE -972 error message
    http://www.dbforums.com/db2/875633-sqlcode-973-sqlstate-57011-drda_heap_sz-cobol-db2-error.html
    http://publib.boulder.ibm.com/infocenter/tivihelp/v4r1/index.jsp?topic=/com.ibm.tpc_V411.doc/fqz0_r_tbs_db2_sql_973.html
    http://www-01.ibm.com/support/docview.wss?uid=swg1IY55389
    Below is explanation about this message
    ===============================================
    SQL0973N Not enough storage is available in the "<heap-name>" heap to process the statement.
    Explanation: All available memory for this heap has been used. The statement cannot be processed.
    User Response: Terminate the application on receipt of this message (SQLCODE). Increase the configuration parameter for "<heap-name>" to increase the heap size.
    ===============================================
    Can you please advise if this is the problem from DBMS side?

  • Newbie question: sqlca.sqlcode positive or negative?

    Good afternoon,
    we have a database based application, launching SQL queries on an Oracle 8.1.7 database.
    These queries return sqlca.sqlcode values, like 0 in case of succesful and 1403/-1403 in case of unsuccesful.
    Exactly the latter is a problem: the whole application is based on the following condition:
    sqlca.sqlcode = 0 => OK
    sqlca.sqlcode < 0 => NOK
    This works fine on our test lab, where the return values are always negative (-1403) in case of a "not found", but it seems that at client's side, sometimes a positive value (1403) pops up, resulting in a bad behaviour.
    My question: is it possible to configure Oracle in such a way that the return codes are always negative (in order for us not to change the whole application)?
    Thanks
    Dominique

    Thanks for the fast reply.
    The mentioned solution however doesn't work:
    1. The problem is not that I always have a positive value, but sometimes a positive and sometimes a negative one, so multiplying with -1 would just turn bad results into good ones and vice versa.
    2. Moreover in order to change the value of the code, I would need to change the application, and I am looking for a way in which I don't need to do so. I am looking for an Oracle parameter that prevents differents signatures for the same SQL return codes.
    Kind regards
    Dominique

  • Pro*C  using client server and the sqlca - any takers

    Hi all
    This is my 1st post and it's about Pro*C.
    At work, we are porting our Pro*C apps from VMS to XP/NT. Has anyone done this before, anything to be aware of?
    Also am planning a client/server architechture for my next project, but with Pro*c, and am concerned about the conficts of using the sqlca between child processes...any ideas/suggetions?

    Don't cross post
    [http://forums.sun.com/thread.jspa?threadID=5384591&messageID=10700568#10700568]

  • Pro*C problem - help !!!

    Hi,
    I have a Pro*C application that performs a select statment, opens a cursor, executes a while loop and retrieves the select results in an array. The while loop exit condition is SQL code 1403 - NOT FOUND. The problem is in that when I run the query through a terminal monitor, JDBC explorer or SLQ Plus 8.0, I get 68 rows back, however, the Pro*C application only returns 63 rows and no errors. Checking the sqlca.sqlerrd[2] variable reports that only 63 rows were processed. SQLSTATE and SQLCODE do not return any errors. I'm sure the query is identical as I copied and pasted it into the "SqlPlus 8.0" monitor and replaced all place holder variables with the actual values used in the Pro*C application. I have implemented the same code with PL/SQL and it works ok, returning 68 rows.
    I'm developing in a Sun Solaris environment, using Oracle 8.1.7.
    Any ideas will be grealty appreciated.
    Cheers,
    Steve

    I think you should post this question in the right forum:
    C++ Call Interface (OCCI)
    --Andy                                                                                                                                                                                                                                                           

  • Pro*C problem - pleas ehelp

    Hi,
    I have a Pro*C application that performs a select statment, opens a cursor, executes a while loop and retrieves the select results in an array. The while loop exit condition is SQL code 1403 - NOT FOUND. The problem is in that when I run the query through a terminal monitor, JDBC explorer or SLQ Plus 8.0, I get 68 rows back, however, the Pro*C application only returns 63 rows and no errors. Checking the sqlca.sqlerrd[2] variable reports that only 63 rows were processed. SQLSTATE and SQLCODE do not return any errors. I'm sure the query is identical as I copied and pasted it into the "SqlPlus 8.0" monitor and replaced all place holder variables with the actual values used in the Pro*C application.
    I'm developing in a Sun Solaris environment, using Oracle 8.1.7.
    Any ideas will be grealty appreciated.
    Cheers,
    Steve

    Scott Dudley (guest) wrote:
    : Folks,
    : I received my pre-release CD 6 weeks or so ago. Installation
    was
    : a snap. I managed to get the database going, tns, client-
    server,
    : etc - no problem. I'm now ready to begin Pro*C development.
    : First of all, I noticed there's no proc/demo subdirectory (no
    : Pro*C demo). When I run the precompiler, I get numerous error
    : messages. The following are snippets from stdout:
    : Pro*C/C++: Release 8.0.5.0.0 - Production on Mon Nov 23
    21:47:20
    : 1998
    : (c) Copyright 1998 Oracle Corporation. All rights reserved.
    : System default option values taken from:
    : /usr/oracle/precomp/admin/pcscfg.cfg
    : Error at line 13, column 10 in file /usr/include/_G_config.h
    : #include <stddef.h>
    : .........1
    : PCC-S-02015, unable to open include file
    : Error at line 47, column 10 in file /usr/include/libio.h
    : #include <stdarg.h>
    : .........1
    : PCC-S-02015, unable to open include file
    : Syntax error at line 317, column 19, file /usr/include/libio.h:
    : Error at line 317, column 19 in file /usr/include/libio.h
    : extern IOsize_t IOsgetn __P((_IO_FILE *, void*,
    IOsize_t));
    : The symbol ";" was substituted for "_IO_sgetn" to continue.
    : Syntax error at line 66, column 9, file /usr/include/stdio.h:
    : Error at line 66, column 9 in file /usr/include/stdio.h
    : typedef IOsize_t size_t;
    : Any clues? GCC and Kernel were up to par (Red Hat 5.1 out of
    the
    : can). I'm desperate!
    : Many thanks.
    Try using makefile file $ORACLE_HOME/plsql/demo/demo_plsql.mk
    null

Maybe you are looking for

  • I want to upgrade my graphic card

    here is my info: Product Name        15-n037se Product Number        F1E67EA#ABV Microprocessor        Intel Core i7-4500U (1.8 GHz, 4 MB cache, 2 cores) Memory        8 GB DDR3L Video Graphics        NVIDIA GeForce GT 740M (2 GB DDR3 dedicated) Hard

  • How do I remove the cells from footer in Pages 5.5.2?

    In the new Pages, version 5.5.2, my footers have cells. I want to have only one cell but can't find a way to remove the cell barriers.

  • ORABPEL-09705 error while deploying SOA project

    Hi, I am trying to use the xsd file which is there in my metadata store, in my SOA project. DB based Meta data store is working fine. But when I am using file based metadata store, it is throwing ORABPEL-09705 error as mentioned below "Caused By: jav

  • Use AIM with iChat

    I don't have an .Mac acount, so I use MSNforMac to talk with an Hotmail account to my PC friends. I want to use iChat because MSNforMac don't let us make videoconferences. But can I talk to my friends (that use MSN in a PC) by iChat with an AIM Acoun

  • How to call webservices in visuval composure CE 7.1 server

    Hi , How to call webservices in visuval composure CE 7.1 server (WSDL) ,  please send step  by step process Thanks & Regards, Suresh