{toc}
h1. Overview
ALTIBASE HDB provides APRE*C to develop an application for C/C++.
It is similar tool-kit to PRO*C in ORACLE.
At first, We recommend you to read a manual about APRE for C/C++.
{gliffy:name=howtoapre|align=left|size=L|version=3}
In the above figure,
# User writes a source code having a extension like ".sc" using embedded-SQL in C/C+\+ style.
(User has to write source-file of extension like "*.sc")
# User executes APRE provided by Altibase for changing a source to C/C+\+ style.
(Apre changes "xxxx.sc" to "xxxx.c" or "xxxx.cpp" like C/C+\+ style)
# User compiles and links an object with altibase-libraries and system-libraries. altibase libraries are libapre.a and libodbccli.a
# After all steps are done, you can make an application-binary to serve for your customer.
h1. Precompiler options
|| ALTIBASE HDB || ORACLE || Comments ||
| \-h | No Option (oracle displays help content when executed without options) | display help content about options. |
| \-t {c\|cpp}\\ | like CODE= {ANSI_C\|KR_C\|CPP}option | This is used to choose the filename extension of the file created \\
as a result of the APRE precompiling operation. |
| \-o output_path | | This is used to specify the location of the file(s) created by APRE. |
| \-mt | THREADS= {yes\|no}| If the file to be precompiled is a multi-threaded program, \\
this option must be specified. |
| \-I include_path | INCLUDE option | This option is used to specify the location(s) of the header file(s) \\
to be used in the precompiling operation. |
| \-parse | PARSE= {none\|partial\|full}\\ | This option is used to specify the range within the source file(s), \\
which are specified within the source code using the #include directive, \\
that is parsed by the precompiler. When this option is not specified, \\
it is set to partial by default. |
| \-D | No option | This option is used to specify the name of a macro \\
during the precompile operation. |
| \-n | No option | This option is used to indicate that any host variables of type CHAR are not null-padded. |
| \-unsafe_null | UNSAFE_NULL= |{yes|no}\\ | This option is used to prevent an error from being raised \\
even when a NULL value is fetched and an indicator variable is not being used. |
| \-spill | No option | This option is specified only when precompiling in an AIX environment. |
| \-keyword | No option | display reserved keywords. |
| \-nchar_var | | When this option is used, APRE processes the specified \\
variables using the Altibase national character set. |
| \-nchar_utf16 | UTF16_CHARSET | When this option is used, national character type data are \\
encoded as UTF-16 during the precompile operation. |
* ALTIBASE HDB doesn't provide features like other oracle's options except above options.
h1. To make a binary
|| Option || ALTIBASE HDB || ORACLE ||
| precomiling | apre \-mt \-t {cpp\|c}sample.sc | proc iname=sample.pc |
| Definition about path of header-files | \-I$ {ALTIBASE_HOME}/include \| \-I${ORACLE_HOME}/public \-I${ORACLE_HOME}/precomp/include \-I${ORACLE_HOME}/oracore/public ... \|\| Definition about path of library-files \| \-I$ \|{ALTIBASE_HOME}/lib | \-L$ {ORACLE_HOME}/precomp/lib \-L$\{ORACLE_HOME}/lib ... \|\| Library-files \| \-lapre \-lodbccli \| cat `$\{ORACLE_HOME}/lib/sysliblist` ... \|\* ORACLE sample
{code:none}
{code}
Shell> proc iname=sample1.pc \\
Shell> gcc \-m64 \-o sample1 sample1.c \-I${ORACLE_HOME}/precomp/public \-L${ORACLE_HOME}/lib \-lclntsh
{code}
* ALTIBASE HDB
{code:none}
Shell> apre -mt -t c sample1.c
Shell> gcc -m64 -o connect1 connect1.c -I${ALTIBASE_HOME}/include -L${ALTIBASE_HOME}/lib -lapre -lodbccli -lpthread -lm -ldl -lstdc++ -lcrypt -lrt{code}
When compiling, User have to link system-libraries like "-lpthread \-lm \-ldl \-lstdc+\+ \-lcrypt \-lrt". (Altibase provides only two-libraries like "libapre", "libodbccli") |
h1. Connection
[See this page|http://aid.altibase.com/x/KZQt]
* *{_}ORACLE{_}*
{code:none}
EXEC SQL CONNECT {:user IDENTIFIED BY :oldpswd :usr_psw }
[[ AT { dbname | :host_variable }] USING :connect_string ];
{code}
* *{_}ALTIBASE HDB{_}*
{code:none}
EXEC SQL [AT {conn_name | :conn_name}]
CONNECT <:user> IDENTIFIED BY <:passwd>
[USING <:conn_opt>];
{code}
h1. Host Variables
[See this page|http://aid.altibase.com/x/UZQt]
* *{_}ORACLE{_}*
{code:none}
EXEC SQL BEGIN DECLARE SECTION;
// declare host variables
EXEC SQL END DECLARE SECTION;
{code}
* *{_}ALTIBASE HDB{_}*
{code:none}
EXEC SQL BEGIN DECLARE SECTION;
// declare host variables
EXEC SQL END DECLARE SECTION;
{code}
* If you uses a option (-parse=full), you can use host-variables without declare-section. (but, this is able to do it in c-style)
h1. Embedded-SQL
See the follwoing pages linked as follows.
# [Basic SQL (SELECT,INSERT, UPDATE, DELETE, CURSOR, MOVE) |http://aid.altibase.com/x/spQt]
# [Call Procedure |http://aid.altibase.com/x/5JQt]
# [Dynamic Method |http://aid.altibase.com/x/HZUt]
# [Error-Handling |http://aid.altibase.com/x/8pQt]
# [LOBs-Handling |http://aid.altibase.com/x/IJUt]
# [Queue-Handling |http://aid.altibase.com/x/rZot]
|| Entries || ALTIBASE HDB || ORACLE || Comments ||
| File Extension | source.sc | source.pc | |
| Precompiler | apre | proc | |
| Header-File | Not needed | \#include <sqlca.h> | ALTIBASE HDB automatically writes a header-file while precompiling. |
| Default Commit-Mode | Auto-Commit | Non Auto-Commit | ALTIBASE can be using a property located at $ALTIBASE_HOME/conf/altibase.properties |
| Fetch-Across-Commit | Not Support | Support | |
| Dynamic Method-4 | Not Support | Support | |
h1. Status Codes
[See this page|http://aid.altibase.com/x/8pQt]
* *{_}ORACLE _*
{code:c}
char SQLSTATE [6];
...
if (sqlca.sqlcode != 0)
...
{code}
* *{_}ALTIBASE HDB{_}*
{code:c}
char SQLSTATE [6];
...
if (sqlca.sqlcode != 0)
...
if (SQLCODE != 0)
...
{code} |