繁体   English   中英

ORA-01722:包装中的编号无效

[英]ORA-01722: invalid number with package

我已经浏览了许多线程,但仍然没有答案。

我在运行脚本之前告诉SQL开发人员充当发现者(已创建的程序包),但是在运行查询时它会返回ORA-01722:无效编号。

我从针对double的包中进行选择,它返回值。

有人可以指出我为什么返回此错误消息的正确方向吗?

 select gsb.name       "Set of Books Name"
,       gsb.set_of_books_id         "Set of Books Id"
,       gjb.name                    "Batch Name"
,       gjh.name                    "Journal Name"
,       trunc(gjh.date_created)     "Journal Header Date Created"     
,       gjh.status                  "Journal Header Status"   
,       gcc.segment1                "Company"
,       gcc.segment7                "Interco Code"
,       APT.term_id                 "Term ID"
,       APT.Name                    "Type of Term"    
,       APT.Description             "Term Decription"
,       ffvt3.description           "Intercompany Descr"
,       gcc.segment2                "Natural Account Code" 
,       ffvt.description            "Natural Account Descr"
,       gcc.segment3                "Cost Centre Code"
,       ffvt2.description           "Cost Centre Descr"
,       gjl.je_line_num             "Je Line Num"
,       gjh.currency_code           "Currency Code"
,       gjl.description             "Line Description"
,       gjh.period_name             "Period Name"
,       gpd.period_num              "Period Num"
,       gpd.period_year             "Period Year"
,       gjc.user_je_category_name   "Category Name"
,       gjs.user_je_source_name     "Source Name"
,       gjl.status                  "Line Status"
,       gjh.actual_flag             "Actual Flag"
,       nvl(gjl.accounted_dr,0)     "Acctd Dr"
,       nvl(gjl.accounted_cr,0)     "Acctd Cr"
,       trunc(gjh.posted_date)      "GL Date"
,       gjl.attribute3              "Recon Status"
,       gjl.effective_date          "Line GL Date"
,       gjl.reference_1             "Reference1"
,       gjl.reference_4             "Reference4"
,       gjl.reference_2             "Invoice Id"
,       pov.vendor_name             "Vendor Name"
,       pov.segment1               "Vendor Number"
,     CASE
        WHEN gjl.reference_6 = 'CUSTOMER' 
        THEN gjl.reference_4
        ELSE gjl.reference_5 
      END                           "Invoice Num" 
,       gjh.doc_sequence_value      "Doc Num"
,       gjh.doc_sequence_value      "Journal Voucher Num"
,       api.invoice_date            "Invoice Date"
,       api.voucher_num             "Image Num"
,       api.discount_amount_taken   "discount amount"
,       api.attribute1              "PO Number"
,       api.attribute2              "GRN Number"
,       api.attribute3              "Invoice Approver"
,       pvs.vendor_site_code        "Vendor Site Code"
,       gjl.code_combination_id     "Code Combination Id"
,       gcc.concatenated_segments   "Full Account Code"
,       api.amount_paid             "Amount Paid"
,       api.base_amount             "Base Amount"
,       api.creation_date           "Creation Date"
,       api.description             "AP Inv Description"
,       api.invoice_amount          "Invoice Amount"
,       api.invoice_type_lookup_code "Invoice Type"
,       api.source "Invoice Source"
,       gjh.posted_date             "Posted Date"
,       aca.check_date              "Payment Date"
,       aca.check_number        "Payment Number"
,       case when gjl.reference_6 = 'CUSTOMER' then gjl.reference_4
             else null 
        end                         "Trans Number"
,       case when gjl.reference_6 = 'CUSTOMER' then 
             (select distinct customer_name
            from ar_customers_v
               where customer_number = gjl.reference_5) 
             else null 
        end                          "Customer Name"
from    gl_je_batches               gjb
,       gl_je_headers               gjh
,       gl_je_lines                 gjl
,       gl_periods                  gpd
,       gl_code_combinations_kfv    gcc
,       gl_sets_of_books            gsb
,       gl_je_categories_tl         gjc
,       gl_je_sources_tl            gjs        
,       fnd_flex_value_sets         ffvs
,       fnd_flex_values             ffv
,       fnd_flex_values_tl          ffvt
,       fnd_flex_value_sets         ffvs2
,       fnd_flex_values             ffv2
,       fnd_flex_values_tl          ffvt2
,       fnd_flex_value_sets         ffvs3
,       fnd_flex_values             ffv3
,       fnd_flex_values_tl          ffvt3
,       ap_invoices_all             api   
,       po_vendors                  pov       
,       po_vendor_sites_all         pvs
,       ap_invoice_payments_all     aip
,       ap_checks_all               aca
,       AP_TERMS_VL                 apt
where   gjb.je_batch_id             = gjh.je_batch_id
and     gjh.je_header_id            = gjl.je_header_id
and     gjl.code_combination_id     = gcc.code_combination_id
and     gjc.je_category_name        = gjh.je_category
and     gjc.language                = 'US'
and     gjs.je_source_name          = gjh.je_source
and     gjs.language                = 'US'
and     ffvs.flex_value_set_id      = ffv.flex_value_set_id
and     ffvs.flex_value_set_name    = XXASW_DISCO_UTIL_PKG.xxasw_get_gl_segment_fvs_name ('SEGMENT2')
and     ffv.flex_value              = gcc.segment2
and     ffv.flex_value_id           = ffvt.flex_value_id
and      ffvt.language               = 'US'
and     ffvs2.flex_value_set_id     = ffv2.flex_value_set_id
and     ffvs2.flex_value_set_name   = XXASW_DISCO_UTIL_PKG.xxasw_get_gl_segment_fvs_name ('SEGMENT3')
and     ffv2.flex_value             = gcc.segment3
and     ffv2.flex_value_id          = ffvt2.flex_value_id
and     ffvt2.language              = 'US'
and     ffvs3.flex_value_set_id     = ffv3.flex_value_set_id
and     ffvs3.flex_value_set_name   =  XXASW_DISCO_UTIL_PKG.xxasw_get_gl_segment_fvs_name ('SEGMENT7') 
and     ffv3.flex_value             = gcc.segment7
and     ffv3.flex_value_id          = ffvt3.flex_value_id
and     ffvt3.language              = 'US'
and     gpd.period_name             = gjh.period_name
and     gpd.period_set_name         = gsb.period_set_name
and     gjh.set_of_books_id         = gsb.set_of_books_id
and     ((gjl.reference_9           <> 'TRADE_REC') 
     or (gjl.reference_9           is null))
and     (case when gjl.reference_6 = 'AP Invoices' 
then to_number(gjl.reference_2) else 0 end ) = api.invoice_id(+) 
and     gjl.reference_5              = api.invoice_num           (+) 
and     pvs.vendor_id               = pov.vendor_id     (+)
and     api.vendor_site_id          = pvs.vendor_site_id (+)
and     api.invoice_id                = aip.invoice_id      (+)          
and     aip.check_id                 = aca.check_id    (+) 
and   api.terms_id                    =       apt.term_id      (+) 
and     ((aca.status_lookup_code    = 'NEGOTIABLE') 
     or (aca.status_lookup_code    is null))
and     aip.reversal_inv_pmt_id(+)  is null 
and gcc.segment3  = 5221
and gjh.period_name  = 'JAN-16'
and gcc.segment2 between 592712 and 592712
and gcc.segment3 between 0000 and 9999;

ORA-01722:编号无效

尝试将字符串转换为数字时发生,但是由于某种原因该字符串无法转换。

看起来查询中的罪魁祸首如下:

and     (case when gjl.reference_6 = 'AP Invoices' 
then to_number(gjl.reference_2) else 0 end ) = api.invoice_id(+)

这意味着gl_je_lines.reference_2中存在数据问题,该列中有一个您不期望的字符串值。

我将通过检查select reference_2 from gl_je_lines列中的数据来解决此问题,并查看是否有任何突出之处显然会导致转换失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM