Repository: oracle/node-oracledb

Issue #186: Stored procedure - IN type CLOB
Created: 2015-09-03T13:28:56Z
Hello,
I am currently experiencing issue with executing stored procedure which has CLOB as input parameter.
Table:
--------------------------------------------------------
--  DDL for Table TRANSCRIPT
--------------------------------------------------------

  CREATE TABLE "MSE_ORA_D"."TRANSCRIPT" 
   (    "TRANSCRIPT_ID" NUMBER, 
    "CONFIG_ITEM_NAME" VARCHAR2(4000 BYTE), 
    "TRANSCRIPT" CLOB, 
    "DEBUG" CLOB, 
    "START_TIME" TIMESTAMP (0), 
    "END_TIME" TIMESTAMP (0), 
    "ERROR_MSG" VARCHAR2(4000 BYTE), 
    "SUCCESS" CHAR(1 BYTE), 
    "PARAMETRIZATION_ID" NUMBER
   ) 
Procedure:
create or replace PROCEDURE SP_ADD_TRANSCRIPT(
  SENT_CONFIG_ITEM_NAME IN TRANSCRIPT.CONFIG_ITEM_NAME%TYPE,
  SENT_TRANSCRIPT IN TRANSCRIPT.TRANSCRIPT%TYPE,
  SENT_DEBUG IN TRANSCRIPT.DEBUG%TYPE,
  SENT_START_TIME IN VARCHAR2,
  SENT_END_TIME IN VARCHAR2,
  SENT_ERROR_MSG IN TRANSCRIPT.ERROR_MSG%TYPE,
  SENT_IS_SUCCESS IN CHARACTER DEFAULT NULL,
  SENT_OCCURRENCES_IDS IN VARCHAR2 DEFAULT NULL,
  SENT_PARAMETRIZATION_ID IN CONFITEM_INSTANCE_ON_SERVER.PARAMETRIZATION_ID%TYPE DEFAULT NULL
)AS
v_start timestamp;
v_end timestamp;
BEGIN
--...
END SP_ADD_TRANSCRIPT;
Node.js code:
connection.execute(
        statement,
        options,
        [],
        function (err, result) {
            console.log("execution done", err, result);
            connection.release(function (err_release) {
                //notify somehow!
                if (err_release) {
                    console.log("ERROR > RELEASE CONNECTION", err_release);
                }
            });
            callback(err, result);
        });
Statement (executed in Node.js):
BEGIN SP_ADD_TRANSCRIPT(:SENT_CONFIG_ITEM_NAME,:SENT_TRANSCRIPT,:SENT_DEBUG,:SENT_START_TIME,:SENT_END_TIME,:SENT_ERROR_MSG,:SENT_IS_SUCCESS,:SENT_OCCURRENCES_IDS,:SENT_PARAMETRIZATION_ID); END;
Options:
{ SENT_CONFIG_ITEM_NAME: { val: 'Cos tam cos', dir: 3001, type: 2001 },
  SENT_TRANSCRIPT: { val: 'jakeis tam wiadomosci', dir: 3001, type: 2006 },
  SENT_DEBUG: { val: 'informacje dodatkowe', dir: 3001, type: 2006 },
  SENT_START_TIME: { val: '1441274497', dir: 3001, type: 2001 },
  SENT_END_TIME: { val: '1441275497', dir: 3001, type: 2001 },
  SENT_ERROR_MSG: { val: '', dir: 3001, type: 2001 },
  SENT_IS_SUCCESS: { val: '1', dir: 3001, type: 2001 },
  SENT_OCCURRENCES_IDS: { val: '', dir: 3001, type: 2001 },
  SENT_PARAMETRIZATION_ID: { val: '903712', dir: 3001, type: 2001 } }
Error produced:
[Error: NJS-011: encountered bind value and type mismatch in parameter 2]
which is obviously a CLOB (this is, 2nd parameter). type 2006 == oracledb.CLOB;
oracledb version: 1.1
node version: v0.12.7
arch: 32bit
OS: Windows
Could you please assist?
//edit
create or replace PROCEDURE NODE_CLOB_TEST(
  inVarchar IN VARCHAR2,
  inClob IN CLOB
)AS
vDummy integer;
BEGIN
  select 1 into vDummy from dual;
END NODE_CLOB_TEST;
var statement = "BEGIN NODE_CLOB_TEST(:inVarchar, :inClob); END;";
var options = {
    inVarchar : 'test',
    inClob : {
        val : 'test2',
        dir : 3001,
        type: 2006
    }
};
connection.execute(
        statement,
        options,
        [],
        function (err, result) {
            console.log("execution done", err, result);
            connection.release(function (err_release) {
                if (err_release) {
                    console.log("ERROR > RELEASE CONNECTION", err_release);
                }
            });
            callback(err, result);
        });

Duplicate issue #464: Need to read and write to XMLTYPE columns
Created: 2016-06-29T00:03:21Z
I need to write a service providing a REST interface to our database that holds XMLTYPE data in one of the columns.
One of the purposes of this service is to provide the XML content to callers.  It will also need to be able to write to this column when callers provide new data.
In writing a small Node.js appliation using Oracledb, I found that I am unable to retrieve the XML data using a select statement.  I get the following error:
NJS-010: unsupported data type in select list
Here is the code that generates the error:
    module.connection.execute(
        "select experiment_xml from cm_experiment where cm_experiment_id= :id",
        [req.params.id],  // bind value for :id
        function(err, result)
        {
            if (err) { console.error(err.message); return; }
            console.log(result.rows);
        });

The column "EXPERIMENT_XML" is type XMLTYPE.
Is there a way to do this using Oracledb and Node or do I need to use some other framework?
Versions:
node: v4.4.5
npm: 2.15.5
Instantclient: (from BASIC_README file)
Thu Sep 11 02:53:25 CDT 2014
Client Shared Library 64-bit - 12.1.0.2.0
Environment variables:
OCI_INC_DIR=C:\apps\instanclient_12_64bit\sdk\include
OCI_LIB_DIR=C:\apps\instanclient_12_64bit\sdk\lib\msvc
path has C:\apps\instanclient_12_64bit in it
Running Windows 7 Enterprise 64 bit (6.1 build 7601) English

Closing comment (2016-07-21T02:45:27Z): Closing this.  'Temporary LOB' support is really needed, which is tracked in #186 and #204.  Otherwise you end up having to use temporary tables for inserting XML.