Getting compile time error while deploying application in IBM Integration Toolkit 10 - esb

I am getting below error while deploying my application on EG exist on remote integration node.
BIP2087E: Integration node 'IIB10Node' was unable to process the
internal configuration message.
The entire internal configuration message failed to be processed
successfully.
Use the messages following this message to determine the reasons for
the failure. If the problem cannot be resolved after reviewing these
messages, contact your IBM Support center. Enabling service trace may
help determine the cause of the failure.
BIP4041E: Integration server 'EGTesting' received an administration
request that encountered an exception.
While attempting to process an administration request, an exception
was encountered. No updates have been made to the configuration of the
integration server.
Review related error messages to determine why the administration
request failed.
BIP2401E: (com.esql.code.UAE_FTProcess_Transaction.Main, 51.47) :
Syntax error : expected '=' but found '.'.
The expected token was not found.
Correct the syntax of your ESQL expression in node
'com.esql.code.UAE_FTProcess_Transaction.Main', around line and column
'51.47', then redeploy the message flow.
BIP2871I: The request made by user 'iibadmin[Default]' to 'deploy' the
resource
'C:/Users/905293/IBM/IIBT10/Adil_workspace/GeneratedBarFiles/AsyncUAE_FTAppproject.generated.bar'
of type 'BAR' on parent 'EGTesting' of type 'ExecutionGroup' has the
status of 'FAILED'.
Below is my esql code where this compilation error mention line number and file name. My code is mostly commented and no semantic error are showing. I've clean my project and change my workspace several time and deploy but getting same error every time. The line where my error occur on esql are commented still it showing this. I cannot understand this what i could do now. Kindly help.
CREATE COMPUTE MODULE UAE_FTProcess_Transaction
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE Schemas CHARACTER 'IIBUAT';
DECLARE Table CHARACTER 'ft_transaction';
DECLARE HEADER_IN CHARACTER '';
DECLARE TRAN_DETAIL CHARACTER '';
DECLARE DR_INFO CHARACTER '';
DECLARE CR_INFO CHARACTER '';
DECLARE SC_DETAIL CHARACTER '';
DECLARE REV_DETAIL CHARACTER '';
DECLARE META_DATA CHARACTER '';
DECLARE XML_REQ CHARACTER '';
DECLARE XML_RESP CHARACTER '';
DECLARE i INT 1;
SET Environment.Variables.FTData[]= SELECT * FROM Database.{Schemas}.{Table} AS A WHERE
A.TRANSACTION_STATUS='N' AND A.TRANSACTION_COUNT=1;
DECLARE ft_data REFERENCE TO Environment.Variables;
WHILE(i<=CARDINALITY(ft_data.FTData[])) DO
DECLARE ft_seq REFERENCE TO ft_data.FTData[i];
-- SET HEADER_IN=
-- '<HEADER_IN><CORR_ID>DAPP888260726808</CORR_ID><USER_NAME>CBS</USER_NAME><CHANNEL>DAPP</CHANNEL><APPLICATION>GNBAQRG</APPLICATION><WORK_STATION>Kci-DigAppBack</WORK_STATION><AUTH_KEY></AUTH_KEY></HEADER_IN>';
-- SET TRAN_DETAIL=
-- '<MSG_TYPE>O</MSG_TYPE><STAN>'||ft_seq.STAN||'</STAN><TRAN_DATETIME>'||ft_seq.TRAN_DATETIME||'</TRAN_DATETIME><TRAN_AMT>'||ft_seq.TRAN_AMT||'</TRAN_AMT><TRAN_DESC>'||ft_seq.TRAN_DESC||'</TRAN_DESC><CHEQUE_NO></CHEQUE_NO><CCY_RATE/>';
-- SET DR_INFO=
-- '<DR_INFO><DR_BANK_CODE>'||ft_seq.DR_BANK_CODE||'</DR_BANK_CODE><DR_BANK_NAME>'||ft_seq.DR_BANK_NAME||'</DR_BANK_NAME><DR_ACCT_TITLE>'||ft_seq.DR_ACCT_TITLE||'</DR_ACCT_TITLE><DR_ACCT_IBAN>'||ft_seq.DR_ACCT_IBAN||'</DR_ACCT_IBAN><DR_ACCT_TYPE>'||ft_seq.DR_ACCT_TYPE||'</DR_ACCT_TYPE><DR_ACCT_NO>'||ft_seq.DR_ACCT_NO||'</DR_ACCT_NO><DR_BRANCH>'||ft_seq.DR_BRANCH||'</DR_BRANCH><DR_CCY>'||ft_seq.DR_CCY||'</DR_CCY><DR_CLIENT_NO>'||ft_seq.DR_CLIENT_NO||'</DR_CLIENT_NO><DR_CRC>PKR</DR_CRC><DR_VALUE_DATE>'||ft_seq.DR_VALUE_DATE||'</DR_VALUE_DATE></DR_INFO>';
--SET CR_INFO=
--'<CR_INFO><CR_BANK_CODE>'||ft_seq.CR_BANK_CODE||'</CR_BANK_CODE><CR_BANK_NAME>'||ft_seq.CR_BANK_NAME||'</CR_BANK_NAME><CR_ACCT_TITLE>'||ft_seq.CR_ACCT_TITLE||'</CR_ACCT_TITLE><CR_ACCT_TYPE>'||ft_seq.CR_ACCT_TYPE||'</CR_ACCT_TYPE><CR_ACCT_NO>'||ft_seq.CR_ACCT_NO||'</CR_ACCT_NO><CR_BRANCH>'||ft_seq.CR_BRANCH||'</CR_BRANCH><CR_CCY>'||ft_seq.CR_CCY||'</CR_CCY><CR_CLIENT_NO>'||ft_seq.CR_CLIENT_NO||'</CR_CLIENT_NO><CR_CRC>PKR</CR_CRC><CR_VALUE_DATE>'||ft_seq.CR_VALUE_DATE||'</CR_VALUE_DATE></CR_INFO>';
SET SC_DETAIL='<SC_DETAIL><ORIG_TRAN_REF></ORIG_TRAN_REF></SC_DETAIL>';
SET REV_DETAIL='<REV_DETAIL><TRAN_SEQ_NO></TRAN_SEQ_NO><TRAN_DATE></TRAN_DATE></REV_DETAIL>';
SET META_DATA='<META_DATA><META_COLUMNS/></META_DATA>';
-- SET XML_REQ='<CBS_TRAN_IN>'||HEADER_IN||TRAN_DETAIL||DR_INFO||
-- CR_INFO||SC_DETAIL||REV_DETAIL||META_DATA||'</CBS_TRAN_IN>';
SET XML_REQ='<CBS_TRAN_IN>'||SC_DETAIL||REV_DETAIL||META_DATA||'</CBS_TRAN_IN>';
-- CALL PROCESS_TRAN(XML_REQ,XML_RESP);
IF(SUBSTRING(SUBSTRING(XML_RESP AFTER '<RESULT_CODE>') BEFORE '</RESULT_CODE>')='0') THEN
UPDATE Database.{Schemas}.{Table} AS B SET B.TRANSACTION_STATUS='A' AND
B.TRANSACTION_COUNT=2 WHERE B.STAN=ft_seq.STAN;
ELSE
UPDATE Database.{Schemas}.{Table} AS B SET B.TRANSACTION_COUNT=2 WHERE B.STAN=ft_seq.STAN;
END IF;
SET i=i+1;
END WHILE;

Related

OpenOffice lost connection to MySQL on open cursor

Creating reports from OCS-NG Inventory using OpenOffice Base.
Because of poor functionality of OOOs Base source editor (it haven't even search facility!), I prefer to develop scripts in MySQL Workbench (both in Windows and in Linux). De-bugged script to be copied into OOO.
Until today all worked fine, including stored procedures and functions. Today I wrote another stored function utilizing data base cursor. On Workbench the script works just perfectly, producing usable results.
I copied script to Base and it failed with error 2013 "lost connection...". In WB the script execution takes about 3-4 seconds to return 348 rows on 4Mbit internet connection and even less on Gbit LAN., so timeouts aren't in charge.
Commenting out parts of stored function, I found that the failure occurs on open cursor_name statement. Well... I can copy-paste WB's script output into spreadsheet, but using all-in-one office package is more convenient.
Let's remind: the same script, calling the same function, does work in WB.
So, if anyone using OOO for accessing MySQL databases, may be you have solution? I asked Q's on OOO forums and asked for TS, but got no usable reply.
edit: Beginning of function
DELIMITER $$
CREATE DEFINER=`root`#`%` FUNCTION `get_monitors`(gmhwid int(11)) RETURNS text CHARSET utf8
BEGIN
declare MOV tinytext;
declare RetVal text;
declare NumOfMons, RowNum int;
# CURSOR-related variables
DECLARE done INT DEFAULT FALSE;
declare gmM, gmC, gmD, gmS tinytext charset utf8;
declare MonCursor cursor for select
MANUFACTURER,CAPTION,DESCRIPTION,SERIAL
from ocsweb.monitors
where ocsweb.monitors.hardware_id=gmhwid;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
# If there''s an overrider, use it and return
set MOV=(select Realmonitor from accinfo where hardware_id=gmhwid);
if ((MOV<>'') and (not isnull(MOV))) then
return mov;
end if;
# how many monitors for this computer
set NumOfMons=(select count(*) from monitors where hardware_id=gmhwid);
set RowNum=0;
set RetVal='';
#set #sel:=(select MANUFACTURER,CAPTION,DESCRIPTION,SERIAL from monitors where monitors.hardware_id=gmhwid);
return '-';
open MonCursor;
Note two last lines. Fake return with a dash is kinda breakpoint. With it the function works in OOO, but produces no usabel result, of course. Then the main loop started:
lup: loop
set MOV='';
fetch MonCursor into gmM, gmC, gmD, gmS;
But execution will never reach the lup: label, if executing in OOO.

Exception while calling stored procedure from jdbc

Calling a stored procedure results in this exception:
SQLException1 java.sql.SQLException: User does not have access to
metadata required to determine stored procedure parameter types. If
rights can not be granted, configure connection with
"noAccessToProcedureBodies=true" to have driver generate parameters
that represent INOUT strings irregardless of actual parameter types.
To resolve this, I tried:
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306
/database?useInformationSchema=true&noAccessToProcedureBodies=true",
"user_name", "pasword");
But it still does not work.
I am using shared hosting.
I am using
Software version: 5.0.91-community-log - MySQL Community Edition (GPL)
Protocol version: 10
Java 1.6
mysql-connector-java-5.1.14-bin.jar
One of my stored procedures is:
DROP PROCEDURE IF EXISTS `share_message`
DELIMITER //
CREATE PROCEDURE share_message(in messageid1 int(200),in received_by1 int(20),
in sent_by1 int(20),in shared_of1 int(20),author1 int(20), OUT query_status1 TINYINT)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
-- ERROR
SET query_status1 = -1;
rollback;
END;
DECLARE EXIT HANDLER FOR SQLWARNING
BEGIN
-- WARNING
SET query_status1 = -1;
rollback;
END;
START TRANSACTION;
SET query_status1 = 0;
INSERT INTO post_message_users(messageid,received_by,sent_by,shared_of,author)
VALUES(messageid1,received_by1,sent_by1,shared_of1,author1);
UPDATE post_messages SET total_share=total_share+1 WHERE messageid=messageid1;
SET query_status1 =1;
COMMIT;
END//
DELIMITER ;
This is working properly with my local database.
It seems that the stored procedure you are attempting to use needs access to MySQL's INFORMATION_SCHEMA. That's a (fake) database built in every MySQL server; it's used to fetch descriptions of tables, columns, indexes, and the like.
It looks like the user id you're using doesn't have access to the INFORMATION_SCHEMA. That's understandable on a hosting service.
Go on MyPhpAdmin and try a query like this to be sure about that.
SELECT table_schema, table_name
FROM information_schema.columns
WHERE column_name = 'something'
AND table_schema = 'your database name'
If you get some kind of error saying you don't have permission, this is definitely your problem.
You could try rewriting your stored proc, or you could ask your hosting service to grant you the appropriate priv.
TLDR; Change your Java code, make the CallableStatement reference parameters by index instead of name.
After having a similar problem I updated my JDBC driver mysql-connector-java-5.1.26-bin.jar.
The error then changed from
User does not have access to metadata required to determine stored
procedure parameter types. If rights can not be granted, configure
connection with "noAccessToProcedureBodies=true" to have driver
generate parameters that represent INOUT strings irregardless of
actual parameter types.
to
No access to parameters by name when connection has been configured not to access procedure bodies
I changed my Callable Statement to reference parameters by index instead of name, and hey presto it works.
Updating the driver may not be necessary, just knowing to use indexes instead of names when you don't have metadata access or routine body access.
Good Luck

SQL Server equivalent of DECLARE CONTINUE HANDLER in MySQL?

I am trying to execute following mySql statement
"DECLARE DONE INT(1) default 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET DONE = 1;"
in SQL Server 2005 like
" DECLARE #DONE INT,
DECLARE CONTINUE HANDLER FOR NOT FOUND SET DONE = 1"
it gives error like
"Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'CONTINUE'.
Msg 136, Level 15, State 1, Line 1
Cannot use a CONTINUE statement outside the scope of a WHILE statement."
MySQL DECLARE ... HANDLER command
SQL Server has no direct equivalent of the handler mechanism described in the documentation linked above. The most obvious alternatives are:
TRY...CATCH...
Write a CLR stored procedure and use .NET code to implement whatever handling code you need; this question also has some useful information

Procedure terminating silently when executing prepared statement

Problem
I have a stored procedure:
CREATE PROCEDURE `ProblematicProcedure` (IN dbName varchar(50), IN tableId INT)
MODIFIES SQL DATA
BEGIN
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v2;
CALL ExecuteSql(CONCAT("CREATE VIEW v1 AS SELECT * FROM ",dbName,".my_table;"));
CALL ExecuteSql(CONCAT("CREATE VIEW v2 AS SELECT * FROM ",dbName,".table_",tableId,";"));
...
When called directly from command line or a client like Navicat or HeidiSql, it works well:
CALL ProblematicProcedure("my_schema",1);
But if called from a custom Apache module using the exactly same line above, it crashes on first ExecuteSql call. I have to make it work when called from the Apache module and couldn't find a reason to crash.
ExecuteSql definition
CREATE PROCEDURE ExecuteSql (IN sql_str TEXT)
BEGIN
SET #query = sql_str;
PREPARE stm FROM #query;
EXECUTE stm;
DEALLOCATE PREPARE stm;
END
What I tried?
Swapped two ExecuteSql calls.
Inlined ExecuteSql calls.
Removed ExecuteSql's and used direct SQL statements with hardcoded dbName and tableId values.
Created procedure without MODIFIES SQL DATA.
Granted CREATE VIEW privilege: GRANT ALL ON *.* TO 'myuser'#'%';
Note: I added simple insert statements between the lines to find where it is crashing. So, I am sure it crashes always on first ExecuteSql call.
Question
What can be reason to this crash?
Update: Finally, I managed to find error code:
ERROR 1312: Procedure can't return a result set in the given context
Solution
Use CLIENT_MULTI_STATEMENTS flag when connecting:
mysql_real_connect(conn, host, user, pass, db, 0, NULL, CLIENT_MULTI_STATEMENTS);
Why this is so?
Calling a stored procedure means executing multiple statements. So, I need to specify that I can execute multiple statements at once. Hence I am using MySql C API functions at client-side (in my Apache module), I need to specify CLIENT_MULTI_STATEMENTS flag when connecting:
mysql_real_connect(conn, host, user, pass, db, 0, NULL, CLIENT_MULTI_STATEMENTS);
Or set it later:
mysql_set_server_option(MYSQL_OPTION_MULTI_STATEMENTS_ON);
I learnt those from the C API Handling of Multiple Statement Execution page.
How I Debugged?
Debugging a stored procedure is not so easy. I used traditional log-table method, but performed a bit aggresively about finding the error code.
Firstly, defined two variables to keep the code and message about the error occurred:
DECLARE E INT DEFAULT 0; -- error code
DECLARE M TEXT DEFAULT NULL; -- error message
Then, defined possible error codes and messages both for client and server errors (full list here):
DECLARE CONTINUE HANDLER FOR 1000 SET E='1000', M="hashchk";
DECLARE CONTINUE HANDLER FOR 1001 SET E='1001', M="isamchk";
...
...
DECLARE CONTINUE HANDLER FOR 1312 SET E='1312', M="PROCEDURE %s can't return a result set in the given context";
...
...
DECLARE CONTINUE HANDLER FOR 1638 SET E='1638', M="Non-ASCII separator arguments are not fully supported";
DECLARE CONTINUE HANDLER FOR 1639 SET E='1639', M="debug sync point wait timed out";
DECLARE CONTINUE HANDLER FOR 1640 SET E='1640', M="debug sync point hit limit reached";
...
...
DECLARE CONTINUE HANDLER FOR 2057 SET E='2057', M="The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again";
And finally, put logs in critical points:
IF E> 0 THEN
CALL WriteLog(CONCAT("Error ", E, ": ", M));
END IF;
WriteLog is another procedure that only inserts into a log table. This method gave me the error code (1312) and then some Googling worked.

Return Exception from MySQL stored procedure

I am using following Exception handler in my stored procedure.
DECLARE EXIT HANDLER FOR SQLEXCEPTION
Begin
DROP TABLE temp_checkForDuplicate;
SET outDone = -1;
End;
Here I found some code for particular
exception '1062'
DECLARE EXIT handler for 1062 set o_error_status := "Duplicate entry in table";
What if I don't know the exception number: How to handle any exception and throw its number and its message?
In versions of MySQL prior to 5.5 you cannot really do this.
Version 5.5 has introduced Signals which provide a mechanism to return specific error codes or conditions.
http://dev.mysql.com/doc/refman/5.5/en/signal.html
Version 5.6 has added "Get Diagnostics" which provides the information you need.
http://dev.mysql.com/doc/refman/5.6/en/get-diagnostics.html
You can also find related information in these SO Questions.
MySQL Stored Procedure Error Handling
How to raise an error within a MySQL function