Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to input Date format for Oracle SQL query using TypeORM?

User_08AYVOct 6 2021

I'm using TypeORM to call a procedure in my Oracle database.
There are some inputs to this procedure, including string or number format. However, date format always gives me an error.
[Case 1]

let connection = await this._database.getConnectin();
let sqlStr: string = "CALL P_OP_MR_SMOOTH(:1,:2,to_date(:3,'YYYY-MM-DD HH24:MI:SS'),:4,:5,:6)";

const result = await connection.manager.query(sqlStr,
  ["ABCD12345678", "3", "2021-10-06 16:00:00", "ABCDEFG-123456",
  {dir: oracledb.BIND_OUT, type: oracledb.NUMBER}, {dir: oracledb.BIND_OUT, type: oracledb.STRING});
)

ORA-01858: a non-numeric character was found where a numeric was expected
[Case 2]

let connection = await this._database.getConnectin();
let sqlStr: string = "CALL P_OP_MR_SMOOTH(:1,:2,to_timestamp(:3,'YYYY-MM-DD\"T\"HH24:MI:SS.ff3\"Z\"'),:4,:5,:6)";

// "2021-10-06T16:00:00.000Z"
const result = await connection.manager.query(sqlStr,
  ["ABCD12345678", "3", new Date(), "ABCDEFG-123456",
  {dir: oracledb.BIND_OUT, type: oracledb.NUMBER}, {dir: oracledb.BIND_OUT, type: oracledb.STRING});
)

ORA-01847: day of month must be between 1 and last day of month
Could someone help me figure out how to correct it?

Comments
Post Details
Added on Oct 6 2021
0 comments
1,328 views