English 中文(简体)
难以执行 REGEXP_SUBSTR
原标题:Difficulty implementing REGEXP_SUBSTR

I m running SQL queries on Oracle 10g. I have two tables ( sample data provided below ). i m trying to extract some fields from Table t2 and update the empty columns in table t1. I m encountering the following error:

<>Restrong>ORA 01722: Invalid number ( Pointing to REGEXP_SUBSTR)

I understand this is because of non - numeric data ( like " NO code {...} " ) in my table, that I m trying to extract using the REGEXP_SUBSTR* Expression I was wondering if someone can suggest me some alternative implementations to help me "copy the entire string" instead of throwing an exception.

MERGE
INTO    缩略语
USING   directory_list t2
ON      (REGEXP_SUBSTR(codelist,  [^.]+ , 1) = t2.tcode)
WHEN MATCHED THEN
UPDATE
SET    t1.tcode = t2.tcode,
       t1.des   = t2.des

缩略语

Codelist          | T1.tcode   | T1.des
1111.1.803.12.X.Z 
1000.2.3232.145.M.P        
300.12.2982.45.X.Y         
NO code {...}  
1111.1.803.12.X.Z

directory_list t2
    tcode              |   DES
    1000           | powervalue100
    300                | powermax300
    20                 | powermin20
    NO code {...}      | maxvalue plus
    1000           | powervalue100

感谢

Novice

问题回答

您可在没有“编码清单”时使用化学文摘社检测。

MERGE
INTO    temptab t1
USING   directory_list t2
ON      (CASE WHEN INSTR(codelist, . ) = 0 THEN codelist
              ELSE REGEXP_SUBSTR(codelist,  [^.]+ , 1)
         END = t2.tcode)
WHEN MATCHED THEN
UPDATE
SET    t1.tcode = t2.tcode,
       t1.des   = t2.des




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签