Application example of tuxedo and oracle dynamic method four

xiaoxiao2021-03-06  75

Title: Application of Tuxedo and Oracle Dynamic Method Time: 2003-11-28

Author: Jian-Xin Peng (dev2dev forum id: sylpjx) BEA dev2dev Tuxedo section moderator, Tuxedo expert

In the forum, there is a friend asking about the corresponding problem of Tuxedo and Oracle's Proc Dynamic Method III. At that time, he only responded to the question point, and a complete example contributed to everyone, I hope to help everyone. Program running environment Description: P4 1.7GHz, memory 512MB, operating system: Windows 2000 Server Bea Tuxedo 8.1 for Windows 2000Bea Tuxedo 6.5 for Windows NT Database: Oracle 8.16 Adopt non-XA connection mode is transmitted with synchronous call communication. Below the main part of the program gives you a description: Program example name: ORADYN4 source package is zip file, for everyone to download: BEA Tuxedo and database combination highlighting it, Oracle database is a very popular mainstream database, Oracle The combination of databases and BEA Tuxedo can complete a variety of functions. Oracle provides Pro * C programming and the BEA Tuxedo is closely integrated, and in the dynamic method in Pro * C, the dynamic method four is undoubtedly the most difficult one in these four methods, and it is also four ways. One of the most flexible. Unlike other methods, the dynamic method fourth is to control the conversion of the data type instead of the data type between Oracle and C automatically implements conversion. Below I combine the program to explain the BEA Tuxedo and Oracle dynamic method four programming implementation, dynamic query. The program utilizes the synchronous communication mode to implement data transmission (TPCALL), in the communication mode of the BEA Tuxedo, synchronous is more and more relatively simple, because it is necessary to put the focus can be implemented and the Oracle dynamic method four In combination, it will not speak in detail. The approach process of the program is to initiate a dynamic SQL statement from the client to the server. After the server is executed, the server is executed after the server is executed, and the result is transmitted to the client, the client prints the result. In ORADYN4 examples, the Oracle database is used by the Oracle database, and the read data from the server is implemented by select * from EMP, and the result of the resulting data is transmitted to a process of the client. Client program process: 1. Application buffer 2, request server terminal 3, accept data, and print to file key to describe the result data received by the client print, in the FML type function, the ffprint function is used to print debugprues . First define a FILE type pointer FP to create a file and open file, then print the received data into the file with the ffprint function. The procedure is as follows: file * fp; / * Define a file pointer * / fp = fopen ("fmlreturn.txt", "w"); / * Open file * / if (fp == null) {UserLog ("Conorasvr Fopen Svrrcv .txt failed "); exit (1);} ffprint (rcvbuf, fp); / * Output data output into the file) Fclose (fp); / * Close the file pointer * / oraDyncli.c The comment statement, the client program is described in detail. Server program flow: 1. Accept number of server requests 2. The resulting result data is written to the buffer 3. Returning the results to the client focus to write data into the buffer, this is a point with a certain difficulty, you need to write to the field name, and the value of the field, while writing the field value It is necessary to judge whether the value of this field is empty.

The procedure is as follows: / * Field name written to the EMP table to the buffer SNDBUF * / {UserLog ("INPUT NUMBER% D Field INTO SNDBUF BUFFER./N", II );UserLog ("INPUT FML Empstr with Field Name:% S / N ", TITLE); FCHG (SNDBUF, Empstr, Occount, Title, (FLDLEN) 0); Occcount ;} / * The field value * / {/ * to write to the buffer SNDBUF * / {/ * judgment is empty Value, and written to buffer * / userlog ("INPUT NUMBER% D Field INTO SNDBUF BUFFER./N", "iSerlog (" INPUT FML Empstr with Current Record I Value% D / N ", * SELECT_DP-> I [i]); sprintf (TmpBuf, "% D", * select_dp-> i [i]); UserLog ("% S / N", TMPBUF; FCHG (SNDBUF, Empstr, Occount, TmpBuf, (Fldlen) 0); Occount ; IF (strcmp (TmpBuf, "0")) / * If it is empty handler * / {UserLog ("True / N"); Sprintf (TmpBuf, "% s", "null"); UserLog ("Input FML Empstr with Null Value% S", TMPBUF); FCHG (SNDBUF, Empstr, Occount, TmpBuf, (FLDLEN) 0); Occcount ;} / * is not available * / ... / * omitted, see The source program * /} also added statistics on the field of the table and the number of records of the table, as follows: The statistics of the number of records recorded: FCHG (SNDBUF, Rowlen, 0, (char *) & row_len (FLDLEN) 0) The statistics of the number of fields Implement statement: FCHG (SNDBUF, Collen, 0, (CHAR *) & col_len, (fdlen) 0); introduction to the program is approximately, the following is an important ring: The program compiles and executes the following operations in the current directory of ORADYN4: 1. Set an environment variable: STENV Note: Do the corresponding changes depending on the location of the system and related software. 2. Compile the client program: buildcleint -o orasedyncli -f orasedyncli.c3. Compile Services: Precommine Proc Programs: Proc ORADYN.PCBUILDSERVER -O ORADYN -F ORADYN.C -S DYN4 -R Oracle_xa4. Compile UBB file: TMLOADCF -Y UBB Note: Do the corresponding changes depending on the location of the system and related software. Be sure to write the machine name into your own machine's name :).

5. Start service: TMBOOT -Y correct boot service Show below: booting admin processes ... EXEC BBL -A: Process ID = 2428 ... Started. Booting Server Processes ... EXEC ORADYN -A: Process ID = 2300 ... start.2 processes Started.6. Execute program: ORADYNCLI If the program is executed correctly, in the ORADYN4 directory, there should be an FMLReturn.txt file, open the contents of the files as follows: (only part of the interpretation) ------------- -------------------------------------------------- --------------------- (FLDID (8694)) 14 / * Get record number * / (FLDID (8695)) 8 / * Number of fields * / (FLDID (41461)) SELECT * from EMP / * Request SQL statement * / ----------------------------- -------------------------------------------------- ---- (FldID (41464)) Empno / * 8 below the field name * / (FldID (41464)) ename (FLDID (41464)) mgr (FldID (41464)) HIREDATE (FLDID (41464)) SAL (FLDID (41464)) COMM (FldID (41464)) DEPTNO ----------------------------- -------------------------------------------------- ---------- (FLDID (41464)) 0 / * The following is the value of the first record * / (FldID (41464)) 7369 (FLDID (41464)) 0 (FLDID (41464)) Smith (FLDID (41464)) Clerk (FLDID (41464)) 7902 (FLDID (41464)) 0 (FLDID (41464)) 17-12 / d4 / c2-80 (FLDID (41464)) 800.00 (FLDID (41464)) (FLDID (41464)) NULL (FLDID (41464)) 20 (FLDID (41464)) 20 in 16 lines above, Two are a group, the first if it is 0, indicating that this result is not empty, the second will display the correct result value, if it is -1, display a null value, in practice, you also need to write a program deal with. Another point to pay attention is that the date of the date is 17-12 / d4 / c2-80. This is in the case where the character set is simplified chinese_china.zhs16GBK, please read the reader to handle itself; when the character set is American_america When .us7ascii, no processing is required, the result is 17-DEC-1980. Through this article, I hope everyone knows how to combine Tuxedo and Oracle dynamic methods and work together. Because it is a combination of the two, there is no excessive introduction to the content of Oracle's dynamic method four. You can refer to the relevant book on dynamic method four, and systematically understand. In the program example, there is a detailed comment statement, here is not described here.

转载请注明原文地址:https://www.9cbs.com/read-121001.html

New Post(0)