When executing below code in phpMyAdmin:
use db;
DELIMITER $$
DROP PROCEDURE IF EXISTS McaTest3$$
CREATE PROCEDURE McaTest3()
BEGIN
SELECT
cl.*
FROM `condition_library` cl
LEFT JOIN condition_custom cc on cl.condition_library_id = cc.condition_library_id
and cc.active = 1
AND (cc.permit_application_id = 20231 OR cc.permit_id = NULL)
WHERE FIND_IN_SET(cl.`condition_library_id`, '13070')
AND cl.active = 1
and cc.condition_library_id IS NULL;
END$$
DELIMITER ;
call McaTest3();
Getting error:
Error
Static analysis:
1 errors were found during analysis.
Missing expression. (near "ON" at position 25)
SQL query: Edit Edit
SET FOREIGN_KEY_CHECKS = ON;
MySQL said: Documentation
#2014 - Commands out of sync; you can't run this command now
This happens when there is no record found in the table which is at LEFT JOIN.
When the same is ran in MySQL Workbench: NO ERROR and return empty dataset.
Same procedure when executed from Application (Appian) is failing as well… Any clues?
Another question on Stackoverflow answered my issue:
link: MySQL error #2014 - Commands out of sync; you can't run this command now
I am new to IIB, trying to connect to Oracle DB using ESQL. Trying to pass a local param to where clause in simple SELECT statement. Getting below error while executing it. Can anyone help me out
ESQL:
BROKER SCHEMA com.project
CREATE COMPUTE MODULE MainFlow_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE var REFERENCE TO Environment.Variables;
DECLARE username CHAR;
SET username = InputRoot.JSON.Data.userid;
--SET OutputRoot.XML.Invoice[] = SELECT E.EMPLOYEE_ID,E.FIRST_NAME FROM Database.HR.EMPLOYEES AS E WHERE E.EMPLOYEE_ID=username;
SET OutputRoot.XML.Invoice[] = PASSTHRU('SELECT E.EMPLOYEE_ID,E.FIRST_NAME FROM Database.HR.EMPLOYEES AS E WHERE E.EMPLOYEE_ID=?' VALUES(username));
SET OutputRoot.JSON.Data.user_id=username;
--SET OutputRoot.JSON.Data.user_name=var.profile.FIRST_NAME;
RETURN TRUE;
END;
END MODULE;
Log:
Error: BIP3113E: Exception detected in message flow com.project.MainFlow
http://localhost:7800/users/getUserDetails
Exception. BIP2230E: Error detected whilst processing a message in node 'com.project.MainFlow.Compute'. : F:\build\slot2\S1000_P\src\DataFlowEngine\SQLNodeLibrary\ImbComputeNode.cpp: 515: ImbComputeNode::evaluate: ComIbmComputeNode: com/project/MainFlow#FCMComposite_1_4
BIP2488E: ('com.project.MainFlow_Compute.Main', '14.4') Error detected while executing the SQL statement ''SET OutputRoot.XML.Invoice[] = DEFAULTPASSTHRU('SELECT E.EMPLOYEE_ID,E.FIRST_NAME FROM Database.HR.EMPLOYEES AS E WHERE E.EMPLOYEE_ID=?', username);''. : F:\build\slot2\S1000_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp: 767: SqlStatementGroup::execute: :
BIP2321E: Database error: ODBC return code '-1' using ODBC driver manager ''odbc32.dll''. : F:\build\slot2\S1000_P\src\DataFlowEngine\MessageServices\ImbOdbc.cpp: 3814: ImbOdbcStatement::checkRcInner: :
BIP2322E: Database error: SQL State ''IM001''; Native Error Code '0'; Error Text ''[Microsoft][ODBC Driver Manager] Driver does not support this function''. : F:\build\slot2\S1000_P\src\DataFlowEngine\MessageServices\ImbOdbc.cpp: 4035: ImbOdbcStatement::checkRcInner: :
Note: I have referred to below link already
IIB: Passing local variable to ESQL select statement
I am using IIB v9.0.0 on Windows, using Oracle database as source application. While running the interface, I'm getting following below issue, when execute prepared SQL query:
SELECT HDR.SHIPMENT, HDR.EST_ARR_DATE, HDR.TO_LOC, HDR.TO_LOC_TYPE,
HDR.SHIP_DATE, HDR.FROM_LOC, HDR.FROM_LOC_TYPE, HDR.COURIER,
HDR.EXT_REF_NO_OUT, HDR.FR_INSPC_FLG, HDR.FR_TRNSMT_NUM,
HDR.FR_CRRR_SUB_NUM, DTL.SEQ_NO, DTL.ITEM, DTL.QTY_EXPECTED, DTL.DISTRO_NO ,DTL.TSF_TYPE
FROM XXIF_ARV_SCH_HDR_IIB_S HDR , XXIF_ARV_SCH_DTL_IIB_S DTL
WHERE HDR.FR_BIH_STATUS = ? AND DTL.FR_BIH_STATUS = ? AND DTL.SHIPMENT =
HDR.SHIPMENT AND HDR.TO_LOC = ?
I have configured ODBC connectivity and run the command to save credentials
mqsisetdbparms DevNode -n odbc::DSN_ORACLE -u XXIF_IIB -p XXIF_IIB
ExceptionList:
RecoverableException
File:CHARACTER:F:\build\slot1\S900_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp
Line:INTEGER:650
Function:CHARACTER:SqlStatementGroup::execute
Type:CHARACTER:ImbESQLManager
Name:CHARACTER:ImbESQLManager
Label:CHARACTER:ImbESQLManager
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2488
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:XXIF_DBService.XXIF_ARV_SCH_DTL_IIB_S_OPS_GROUP.retrieveXxifASNDetails
Insert
Type:INTEGER:5
Text:CHARACTER:3.2
Insert
Type:INTEGER:5
Text:CHARACTER:SET dbResultSetRef.row[ ] = SPECIFICPASSTHRU('SELECT HDR.SHIPMENT, HDR.EST_ARR_DATE, HDR.TO_LOC, HDR.TO_LOC_TYPE, HDR.SHIP_DATE, HDR.FROM_LOC, HDR.FROM_LOC_TYPE, HDR.COURIER, HDR.EXT_REF_NO_OUT, HDR.FR_INSPC_FLG, HDR.FR_TRNSMT_NUM, HDR.FR_CRRR_SUB_NUM, DTL.SEQ_NO, DTL.ITEM, DTL.QTY_EXPECTED, DTL.DISTRO_NO , DTL.TSF_TYPE FROM XXIF_ARV_SCH_HDR_IIB_S HDR , XXIF_ARV_SCH_DTL_IIB_S DTL WHERE HDR.FR_BIH_STATUS = ? AND DTL.FR_BIH_STATUS = ? AND DTL.SHIPMENT = HDR.SHIPMENT AND HDR.TO_LOC = ?', Database.DSN_ORACLE, fr_bih_status, fr_bih_status, toloc);
DatabaseException
File:CHARACTER:F:\build\slot1\S900_P\src\DataFlowEngine\MessageServices\ImbOdbc.cpp
Line:INTEGER:3246
Function:CHARACTER:ImbOdbcStatement::checkRcInner
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2321
Text:CHARACTER:Root SQL exception
Insert
Type:INTEGER:2
Text:CHARACTER:-1
Insert
Type:INTEGER:14
Text:CHARACTER:odbc32.dll
DatabaseException
File:CHARACTER:F:\build\slot1\S900_P\src\DataFlowEngine\MessageServices\ImbOdbc.cpp
Line:INTEGER:3424
Function:CHARACTER:ImbOdbcStatement::checkRcInner
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2322
Text:CHARACTER:Child SQL exception
Insert
Type:INTEGER:5
Text:CHARACTER:IM001
Insert
Type:INTEGER:2
Text:CHARACTER:0
Insert
Type:INTEGER:5
Text:CHARACTER:[Microsoft][ODBC Driver Manager] Driver does not support this function
Anyone knows the issue, please check.
Check the options that can be configured in ODBC connection, usually you must enable some options to run the sentences and the execution of procedures and functions properly.
In Windows you need to enable checkbox "Enable Nchar support" on your user DSN.
How can I write the query result messages, which inform the user that the query was successful or not and the number of affected records, to log file in PostgreSQL.
I have tried to change log_statement to 'all' and log_min_duration_statement to 0 but all I get is the query text.
Is it possible to redirect those messages to log file in a Windows OS?
you can use GET DIAGNOSTICS for that.. And if you are a superuser, you can save result to a file...
create table tablename(version int);
insert into tablename select 9;
do
$$
declare
rc text;
begin
update tablename set version=version where false;
GET DIAGNOSTICS rc = ROW_COUNT;
raise info '%',' changed: '||rc;
update tablename set version=version where true;
GET DIAGNOSTICS rc = ROW_COUNT;
raise info '%',' changed: '||rc;
raise info '%','If you are superuser you can save result to a file...';
execute $e$copy(select '$e$||rc||$e$') to '/tmp/roes.log'$e$;
raise exception '%','raiseing error to rollback changes';
end;
$$
;
and the result looks:
INFO: changed: 0
INFO: changed: 1
INFO: If you are superuser you can save result to a file...
ERROR: raiseing error to rollback changes
********** Error **********
ERROR: raiseing error to rollback changes
SQL state: P0001
Our Continuous Inegration server (Hudosn) is having a strange issue when attempting to run a simple create table statement in Teradata.
This statement tests the existence of the max_call table:
unless $teradata_connection.table_exists? :arm_custom_db__max_call_attempt_parameters
$teradata_connection.run('CREATE TABLE all_wkscratchpad_db.max_call_attempt_parameters AS (SELECT * FROM arm_custom_db.max_call_attempt_parameters ) WITH NO DATA')
end
The table_exists? method does the following:
def table_exists?(name)
v ||= false # only retry once
sch, table_name = schema_and_table(name)
name = SQL::QualifiedIdentifier.new(sch, table_name) if sch
from(name).first
true
rescue DatabaseError => e
if e.to_s =~ /Operation not allowed for reason code "7" on table/ && v == false
# table probably needs reorg
reorg(name)
v = true
retry
end
false
end
So as per the from(name).first line, the test which this method is performing is just a simple select statement, which, in SQL, looks like: SELECT TOP 1 MAX(CAST(MAX_CALL_ATTEMPT_CNT AS BIGINT)) FROM ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS
The above SQL statement executes perfectly fine within Teradata SQL Assistant, so it's not a SQL syntax issue. The generic ID which our testing suite (Rubymine) uses is also not the issue; that ID has select access to the arm_custom_db.
The exeption which I can see is being thrown (within the builds console output on Hudson) is
Sequel::DatabaseError: Java::ComTeradataJdbcJdbc_4Util::JDBCException. Since this execption is a subclass of DatabaseError, the exception shouldn't be the problem either.
Also: We use unless statements like this every day for hundreds of different tables, and all except this one work correctly. This statement just seems to be a problem.
The complete error message which appears in the builds console output of Hudson is as follows:
[2015-01-07T13:56:37.947000 #16702] ERROR -- : Java::ComTeradataJdbcJdbc_4Util::JDBCException: [Teradata Database] [TeraJDBC 13.10.00.17] [Error 3807] [SQLState 42S02] Object 'ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS' does not exist.: SELECT TOP 1 MAX(CAST(MAX_CALL_ATTEMPT_CNT AS BIGINT)) FROM ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS
Sequel::DatabaseError: Java::ComTeradataJdbcJdbc_4Util::JDBCException: [Teradata Database] [TeraJDBC 13.10.00.17] [Error 3807] [SQLState 42S02] Object 'ALL_WKSCRATCHPAD_DB.MAX_CALL_ATTEMPT_PARAMETERS' does not exist.
I don't understand why this specific bit of code is giving me issues...there does not appear to be anything special about this table or database, and all SQL code executes perfectly fine in Teradata when I am signed in with the same exact user ID that is being used to execute the code from Hudson.