2009년 11월 18일
void main vs. int main
# by | 2009/11/18 15:27 | 트랙백 | 덧글(4)
char *conn_str = "tibero/tmax";
EXEC SQL CONNECT :conn_str;
char *user_str = "tibero";
char *pass_str = "tmax";
EXEC SQL CONNECT :user_str IDENTIFIED BY :pass_str;
tbesql $ vi test_ddl.tbc
/* test_ddl.tbc */
#include <stdio.h>
#include <string.h>
int main(void)
{
char *conn_str = "tibero/tmax";
/* connection */
EXEC SQL CONNECT :conn_str;
if (sqlca.sqlcode == 0)
printf("Connected.\n");
else
return -1;
/* create table */
EXEC SQL CREATE TABLE TEST01 (A NUMBER, B VARCHAR(10));
/* check error code */
if (sqlca.sqlcode == 0)
printf("Table has been created.\n");
else
printf("Error occurred: %d\n", sqlca.sqlcode);
return 0;
}
tbesql $ tbpc test_ddl
tbESQL Precompiler 4 Trunk
TmaxSoft, Co. Copyright(C) 2001-2009. All rights reserved.
test_ddl.tbc is precompiled successfully!
tbesql $ tbpcc test_ddl
tbesql $ ls
test_ddl test_ddl.tbc test_ddl.c
tbesql $ ./test_ddl
Connected.
Table has been created.
tbesql $ vi test_insert.tbc
/* test_insert.tbc */
#include <stdio.h>
#include <string.h>
int main(void)
{
char *conn_str = "tibero/tmax";
EXEC SQL CONNECT :conn_str;
if (sqlca.sqlcode == 0)
printf("Connected.\n");
else
return -1;
EXEC SQL INSERT INTO TEST01 VALUES (1, 'Tibero');
if (sqlca.sqlcode == 0)
printf("1 row has been inserted.\n");
else
printf("Error occurred: %d\n", sqlca.sqlcode);
return 0;
}
tbesql $ tbpc test_insert
tbESQL Precompiler 4 Trunk
TmaxSoft, Co. Copyright(C) 2001-2009. All rights reserved.
test_insert.tbc is precompiled successfully!
tbesql $ tbpcc test_insert
tbesql $ ./test_insert
Connected.
1 row has been inserted.
tbesql $ ./test_insert
Connected.
Error occurred: -8033
tbesql $ tberr 8033
/*
* err: -8033
* name: ERROR_DML_OBJ_NOT_EXIST
* desc: Specified schema object was not found.
* cause: The specified schema object does not exist.
* action: Check the schema object name.;
*/
tbesql $ vi test_select.tbc
/* test_select.tbc */
#include <stdio.h>
#include <string.h>
int main(void)
{
char *conn_str = "tibero/tmax";
char a[11];
memset(a, 0, sizeof(a));
EXEC SQL CONNECT :conn_str;
if (sqlca.sqlcode == 0)
printf("Connected.\n");
else
return -1;
EXEC SQL SELECT A INTO :a FROM TEST01;
if (sqlca.sqlcode == 0) {
printf("1 row has been selected.\n");
printf("column A: %s\n", a);
}
else
printf("Error occurred: %d\n", sqlca.sqlcode);
return 0;
}
tbesql $ tbpc test_select
tbESQL Precompiler 4 Trunk
TmaxSoft, Co. Copyright(C) 2001-2009. All rights reserved.
test_select.tbc is precompiled successfully!
tbesql $ tbpcc test_select
tbesql $ ./test_select
Connected.
Error occurred: 1403
tbesql $ tberr 1403
"1403" is invalid err code
/* test_insert.tbc */
#include <stdio.h>
#include <string.h>
int main(void)
{
char *conn_str = "tibero/tmax";
EXEC SQL CONNECT :conn_str;
if (sqlca.sqlcode == 0)
printf("Connected.\n");
else
return -1;
EXEC SQL INSERT INTO TEST01 VALUES (1, 'Tibero');
if (sqlca.sqlcode == 0)
printf("1 row has been inserted.\n");
else
printf("Error occurred: %d\n", sqlca.sqlcode);
EXEC SQL COMMIT;
if (sqlca.sqlcode == 0)
printf("Committed.\n");
else
printf("Error occurred: %d\n", sqlca.sqlcode);
return 0;
}
tbesql $ ./test_insert
Connected.
1 row has been inserted.
Committed.
tbesql $ ./test_select
Connected.
1 row has been selected.
column A: 1
EXEC SQL COMMIT WORK;
EXEC SQL COMMIT WORK RELEASE;
# by | 2009/10/21 11:33 | introduction to tbESQL | 트랙백 | 덧글(0)
tbesql $ echo $TB_HOME
/home/soohah/Work/tibero_trunk3
tbesql $ echo $PATH
/home/soohah/Work/tibero_trunk3/client/bin:/home/soohah/Work/tibero_trunk3/scripts:/home/soohah/Work/tibero_trunk3/bin:/home/soohah/Work/tibero_trunk3/src/scripts:/home/soohah/Work/tibero_trunk3/tools/bin:/usr/lib/j2se/1.4/bin:/usr/lib/j2se/1.4/include:/usr/local/eclipse:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
tbesql $ echo $LD_LIBRARY_PATH
/lib:/usr/lib:/usr/lib32:/usr/local/lib:/usr/X11R6/lib/:/home/soohah/Work/tibero_trunk3/client/lib:/home/soohah/Work/tibero_trunk3/tool/lib:/lib:/usr/local/BerkeleyDB.4.5/lib/:
tbesql $ tbpc
Usage: tbpc [-h] [-v] [options] file...
-h show this help.
-v show tbESQL version.
Option Name Description
----------------------------------------------------------------------------
CHAR_MAP Mapping of character arrays and strings
CLOSE_ON_COMMIT Close all cursors on COMMIT
CODE The user language type
CONFIG The name of user configuration file
CPP_SUFFIX C++ filename suffix of generated code
DEF_SQLCODE Whether precompiler generates SQLCODE macro
DEFINE Define name for c preprocessor
DYNAMIC Specify Tibero or ANSI, Oracle Dynamic SQL Semantics
HOLD_CURSOR Specifies if the cursors will be holded after closing
INAME The name of the input file
INCLUDE Directory paths for included files
LINES Whether to print #line directives for debugging
MODE Code conformance to Tibero or ANSI, Oracle rules
ONAME The name of the output file
ORACA Whether to use the oraca sturucture
PARSE Specifies which non-SQL code is parsed
PREFETCH Number of rows pre-fetched at cursor OPEN time
RELEASE_CURSOR Specifies if the cursors will be released after closing
SELECT_ERROR Control flagging of select errors
SQLCHECK Specifies the type and extent of syntatic and semantic checking
STMT_CACHE_SIZE Size of the statement cache
SYS_INCLUDE Directory paths for system header files
THREADS Indicates multi-threads application
TYPE_CODE Use Tibero or ANSI, Oracle type codes for Dynamic SQL
UNSAFE_NULL prevent 1405 error when indicator is not specified
USERID Specifies Tibero username and password
tbesql $ tbpc -v
tbESQL Precompiler 4 Trunk rev.43057 on Oct 16 2009 15:50:26
TmaxSoft, Co. Copyright(C) 2001-2009.
Linux soohah-desktop 2.6.24-24-generic #1 SMP Fri Sep 18 16:16:18 UTC 2009 x86_64 GNU/Linux version (little-endian)
tbesql $ vi test1.tbc
#include <stdio.h>
int main(void)
{
printf("hello world!\n");
return 1;
}
tbesql $ ls
test1.tbc
tbesql $ tbpc test1.tbc
tbESQL Precompiler 4 Trunk
TmaxSoft, Co. Copyright(C) 2001-2009. All rights reserved.
test1.tbc is precompiled successfully!
tbesql $ ls
test1.c test1.tbc
tbesql $ tbpcc test1
tbesql $
tbesql $ ls
test1 test1.c test1.tbc
tbesql $ ./test1
hello world!
# by | 2009/10/20 10:52 | introduction to tbESQL | 트랙백 | 덧글(0)
◀ 이전 페이지다음 페이지 ▶