[IBM][CLI Driver] CLI0125E Function sequence error on RUBY - ruby

require "ibm_db"
=> true
db_config = {:host=>"ec2-<>.compute.amazonaws.com", :database=>"SAMPLE", :user=>"user", :password=>"pass", :port=>50000}
db_conn = IBM_DB.connect("DATABASE=#{db_config[:database]};HOSTNAME=#{db_config[:host]};PORT=#{db_config[:port]};PROTOCOL=TCPIP;UID=#{db_config[:user]};PWD=#{db_config[:password]};AUTHENTICATION=SERVER;ClientWrkStnName=tester", "", "")
=> #<IBM_DB::Connection:0x00007fa563fbc8f8>
IBM_DB.autocommit(db_conn)
=> 1
IBM_DB.autocommit(db_conn,0)
=> true
IBM_DB.autocommit(db_conn)
=> 0
sql = "INSERT INTO TTE (name, price) VALUES (?,?)"
stmt = IBM_DB.prepare(db_conn, sql)
#<IBM_DB::Statement:0x00007fa564ce28c0>
value = "string"
IBM_DB.bind_param(stmt,1,value)
(pry):12: warning: Describe Param Failed: [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 SQLCODE=-99999
=> false
tried another way
param = ["sr", 1]
=> ["sr", 1]
IBM_DB.execute(stmt, param)
(pry):14: warning: Execute Failed due to: [IBM][CLI Driver] CLI0125E Function sequence error. SQLSTATE=HY010 SQLCODE=-99999
=> false
Getting CLI0125E Function sequence error for both ways. Not sure how to resolve it.
I'm on Mac catalina, using ibm_db (3.0.5)
.zschrc
export IBM_DB_HOME=/Applications/dsdriver
export DYLD_LIBRARY_PATH=/Applications/dsdriver/lib
export LD_LIBRARY_PATH=/Applications/dsdriver/lib

There was a mismatch in the table scheme. The field price was not present. Corrected the table schema and the query is working.

Related

The "error_marshaling_enabled" setting seems to be always enabled

When I run this code:
$client->evaluate('
box.session.settings.error_marshaling_enabled = false
box.error{code = 42, reason = "Foobar", type = "MyError"}
');
regardless of the value of error_marshaling_enabled I always get a response with a new (extended) error format:
[
49 => 'Foobar',
82 => [
0 => [
0 => [
0 => 'CustomError',
2 => 3,
1 => 'eval',
3 => 'Foobar',
4 => 0,
5 => 42,
6 => [
'custom_type' => 'MyError',
],
],
],
],
],
Why is that?
Short answer.
error_marshaling_enabled option affects only how error objects are encoded in response body (48, IPROTO_DATA). It does not affect how they are returned as exceptions, in the response header (82, IPROTO_ERROR).
Long answer.
In Tarantool an error object can be returned in 2 ways: as an exception and as an object. For example, this is how to throw an error as exception:
function throw_error()
box.error({code = 1000, reason = "Error message"})
-- Or
error('Some error string')
end
This is how to return it as an object:
function return_error()
return box.error.new({code = 1000, reason = "Error message"})
end
If the function was called remotely, using IPROTO protocol via a connector like netbox, or PHP connector, or any other one, the error return way affects how it is encoded into MessagePack response packet. When the function throws, and the error reaches the top stack frame without being caught, it is encoded as IPROTO_ERROR (82) and IPROTO_ERROR_24 (49).
When the error object is returned as a regular value, not as an exception, it is encoded also as a regular value, inside IPROTO_DATA (48). Just like a string, a number, a tuple, etc.
With encoding as IPROTO_ERROR/IPROTO_ERROR_24 there is no much of a configuration space. Format of these values can't be changed. IPROTO_ERROR is always returned as a MessagePack map, with a stack of errors in it. IPROTO_ERROR_24 is always an error message. The IPROTO_ERROR_24 field is kept for compatibility with connectors to Tarantool versions < 2.4.1.
With encoding as a part of IPROTO_DATA you can choose serialization way using error_marshaling_enabled option. When it is true, errors are encoded as MessagePack extension type MP_EXT, and contain the whole error stack, encoded exactly like IPROTO_ERROR value. When the option is false (default behaviour in 2.4.1), the error is encoded as a string, MP_STR, which is the error's message. If there is a stack of errors, only the newest error is encoded.
error_marshaling_enabled option exists for backward compatibility, in case your application on Tarantool wants to be compatible with old connectors, which don't support MP_EXT encoded errors.
In Tarantool < 2.4.1 errors were encoded into result MessagePack as a string with error message, and error stacks didn't exist at all. So when the new format and the error stacks feature were introduced, making the new format default would be a too radical change breaking the old connectors.
Consider these examples of how error marshaling affects results. I use Tarantool 2.4.1 console here, and built-in netbox connector. The code below can be copy pasted into the console.
First instance:
box.cfg{listen = 3313}
box.schema.user.grant('guest', 'super')
function throw_error()
box.error({code = 1000, reason = "Error message"})
end
function return_error()
return box.error.new({code = 1000, reason = "Error message"})
end
Second instance:
netbox = require('net.box')
c = netbox.connect(3313)
Now I try to call the function on the second instance:
tarantool> c:call('throw_error')
---
- error: Error message
...
The c:call('throw_error') threw an exception. If I catch it using pcall() Lua function, I will see the error object.
tarantool> ok, err = pcall(c.call, c, 'throw_error')
tarantool> err:unpack()
---
- code: 1000
base_type: ClientError
type: ClientError
message: Error message
trace:
- file: '[string "function throw_error()..."]'
line: 2
...
As you can see, I didn't set error_marshaling_enabled, but got the full error. Now I will call the other function, without exceptions. But the error object won't be full.
tarantool> err = c:call('return_error')
tarantool> err
---
- Error message
...
tarantool> err:unpack()
---
- error: '[string "return err:unpack()"]:1: attempt to call method ''unpack'' (a nil
value)'
...
The error was returned as a mere string, error message. Not as an error object. Now I will turn on the marshaling:
tarantool> c:eval('box.session.settings.error_marshaling_enabled = true')
---
...
tarantool> err = c:call('return_error')
---
...
tarantool> err:unpack()
---
- code: 1000
base_type: ClientError
type: ClientError
message: Error message
trace:
- file: '[C]'
line: 4294967295
...
Now the same function returned the error in the new format, more featured.
On the summary: error_marshaling_enabled affects only returned errors. Not thrown errors.

LOGSTASH - Issue with JDBC input connected to HSQL DB database when selecting ARRAY columns

I'm having troubles to successfully import HSQL DB database content using Logstash's JDBC input plugin.
The problem occurs when I try to fetch a column that is of type ARRAY.
Please note that if I try to fetch non-array columns, it works just fine.
I get the following error message from Logstash :
[WARN ][logstash.inputs.jdbc ] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::OrgLogstash::MissingConverterException: Missing Converter handling for full class name=org.hsqldb.jdbc.JDBCArray, simple name=JDBCArray>}
[INFO ][logstash.pipeline ] Pipeline has terminated {:pipeline_id=>"hsql", :thread=>"#<Thread:0x7b626752 run>"}
Please find below the input part of the Logstash conf file (PLATFORM_DESTINATION_CANDIDATES is the name of a column in a table.)
input {
jdbc {
jdbc_driver_library => "hsqldb_2.5.0.jar"
jdbc_driver_class => "org.hsqldb.jdbc.JDBCDriver"
jdbc_connection_string => "jdbc:hsqldb:hsql://localhost/probe"
jdbc_user => "SA"
statement => "SELECT PLATFORM_DESTINATION_CANDIDATES FROM PUBLIC.MESSAGES_SENT"
connection_retry_attempts => 10
}
}
Did any of you encounter this kind of problem, and how did you solve it ?
Thanks.
OS : windows 10
Logstash version : 6.3.1
HSQLDB driver version : 2.5.0 (LINK)
I do not know if it is the best solution, but I managed to solve my issue. Here is how.
I replaced the line :
statement => "SELECT PLATFORM_DESTINATION_CANDIDATES FROM PUBLIC.MESSAGES_SENT"
with :
statement => SELECT concat_ws('', PLATFORM_DESTINATION_CANDIDATES , '') AS str_platforms
It has the consequence to put in the field str_platforms of type string data that looks like : ARRAY[1,2,3,4]
With the following ruby line, I then remove unwanted characters ( ARRAY[ and ] ) from the field :
ruby {
code => "event.set('listRxUnits',event.get('str_platforms').split('ARRAY[')[1].split(']')[0])"
}

IIB v10: Passing local variable to ESQL select statement

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

CI_session and Error Number: 1054 (Unknown column ...)

I have got problem with ci_session. When I am creating query with Active Record and I use session, it throws me Error Number: 1054.
It is caused by Session.php . I am using database session and when it executes sess_write(), then it throws error.
Can I create new instance of $this->db ?
Error is at line no. 289 in Session.php
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
In this place is set $this->CI->db->order_by(‘something’), from my code, before I call $this->session and this is my problem.
EDIT (13:12):
Unknown column 'contract.created' in 'order clause'
UPDATE `ci_sessions` SET `last_activity` = 1393330303, `user_data` = 'some_data' WHERE `session_id` = 'ea330d7194f902b6b38b88d509766560' ORDER BY `contract`.`created` DESC LIMIT 30
Filename: C:\Apache24\htdocs\Trokadero_v5\system\database\DB_driver.php
EDIT 2:
I am sure, it is happening by Active Record , because sequence of AR tasks is:
My_controller.php
$this->db->order_by('contract.created', 'DESC');
$this->session->set_flashdata('order_by_direction', 'DESC');
And then is executing in Session.php, with my own order_by clause
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
I got it.
$this->session->userdata();
$this->session->set_userdata();
etc.
MUST BE used before/after execute your own CRUD ($this->db->...).
In your controller, you have to reset the db query.
$this->db->order_by('contract.created', 'DESC');
// add line of code to get data. After getting data, reset the db object.
$this->db->_reset_write();
$this->session->set_flashdata('order_by_direction', 'DESC');

Oracle PLSQL CreateSchemaBasedXML using multiple schemas

I am trying to perform XSD validation against an XML document within PLSQL and I'm having an issue with getting it working.
I have created an XMLTYPE object, which when I call isSchemaBased() against it returns 0 (false). Now obviously the XMLTYPE needs to be schema based in order to be validated, I found that you can make a schema based version by calling createSchemaBasedXML against the XMLTYPE. The problem I am having is that my schema is broken into two parts (combining the schema files is not an option unfortunately), which means that when I try and createSchemaBasedXML specifying the main schema it fails because it is unable to resolve a reference which is imported from the second XSD document.
-- lxml is the XMLTYPE which has been populated with the XML before this point
dbms_xmlschema.registerSchema(
schemaURL => mainSchemaURL,
schemaDoc => mainSchemaDoc,
local => true,
genTypes => true,
genTables => false,
force => true,
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
dbms_xmlschema.registerSchema(
schemaURL => importedSchemaURL,
schemaDoc => importedSchemaDoc,
local => true,
genTypes => true,
genTables => false,
force => true,
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
if lxml.isSchemaBased() = 1 then
dbms_output.put_line('Schema based');
else
dbms_output.put_line('Non-schema based');
end if;
dbms_ouput.put_line('About to apply schema');
lxml := lxml.createSchemaBasedXML(mainSchemaURL);
dbms_ouput.put_line('We don't get this far');
lxml := lxml.createSchemaBasedXML(importedSchemaURL);
Is there any way of being able to import both the mainSchemaURL and the importedSchemaURL at the same time so that the imported schema references within the main schema don't cause the failure;
ORA-31079: unable to result reference to type [type containing imported type]
Any help or pointers would be greatly appreciated.
UPDATE: I am working with Oracle version 11g
The answer was provided by 'odie_63' on the Oracle forums [here][1]
In the end it was a case of specifying the schemaLocation for the import of the importedSchema
[1]: https://forums.oracle.com/message/11135111 "CreateSchemaBasedXML using multiple schemas
"

Resources