RTP record log Mechanism

Source: Internet
Author: User
Tags sql error
We often run a concurrentrequestRTP: ReceivingTransactionProcessor on the rcv side, which is mainly used to process data in RCV_TRANSACTIONS_INTERFACE. this concurrentprogram contains many files. More important: identRVCTPRVCTP: $ Header: rvctp. oc120.0.120

We often run a concurrent request RTP: Processing ing Transaction Processor on the RCV side, which is mainly used to process data in RCV_TRANSACTIONS_INTERFACE. this concurrent program contains many files, which are more important: ident RVCTPRVCTP: $ Header: rvctp. oc 120.0.120

We often run a concurrent request RTP: Processing ing Transaction Processor on the RCV side, which is mainly used to process data in RCV_TRANSACTIONS_INTERFACE.

This concurrent program contains many files, which are more important:

ident RVCTPRVCTP:     $Header: rvctp.oc  120.0.12000000.1 2007/01/16 23:53:49 appldev ship $     $Header: rvtbm.lpc 120.13.12010000.10 2013/03/15 02:51:16 zhlee ship $      $Header: rvtpt.lpc 120.28.12010000.33 2013/07/15 07:12:37 smai ship $     $Header: rvtvq.lpc 120.8.12010000.17 2013/04/03 11:40:30 wayin ship $     $Header: rvtuq.lpc 120.9.12000000.7 2009/07/07 09:47:49 YUZZHANG01 ship $     $Header: pouer.lpc 120.2 2006/06/14 07:57:02 arudas noship $     $Header: rvtlo.lpc 120.1.12010000.7 2013/01/05 16:02:14 gke ship $     $Header: rvtoc.lpc 120.1.12010000.5 2013/03/28 22:38:31 vthevark ship $     $Header: rvtpa.lc  120.6.12010000.3 2009/07/07 08:58:22 ksivasa ship $     $Header: rvtpd.lc  120.1.12010000.3 2009/07/07 09:03:17 ksivasa ship $     $Header: rvtsh.lpc 120.10.12010000.3 2009/03/06 22:09:40 vthevark ship $     $Header: rvtth.lpc 120.29.12010000.9 2012/05/30 15:50:03 gke ship $     $Header: rvtvt.lpc 120.9.12010000.10 2013/03/28 18:19:11 vthevark ship $     $Header: rvsco.lpc 120.4.12010000.12 2012/09/27 23:10:24 vthevark ship $     $Header: rvsrv.lpc 120.4.12010000.16 2013/02/04 07:34:37 zhizheng ship $     $Header: rvsit.lpc 120.5.12010000.6 2013/02/04 07:26:30 zhizheng ship $     $Header: rvsdl.lpc 120.5.12010000.17 2011/11/28 05:19:19 xiameng ship $     $Header: rvssh.lpc 120.2.12010000.3 2009/07/07 09:56:26 ksivasa ship $     $Header: rvsut.lpc 120.3.12010000.14 2012/05/28 04:53:57 gke ship $     $Header: rvtcl.lpc 120.6.12010000.3 2009/07/07 09:15:25 ksivasa ship $     $Header: rvtii.lpc 120.19.12010000.27 2013/08/14 09:58:23 gke ship $     $Header: rvtls.lpc 120.7.12010000.14 2012/01/30 12:31:22 ksivasa ship $     $Header: rvtoo.lpc 120.3.12010000.3 2009/07/07 09:08:40 ksivasa ship $     $Header: rvsrq.lpc 120.5.12010000.3 2009/07/07 09:53:56 ksivasa ship $     $Header: rvspo.lpc 120.3.12010000.3 2009/07/07 09:53:12 ksivasa ship $

These files are often seen in RTP logs. Here we mainly look at the mechanisms used to write logs in these files.

First, declare a variable in the function to write logs:

text     strbuf[BUFLEN+1];

Use the following statement:

    strcpy((char *)strbuf,"");    sprintf((char *)strbuf,"RVTUQ:370 req_line_id %ld\n", (long)req_line_id);    Debug(strbuf,TRUE,TRUE);

The first sentence is to clear strbuf, and then write the strings and integer numbers behind it to strbuf. The third sentence is to Debug and write strbuf into the log. Debug has two parameters:

#define Debug(message,check_sql_error,no_rows_is_error)

The second parameter check_ SQL _error indicates that if you want to check SQL error, it is set to TRUE; otherwise, it is set to FALSE. no_rows_is_error, indicating whether NO_DATA_FOUND is regarded as an error. If yes, It is set to TRUE.

The files in Concurrent Request are all. c code. If you want to write SQL, you need to write a sentence:

    EXEC SQL
Then write the SQL statement below. This SQL statement may cause errors. In this case, you need a method to write the error message to the log. For example:
       EXEC SQL       select transaction_id,              unit_of_measure         into :parent_trx_id,              :rec_uom         from rcv_transactions        where transaction_type in ('RECEIVE','MATCH')        start with transaction_id = :p_trx_id    connect by transaction_id = prior parent_transaction_id;

To capture the possible errors of this SQL statement, we will write the following sentence:

pouersql("RVTUQ", "134", FALSE )
Pouersql () is a function in pouer. if an error occurs in the preceding SQL statement, the error message is written to message stack. and returns true.

There are three parameters, routine, location, no_rows_is_err.

Routine indicates the name of the file with an SQL error. In the preceding example, It is RVTUQ.

Location indicates the location where the SQL statement is incorrect. In the preceding example, the location is 134. As a result, the location in the log is easy to locate this SQL statement.

No_rows_is_err indicates whether to treat NO_DATA_FOUND as an error. In the above example, we did not treat it as an error.

Inside the pouersql function, sqlcode is extracted from sqlca. the full name of sqlca is: SQL communications area, which is a place for recording SQL Execution information. each time you run an SQL statement, sqlcode is returned. if sqlcode = 0, it indicates no error. if sqlcode> 0, exception exists. If sqlcode <0, error occurs and rollback is required. the error values we usually encounter are less than 0, but NO_DATA_FOUND is greater than 0, code 1403. the pousersql () function extracts sqlcode from sqlca and then determines whether sqlcode <0 or sqlcode> 0. If it is less than 0, the error message is written to message stack. if the value is greater than 0 and the value of no_rows_is_err In the parameter is set to TRUE, it will also be written as message stack.

Each time an SQL statement is executed, sqlca is updated. Therefore, this structure only records information about the last SQL statement executed. the error message is recorded in sqlca. sqlerrm. in sqlerrmc. therefore, the strings in the message stack will be written. however, sqlerrmc can only record up to 70 characters, so if the error message is too long, it will be truncated.

If an error occurs in the preceding SQL statement, the return value of pouersql () is TRUE. then, when calling this function, such as rvtpt. in the lpc file, the returned value is captured. After the returned value is determined to have an error, the following code is called:

pouertrace( "RVTUQ", "000", "rvtuqdebitmemo()" )
The pouertrace () function is also defined in the pouer. lpc file. The return value of this function is always false. Its main function is to write error messages to message stack. The three parameters are:

File: indicates the file with an error
Location: indicates the wrong location.
Subroutine: indicates the function with an error.

As mentioned above, sqlerrmc can only store 70 characters. if the error message contains more than 70 characters, you must use the sqlglm () function to obtain all the error messages. before using this function, make sure that sqlcode <0; otherwise, the error message obtained is the previous SQL message.

if (pouersql("RVTUQ","019",TRUE)){                              char msg[510];   size_t buf_len, msg_len;   buf_len = sizeof (msg);   sqlglm(msg, &buf_len, &msg_len);                   strcpy((char *)strbuf,"");   sprintf((char *)strbuf,"RVTUQ:001 YU SQL ERROR %s \n", (text *) msg);   Debug(strbuf,TRUE,TRUE);   return( FALSE );}
The sqlglm () function writes the error message to msg, and then writes the msg to the log using the Debug () function. the sqlglm () function also has a limit on the number of characters, up to 512 characters. it is much more than sqlerrmc's 70 characters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.