Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to cut data from cell PL/SQL

i have a table with data and particular column where i need to cut data e.g.:

on unknown id:138702 client_type:0 contract:25369/NBX1/010322

so i need to cut only 138702

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

i tried to use SUBSTR but the thing is that besides the exaple above there is also:

on CALL3 id:138702 client_type:0 contract:25369/NBX1/010322

on SOPP6 id:138702 client_type:16 contract:25369/JMZXH3/010322

so results are kinda messy.

id appreciate if someone could help me with this.

>Solution :

If you’re looking for a first numeric value that follows the id: string, then this might be one option:

Sample data:

SQL> with test (col) as
  2    (select 'on unknown id:138702 client_type:0 contract:25369/NBX1/010322'  from dual union all
  3     select 'on CALL3 id:138702 client_type:0 contract:25369/NBX1/010322'    from dual union all
  4     select 'on SOPP6 id:138702 client_type:16 contract:25369/JMZXH3/010322' from dual
  5    )

Query begins here:

  6  select col,
  7    ltrim(regexp_substr(col, 'id:\d+'), 'id:') result
  8  from test;

COL                                                            RESULT
-------------------------------------------------------------- ----------
on unknown id:138702 client_type:0 contract:25369/NBX1/010322  138702
on CALL3 id:138702 client_type:0 contract:25369/NBX1/010322    138702
on SOPP6 id:138702 client_type:16 contract:25369/JMZXH3/010322 138702

SQL>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading