Title: timestamp in cursor comparison > expect() has problem with precision / nls · Issue #771 · utPLSQL/utPLSQL · GitHub
Open Graph Title: timestamp in cursor comparison > expect() has problem with precision / nls · Issue #771 · utPLSQL/utPLSQL
X Title: timestamp in cursor comparison > expect() has problem with precision / nls · Issue #771 · utPLSQL/utPLSQL
Description: In our project we use a lot of timestamp(6) columns. Our calls to ut.expect() run into problems with comparisons between sys_refcursors that contain timestamp(6) columns. I prepared three little attachments that should help demonstrate t...
Open Graph Description: In our project we use a lot of timestamp(6) columns. Our calls to ut.expect() run into problems with comparisons between sys_refcursors that contain timestamp(6) columns. I prepared three little at...
X Description: In our project we use a lot of timestamp(6) columns. Our calls to ut.expect() run into problems with comparisons between sys_refcursors that contain timestamp(6) columns. I prepared three little at...
Opengraph URL: https://github.com/utPLSQL/utPLSQL/issues/771
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"timestamp in cursor comparison > expect() has problem with precision / nls","articleBody":"In our project we use a lot of ```timestamp(6)``` columns. Our calls to ```ut.expect()``` run into problems with comparisons between sys_refcursors that contain ```timestamp(6)``` columns. \r\n\r\nI prepared three little attachments that should help demonstrate the problem and show our current solution. But this solution is not perfect, as it only fixes the problem for our ```timestamp(6)``` columns and we would like to see a more general solution.\r\n\r\nIf you can help in any way, that would be great.\r\n\r\n**Attachments**\r\n\r\n1. ```setup.sql``` - creates one table and two packages designed to demonstrate the problem.\r\n2. ```problem_demo.sql``` - shows our NLS_SESSION_PARAMETERS, starts the ut-test and quotes the fail message we get from this unit test run ... if we do not patch the current UT3 installation\r\n3. ```our_solution_so_far.txt``` - describes how we got around the problem with a very small patch, but we lack the utplsql knowlege to find a general fix, so we ask you for help.\r\n______________________________________________________________________\r\n\r\n```setup.sql``` - creates one table and two packages designed to demonstrate the problem\r\n\r\n```\r\n/*\r\n name\r\n setup.sql\r\n version\r\n 1.0, 2018-10-31\r\n author\r\n MalachiasTS\r\n\r\n purpose\r\n Build a table and two packages in the current schema \r\n which are needed to demonstrate a problem with the \r\n comparison timestamp columns in sys_refcursors.\r\n\r\n creates\r\n tables\r\n TMP_NLS_TEST\r\n packages\r\n P_NLS_TEST\r\n P_NLS_TEST_UT\r\n*/\r\n\r\n--drop table tmp_nls_test;\r\n\r\ncreate table tmp_nls_test (\r\n id number,\r\n\tats3 timestamp (3),\r\n\tats6 timestamp (6),\r\n\tats9 timestamp (9)\r\n);\r\n\r\ninsert into tmp_nls_test (id, ats3, ats6, ats9) \r\nvalues (1, systimestamp, systimestamp, systimestamp);\r\ncommit;\r\n\r\n--drop package p_nls_test;\r\n\r\ncreate or replace package p_nls_test\r\nis\r\n procedure insert_into_nls_test (\r\n i_id tmp_nls_test.id%type,\r\n i_timestamp3 tmp_nls_test.ats3%type,\r\n i_timestamp6 tmp_nls_test.ats6%type,\r\n i_timestamp9 tmp_nls_test.ats9%type\r\n );\r\nend p_nls_test;\r\n/\r\n\r\ncreate or replace package body p_nls_test\r\nas\r\n procedure insert_into_nls_test (\r\n i_id tmp_nls_test.id%type,\r\n i_timestamp3 tmp_nls_test.ats3%type,\r\n i_timestamp6 tmp_nls_test.ats6%type,\r\n i_timestamp9 tmp_nls_test.ats9%type\r\n )\r\n is\r\n begin\r\n insert into tmp_nls_test (id, ats3, ats6, ats9) \r\n values (i_id, i_timestamp3, i_timestamp6, i_timestamp9);\r\n\r\n --commit;\r\n end insert_into_nls_test;\r\nend p_nls_test;\r\n/\r\n\r\n--drop package p_nls_test_ut;\r\n\r\ncreate or replace package p_nls_test_ut\r\nis\r\n -- %suite(nls_test)\r\n -- %suitepath(nls_test)\r\n\r\n -- %test(check that inserts into tmp_nls_test work correctly)\r\n procedure ut_insert_into_nls_test;\r\nend p_nls_test_ut;\r\n/\r\n\r\ncreate or replace package body p_nls_test_ut\r\nis\r\n procedure ut_insert_into_nls_test\r\n is\r\n lv_new_id number;\r\n lv_ts timestamp(9);\r\n\r\n lc_exp sys_refcursor;\r\n lc_act sys_refcursor;\r\n begin\r\n -- get new id\r\n select max(id)+1\r\n into lv_new_id\r\n from tmp_nls_test;\r\n\r\n -- get a valid timestamp with timezone\r\n select systimestamp\r\n into lv_ts\r\n from dual;\r\n\r\n -- insert a record with these values\r\n p_nls_test.insert_into_nls_test (lv_new_id, null, lv_ts, null);\r\n\r\n\r\n -- build two cursors\r\n ut.set_nls();\r\n\r\n -- fill cursor with expected values by selecting from dual\r\n open lc_exp for\r\n select\r\n lv_new_id as id, \r\n to_timestamp (null) as ats3, \r\n lv_ts as ats6, \r\n to_timestamp (null) as ats9\r\n from dual;\r\n\r\n -- fill cursor with actual table values.\r\n open lc_act for\r\n select id, ats3, ats6, ats9\r\n from tmp_nls_test\r\n where id = 2;\r\n \r\n ut.reset_nls();\r\n\r\n -- compare variable with table values\r\n ut.expect (lc_act).to_equal (lc_exp);\r\n \r\n end ut_insert_into_nls_test;\r\nend p_nls_test_ut;\r\n/\r\n```\r\n________________________________________________\r\n```problem_demo.sql``` - shows our NLS_SESSION_PARAMETERS, starts the ut-test and quotes the fail message we get from this unit test run ... if we do not patch the current UT3 installation.\r\n\r\n```\r\n/*\r\nselect * from NLS_SESSION_PARAMETERS;\r\n\r\nPARAMETER VALUE\r\n----------------------------------------------------------\r\nNLS_LANGUAGE AMERICAN\r\nNLS_TERRITORY AMERICA\r\nNLS_CURRENCY $\r\nNLS_ISO_CURRENCY AMERICA\r\nNLS_NUMERIC_CHARACTERS .,\r\nNLS_CALENDAR GREGORIAN\r\nNLS_DATE_FORMAT yyyy-mm-dd hh24:mi:ss\r\nNLS_DATE_LANGUAGE AMERICAN\r\nNLS_SORT BINARY\r\nNLS_TIME_FORMAT HH.MI.SSXFF AM\r\nNLS_TIMESTAMP_FORMAT yyyy-mm-dd hh24:mi:ssxff\r\nNLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR\r\nNLS_TIMESTAMP_TZ_FORMAT yyyy-mm-dd hh24:mi:ssxff tzh:tzm\r\nNLS_DUAL_CURRENCY $\r\nNLS_COMP BINARY\r\nNLS_LENGTH_SEMANTICS\tBYTE\r\nNLS_NCHAR_CONV_EXCP FALSE\r\n*/\r\n\r\nbegin\r\n ut.run ('p_nls_test_ut');\r\nend;\r\n/\r\n\r\n/*\r\nDBMS OUTPUT:\r\n\r\nnls_test\r\n nls_test\r\n check that inserts into tmp_nls_test work correctly [.149 sec] (FAILED - 1)\r\n \r\nFailures:\r\n \r\n 1) ut_insert_into_nls_test\r\n Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]\r\n Diff:\r\n Rows: [ 1 differences ]\r\n Row No. 1 - Actual: \u003cATS6>2018-10-31T17:11:51.150893\u003c/ATS6>\r\n Row No. 1 - Expected: \u003cATS6>2018-10-31T17:11:51.150893000\u003c/ATS6>\r\n at \"\u003cschema>.P_NLS_TEST_UT.UT_INSERT_INTO_NLS_TEST\", line 46 ut.expect (lc_act).to_equal (lc_exp);\r\n \r\n \r\nFinished in .15082 seconds\r\n1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s)\r\n */\r\n```\r\n_________________________________________________________\r\n```our_solution_so_far.txt``` - describes how we got around the problem with a very small patch, but we lack the utplsql knowlege to find a general fix, so we ask you for help.\r\n\r\nWhat fixed it for us was ...\r\n\r\nWe patched two rows in the header of package ```UT_UTILS```:\r\n\r\nline 120:\r\n```\r\n gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd\"T\"hh24:mi:ssxff';\r\n->: gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd\"T\"hh24:mi:ssxff6'; -- patched\r\n```\r\n\r\nline 121:\r\n```\r\n gc_timestamp_tz_format constant varchar2(100) := 'yyyy-mm-dd\"T\"hh24:mi:ssxff tzh:tzm';\r\n->: gc_timestamp_tz_format constant varchar2(100) := 'yyyy-mm-dd\"T\"hh24:mi:ssxff6 tzh:tzm'; -- patched\r\n```\r\n\r\nThis patch only fixes it for ```timestamp(6)```.\r\nLucky for us, if we use timestamp types at all, then we always use ```TIMESTAMP(6)``` ... presently.\r\n\r\nWhat would be a general solution?","author":{"url":"https://github.com/MalchiasTS","@type":"Person","name":"MalchiasTS"},"datePublished":"2018-10-31T17:24:23Z","url":"https://github.com/utPLSQL/utPLSQL/issues/771"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dc807eab-73f5-f2ba-122d-8826968c55a5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCDA:378EF4:356619:4946B6:6B04BAD5 |
| html-safe-nonce | 853b83d3fe702f3c4bff9d20cb0e2d34f02f4bd71d6ab85f47b355999e6fe9b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0RBOjM3OEVGNDozNTY2MTk6NDk0NkI2OjZCMDRCQUQ1IiwidmlzaXRvcl9pZCI6IjI5MzkxMzczMzQ2Njg3MzcyMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 26ee980b4d58da58decc21c133c03f5977798bb000bb6c9508a0912a2b8b29de |
| hovercard-subject-tag | issue:376076156 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/utPLSQL/utPLSQL/771/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b87ec437bfdf23fbe901a54615a66a61e6b4bb4106122fd0d000734c8ac7322d/utPLSQL/utPLSQL/issues/771 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b87ec437bfdf23fbe901a54615a66a61e6b4bb4106122fd0d000734c8ac7322d/utPLSQL/utPLSQL/issues/771 |
| og:image:alt | In our project we use a lot of timestamp(6) columns. Our calls to ut.expect() run into problems with comparisons between sys_refcursors that contain timestamp(6) columns. I prepared three little at... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MalchiasTS |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85dd75377eb77313206b8fc108bcee6a3a029286d94bf32bf9b4426e4d92e0c4 |
| turbo-cache-control | no-preview |
| go-import | github.com/utPLSQL/utPLSQL git https://github.com/utPLSQL/utPLSQL.git |
| octolytics-dimension-user_id | 15661281 |
| octolytics-dimension-user_login | utPLSQL |
| octolytics-dimension-repository_id | 50728220 |
| octolytics-dimension-repository_nwo | utPLSQL/utPLSQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 50728220 |
| octolytics-dimension-repository_network_root_nwo | utPLSQL/utPLSQL |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0d64fa748a2bab9a5b587a967ac4da1cfa8da6dd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width