Sie sind auf Seite 1von 3

X12 Inbound Flow (X12_in.

pc)
1. EXEC ORACLE OPTION (SQLCHECK=SYNTAX); EXEC ORACLE OPTION (SQLCHECK=SEMANTICS);
Syntactic checking verifies that keywords, object names, operators, delimiters, and so on are placed correctly in your SQL statement. E.g. EXEC SQL DELETE FROM EMP WHER DEPTNO = 20; Here the keyword WHERE is misspelled Semantic checking verifies that references to database objects and host variables are valid and that host variable datatypes are correct. E.g. EXEC SQL DELETE FROM empp WHERE deptno = 20; Here the Table name EMP is doesnt exist

2. #define V_CODE_NAME "x12_in" -- Its a macro 3. Header Files inclusion 4. EXEC SQL INCLUDE SQLCA;
SQLCA - SQL Communication Area is a structure defined in sqlca.h header file and is used to provide extra information about the most recently executed SQL command. struct { char sqlcaid[8]; long sqlabc; long sqlcode; struct { int sqlerrml; char sqlerrmc[SQLERRMC_LEN]; } sqlerrm; char sqlerrp[8]; long sqlerrd[6]; char sqlwarn[8]; char sqlstate[5]; } sqlca;

sqlcaid This string component is initialized to "SQLCA" to identify the SQL Communications Area. sqlcabc This integer component holds the length, in bytes, of the SQLCA structure. sqlcode This integer component holds the status code of the most recently executed SQL statement: 0 No error. Statement executed but exception detected. This occurs when Oracle cannot find a row >0 that meets your WHERE condition or when a SELECT INTO or FETCH returns no rows. <0 Oracle did not execute the statement because of an error. When such errors occur, the current transaction should, in most cases, be rolled back.

sqlerrm This embedded structure contains the following two components: sqlerrml - Length of the message text stored in sqlerrmc. sqlerrmc - Up to 70 characters of the message text corresponding to the error code stored in sqlcode.

sqlerrp Reserved for future use. sqlerrd This array of binary integers has six elements: sqlerrd[0] - Future use. sqlerrd[1] - Future use. sqlerrd[2] - Numbers of rows processed by the most recent SQL statement. sqlerrd[3] - Future use. sqlerrd[4] - Offset that specifies the character position at which a parse error begins in the most recent SQL statement. sqlerrd[5] - Future use.

sqlwarn This array of single characters has eight elements used as warning flags. Oracle sets a flag by assigning to it the character 'W'. sqlwarn[0] Set if any other flag is set. sqlwarn[1] Set if a truncated column value was assigned to an output host variable. sqlwarn[2] sqlwarn[3] sqlwarn[4] sqlwarn[5] Set if a NULL column value is not used in computing a SQL aggregate such as AVG or SUM. Set if the number of columns in SELECT does not equal the number of host variables specified in INTO. Set if every row in a table was processed by an UPDATE or DELETE statement without a WHERE clause. Set if a procedure/function/package/package body creation command fails because of a PL/SQL compilation error.

sqlwarn[6] No longer in use. sqlwarn[7] No longer in use. sqlext Reserved for future use.

5. int main(int argc, char* argv[])

Sometimes interactive input is impractical. Interactive input is when a program promts a user for data that it requires to perform its calculations. There are times however, when the program cannot prompt the user, a good example is when another program calls your program. In this situation, acquiring the data that you need from the calling program is difficult at best and impossible at worst, but there must be a way. This solution is that of command line arguments The main function is declared by the Standard to take either zero or two parameters, these two parameters allow other programs to call main with a set of arguments that main can then use to perform operations. These arguments are commonly called

a) argc, which stands for argument count -- an integer that contains the number of arguments passed to
main, this value will always be at least 1, the first argument is always the name of the program.

b) argv, which stands for argument vector -- an array of char pointers (or an array of C strings) which
contains each argument in string format.

6. S_CONN s_conn, hub_conn;


S_CONN is a structure which is defined in the sql_olib.h header file, and is used to store the uid and pwd. Note: Declarations of functions is done in .h file and the definitions are defined in correspondin .pc files. Complier automatically links up the .pc file whenever a function is encountered in the .h file.

7. Functions are defined in .pc & .c files


takes connection instances as parameters and sqlol_conn_init(&s_conn); -- set the default values i.e. 0 / false (sql_olib.pc) sqlol_conn_init(&hub_conn); -- (sql_olib.pc) sqlol_set_hub_conn(&hub_conn); -- used to reset the connection pointer (sql_olib.pc) set_int_dir('I'); -- sets the directory to either I / O I for inbound and O for Outbound (x12_olib.pc) set_prog_name(argv[0]); -- (edi_lib.h) explore more set_daemon_proc(FALSE); -- (edi_lib.h)

8. exec_inbound(&s_conn, &hub_conn, NULL, argc, argv);


Declaration in X12in_olib.h Definition in X12in_olib.pc int exec_inbound(S_CONN* s_conn, S_CONN* hub_conn, S_EOPTS* p_eopts, int argc, char* argv[]) S_CONN defined in sql_olib.h S_EOPTS defined in eopts_olib.h S_X12 defined in X12_olib.h sqlol_conn_new defined in sql_olib.pc calls sqlol_conn_connect establishes the database connection

Das könnte Ihnen auch gefallen