oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

Unable to get custom Package Type Object class using getDbObjectClass() #1680

Closed kandukurivarun closed 2 weeks ago

kandukurivarun commented 3 weeks ago

Node OracleDB Version: 6.5.1 Oracle Database version: 19c

I have created a package on my DB manually using the below snippet

`CREATE OR REPLACE PACKAGE test.pkg_trace_loop AS TYPE devices IS TABLE OF NUMBER (10,0);

PROCEDURE sp_trace_loop
(
    p_link IN NUMBER,
    p_devices IN OUT NOCOPY devices,
    p_opens IN OUT NOCOPY devices
)
;

END;`

In above snippet test is the schama/user name and the pkg_trace_loop is the package name. Now I want to reference the custom Type devices in my NodeJS snippet. For this I have used the below code:

let deviceTypeClass = await conn.getDbObjectClass("test.pkg_trace_loop.devices"); let deviceClass = new deviceTypeClass(Number);

I am receiving the error mentioned below with the above syntax:

Error: NJS-129: invalid object type name: "test.pkg_trace_loop.devices"

I tried removing the schema name as well but it returns the same error.

I couldnt find much examples of how I can get working. Any pointers to the solution or the issue are appreciated

anthony-tuininga commented 3 weeks ago

Try with all uppercase:

const deviceTypeClass = await conn.getDbObjectClass("TEST.PKG_TRACE_LOOP.DEVICES");

The lookup is case sensitive and in most cases package names and the like are not quoted when they are created, so they are converted to all upper case.

kandukurivarun commented 2 weeks ago

@anthony-tuininga Thank you for the response. I was able to solve the issue with the suggestion you provided and I am now having issue with translating the below SQL block into my oracledb package binds

DECLARE Devices1 SCHEMA_NAME.PKG_TRACE_LOOP.devices :=SCHEMA_NAME.PKG_TRACE_LOOP.devices(); OPEN_Devices SCHEMA_NAME.PKG_TRACE_LOOP.devices :=SCHEMA_NAME.PKG_TRACE_LOOP.devices(); BEGIN SCHEMA_NAME.PKG_TRACE_LOOP.SP_TRACE_LOOP(180642903, Devices1, OPEN_Devices); END;

I want to access the values of Devices1 and OPEN_Devices back in my JS code.

kandukurivarun commented 2 weeks ago

@anthony-tuininga Thank you for the response. I was able to solve the issue with the suggestion you provided and I am now having issue with translating the below SQL block into my oracledb package binds

DECLARE Devices1 SCHEMA_NAME.PKG_TRACE_LOOP.devices :=SCHEMA_NAME.PKG_TRACE_LOOP.devices(); OPEN_Devices SCHEMA_NAME.PKG_TRACE_LOOP.devices :=SCHEMA_NAME.PKG_TRACE_LOOP.devices(); BEGIN SCHEMA_NAME.PKG_TRACE_LOOP.SP_TRACE_LOOP(180642903, Devices1, OPEN_Devices); END;

I want to access the values of Devices1 and OPEN_Devices back in my JS code.

Able to solve the above issue. Thanks for looking into it though.