REGEXP_REPLACE procedure

Hello

I have a few unprintable characters (no white space, the work of toppings in the procedure) I want to remove a table for many areas. not a single one.  Can someone help me get this procedure to run to update both fields.  Compiles the procedure but when I run it I get error messages.  The standard update works, but when I add the REGEXP_REPLACE (column_name, ' [^ [: cntrl :]-~]') is where the problem is I think.]])  Thanks for reading.

[code]

CREATE TABLE TBL_TEST

(

PK_TEST_ID NUMBER (12) NOT NULL,

VARCHAR2 (30 BYTE) LAST_NAME,

FIRST NAME VARCHAR2 (30 BYTE)

)

CREATE OR REPLACE PROCEDURE p_RegExpChars_TEST)

pa_table_name all_tab_columns.table_name%TYPE)--,

-pa_owner all_tab_columns.owner%TYPE)

IS

v_sql_text VARCHAR2 (4000);

BEGIN

FOR rec

(SELECT NOM_DE_COLONNE

From all_tab_columns

WHERE - owner = SUPERIOR (pa_owner)

- AND

table_name = SUPERIOR (pa_table_name)

AND data_type = 'VARCHAR2')

LOOP

v_sql_text: =.

"UPDATE".

--|| pa_owner

--|| '.'

|| pa_table_name

|| 'SET '.

|| recomm. COLUMN_NAME

|| ' = REPLACE (")

|| recomm. COLUMN_NAME

|| ' [^ [: cntrl:]-~]'

|| ')';

EXECUTE IMMEDIATE (v_sql_text);

COMMIT;

END LOOP;

END p_RegExpChars_TEST;

/

-When I run, I get error messages.

execute p_RegExpChars_TEST ('TBL_TEST');

-Error messages

ORA-00907: lack of right parenthesis

ORA-06512: at "P_REGEXPCHARS_TEST", line 28

ORA-06512: at line 1

-Test data

Of INSERT INTO TBL_TEST values (20040968, 'HARRIS', 'JOHN');

Of INSERT INTO TBL_TEST values (20040969, 'PAYNE', 'DIANNA');

Of INSERT INTO TBL_TEST values (20040970, 'CARTER', 'DARLENE');

Values inserted INTO TBL_TEST ("20040971, ' JARVIS","MICHELLE");

Of INSERT INTO TBL_TEST values (20040972, 'HAYES', 'SAMANTHA');

-It works but I want to perform the procedure for each column in the table which is VARCHAR2

-do not change the names of fields and run every time.

UPDATE TBL_TEST

SET last_name = REGEXP_REPLACE (LAST_NAME, ' [^ [: cntrl :]-~]')]])

WHERE REGEXP_LIKE (LAST_NAME, ' [^ [: cntrl :]-~]')]])

[/ code]

Just add DBMS_OUTPUT. Put_line (v_sql_text); before EXECUTE IMMEDIATE and you will see what SQL statement is. And there is no need to update a column at a time:

CREATE OR REPLACE

PROCEDURE p_RegExpChars_TEST)

pa_table_name all_tab_columns.table_name%TYPE,

pa_owner all_tab_columns.owner%TYPE

)

IS

v_sql_text VARCHAR2 (4000);

BEGIN

v_sql_text: = "UPDATE". pa_owner | '.' || pa_table_name | "TOGETHER";

FOR (IN) rec

SELECT column_name

From all_tab_columns

Owner WHERE = UPPER (pa_owner)

AND table_name = UPPER (pa_table_name)

AND data_type = "VARCHAR2".

) LOOP

v_sql_text: = v_sql_text | recomm. COLUMN_NAME |

' = REPLACE ("|") Rec. COLUMN_NAME | ',''[^[:cntrl:] -~]''),';

END LOOP;

DBMS_OUTPUT. Put_line (RTrim (v_sql_text, ','));

RUN IMMEDIATELY RTRIM (v_sql_text, ',');

END p_RegExpChars_TEST;

/

Created procedure.

SQL > set serveroutput on
SQL > exec p_RegExpChars_TEST ('tbl_test', 'scott');
UPDATE scott.tbl_test SET LAST_NAME = REPLACE (LAST_NAME,'[^ [: cntrl:]-~]'), name = REPLACE (FIRST_NAME,'[^ [: cntrl :]-~]')]])

PL/SQL procedure successfully completed.

SQL >

SY.

Tags: Database

Similar Questions

  • Pass dynamic strings to procedure

    Oracle 11g r2 and Java

    Oracle procedure:

    procedure sp_get_account)

    p_rc on sys_refcursor,

    p_state varchar2

    )

    Open the p_rc for

    Select *.

    of user_table

    where to report in (p_state);

    Example of HARD CODE: select * from user_table where State in ("NY", "FL", "MY");

    Now, I want to dynamically pass the string on the java side: call.setString (2, stateStr);

    I am now tring stateStr = "'NY', 'FL', 'MY" ";    Does not work.

    How the stateStr should be built?

    Thank you

    Scott

    Or you can try this:

    (Sp_get_account) CREATE or REPLACE procedure

    p_rc on sys_refcursor,

    p_state varchar2

    )

    as

    Start

    Open p_rc for ' select * from user_table where State in ('|) REGEXP_REPLACE (p_state,'([A-Z]+) ', "'\1"') |') ' ;

    end;

    /

    Pass p_state as in format NY, FL, MY:

    EXEC sp_get_account(:p_result,'NY,FL,MA');

    Take care of sql injection.

  • REGEXP_REPLACE how to loop through the occurrences of a text string variables

    Hello

    I use a 11.g Oracle procedure. I found an example of REGEXP_REPLACE with only two arguments (input and model) and created a procedure based on this example. The Replace function works, but not optimally. I try to use REGEXP_REPLACE to loop on a variable number of occurrences of a text string in a local variable of CLOB.  The string occurs after the text base64 (base64 comma) and before the text "/ > (double quote space oblique superior - only)."  I can do replace it work for a single occurrence, but I can't do it properly in a loop.  These embedded strings include images that were inserted in a rich Apex text field.  This is a rich text field is assigned to the CLOB p_html.

    Declare p_html clob;
      l_image_clob clob;
      l_image_count number;
    Begin
    p_html := '<p>Some header text base64,one start here and then this is the end one" /></p><p>Some header text base64,two start here and then this is the end two" /></p>';
    l_image_count := REGEXP_COUNT(p_html, 'base64', 1, 'i');
    If l_image_count > 0 Then
      For i In 1..l_image_count Loop
      l_image_clob := REGEXP_REPLACE(p_html, '(.*base64,)|(" />.*)');
      dbms_output.put_line(l_image_clob);
      -- code to process each occurrence individually.
      End Loop;
    End If;
    End;

    What I would like to see results of the data are:

    tenure here and that's the end

    two beginning here and that's the end of two

    The results I get are:

    two beginning here and that's the end of two

    two beginning here and that's the end of two

    Thanks a lot for watching this.

    Hello

    From Oracle 11.1, REGEXP_SUBSTR is better than REGEXP_REPLACE for this sort of thing.

    What produces the output you asked for:

    Declare

    CLOB p_html;

    CLOB l_image_clob;

    number of l_image_count;

    Begin

    p_html: = '

    ' Some header text base64, start here and then it's the end "/ >

    Some header text base64, two start here and then it's the end of two"/ >

    ';

    l_image_count: = REGEXP_COUNT (p_html, 'base64', 1, 'i');

    If l_image_count > 0 Then

    For i In 1... l_image_count loop

    l_image_clob: = REGEXP_SUBSTR (p_html )

    , "base64,(.*?)" / > "

    1

    , I - letter i (loop variable), not number 1

    , 'i'

    1

    );

    dbms_output.put_line (l_image_clob);

    -code to treat each case individually.

    End loop;

    End If;

    End;

    /

    The 4th argument to REGEXP_SUBSTR specifies where desired appearance (starting with 1).

    The 6th argument is a backreference. 1 means you want to return all that match the expression starting with the 1st '('. gauche)

  • How to include a message of output in a procedure

    Hi guys,.

    I have the procedure, where I need to include a query of exit message, please help me.

    The procedure is:

    create or replace procedure insert_data_employees (p_name in varchar2, p_acess_level in numbers) as

    v_Name varchar2 (100);

    number of v_uname;

    Begin

    If p_name is not null then

    BEGIN

    Select COUNT (1) in the v_uname of employees

    where

    Upper (p_name) = upper (name);

    Exception

    WHEN NO_DATA_FOUND THEN

    v_uname: = 0;

    END;

    End if;

    INSERT INTO employees

    (name, rol_id, emp_number, creation_date) VALUES

    (EMPLOYEES_DATA_SEQ,

    regexp_replace(p_name,'(.*)@.*','\1'),

    p_acess_level,

    SYSDATE

    );

    COMMIT;

    end insert_data_employees;

    If I write the query in the form:

    create or replace procedure insert_data_employees (p_name in varchar2, p_acess_level in numbers, some o_return_code number)

    How to include under conditions in the procedure? How can I represent the successful and failed integration in a query?

    a. If successful insertion, then o_return_code = 0

    b. If insertion failed so o_return_code = - 1

    Please help its urgent...

    You can use the cursor SQL SQL and FOUND for this % NOTFOUND attribute.

    create or replace procedure insert_data_employees(p_name in varchar2,p_acess_level in number) as
    v_name varchar2(100);
    v_uname number;
    Begin
    if p_name is not null then
    BEGIN
    select COUNT(1) into v_uname from employees
    where
    upper(p_name) = upper(name);
    Exception
    WHEN NO_DATA_FOUND THEN
    v_uname:=0;
    END;
    End if;
    INSERT INTO employees
    (emp_number, name,  rol_id, creation_date) VALUES
    ( EMPLOYEES_DATA_SEQ,
      regexp_replace(p_name,'(.*)@.*','\1'),
      p_acess_level,
      SYSDATE
      );
      IF SQL%NOTFOUND THEN
      o_return_code := 1;
        dbms_output.put_line('Records inserted');
      ELSIF SQL%FOUND THEN
        o_return_code := 0;
        dbms_output.put_line('Nothing inserted.');
    COMMIT;
    end insert_data_employees;
    

    I have not tested the code in my DB.

  • Procedure to extract several substring of a string

    Hi all

    I was wondering how can I extract substring of a string. I would write a procedure to update data in the table and by mistake if the string doesnot match the pattern.

    Example of a string: [1594374: "SFD"] [1597251: 'TTT'] [1601085: 'SSS']

    Using this channel, I would update as table 'test' which has columns ID and TYPE.

    Updates of the statements will be:

    UPDATE TEST SET type is 'DFS' where id = 1594374;.
    UPDATE TEST SET type is 'TTT' where id = 1597251;.
    UPDATE TEST SET type is 'TTT' where id = 1597251;.

    I would be grateful if someone could help me with this.

    Thank you
    SQL> create table test(
      2                    id   number,
      3                    type varchar2(10)
      4                   )
      5  /
    
    Table created.
    
    SQL> insert into test(id) values(1594374)
      2  /
    
    1 row created.
    
    SQL> insert into test(id) values(1597251)
      2  /
    
    1 row created.
    
    SQL> insert into test(id) values(1601085)
      2  /
    
    1 row created.
    
    SQL> select * from test
      2  /
    
            ID TYPE
    ---------- ----------
       1594374
       1597251
       1601085
    
    SQL> merge
      2    into  test a
      3    using (
      4           select  ltrim(regexp_substr('[1594374:''DYC''][1597251:''TTT''][1601085:''SSS'']','\[(\d+)',1,level),'[') id,
      5                   ltrim(regexp_substr('[1594374:''DYC''][1597251:''TTT''][1601085:''SSS'']',':''[^'']+',1,level),':''') type
      6             from  dual
      7             connect by level <= length(regexp_replace('[1594374:''DYC''][1597251:''TTT''][1601085:''SSS'']','[^[]'))
      8          ) b
      9    on (a.id = b.id)
     10    when matched
     11      then
     12        update set a.type = b.type
     13  /
    
    3 rows merged.
    
    SQL> select * from test
      2  /
    
            ID TYPE
    ---------- ----------
       1594374 DYC
       1597251 TTT
       1601085 SSS
    
    SQL> 
    

    SY.

  • I can not pair my Apple Watch with my iphone 6 s so true the automatic procedure freezes the app on my iphone. If manually matching the 6 digit code will appear on the Apple Watch. I have the current ios 10.0.1

    I can not pair my Apple Watch with my iphone 6 s so true the automatic procedure freezes the app on my iphone. If manually matching the 6 digit code will appear on the Apple Watch. I have the current ios 10.0.1

    does anyone have a solution to this?

    Hello

    The following steps can help (try again after each):

    • On your iPhone, in the application of the watch, go to: Watch My > general > use > software update - remove any file update, if one is displayed.
    • Delete all profiles beta (on your iPhone and/or the watch), then restart both devices (this applies only if you have already participated in a program of Apple Beta software).
  • This procedure is a diagnostic test.

    The question how to delete this file EtreCheck found:

    ~/Library/LaunchAgents/com. [email protected]-SharedServices.Agent.plist

    /System/Library/frameworks/CoreServices.framework/frameworks/OSServices.framewo rk/Versions/A/support/CSConfigDotMacCert - /Users/GeoffreyMcCabe/Library/Logs/[email protected]- SharedServices.log u l @me.com SharedServices s t

    Search me has led to an older discussion-"this procedure is a diagnostic test"...

    I ran the test recommended in the Terminal, but this window says there are invalid characters...

    Are there any alternatives to the procedure or updates?

    Thank you...

    Open your library folder of the user by holding down the Option key and selecting the library from the menu go to the Finder.

    Find the LaunchAgents folder and open it.

    Search for the file with the same name as on the Etrecheck and delete it.

  • My googlemail is blocked due to a forgotten password, but google for the recovery procedure continues to send me round in circles.

    My frozen Googlemail account a few days ago, and I had to use the procedure of recovery to thaw, which included a series of new passwords, provided by Google, which I was told that I would not need to memorize or note down. After a few hours of work successfully, the program froze again and so I am unable to receive or forward all e-mail messages. Google asks me to use the procedure "forgotten password", but I don't know what password is the system, and I continue to be sent in a circle to the same pages.
    I would be grateful for any positive suggestions and thank you in advance.

    Hi frederickwilliams, I'm sorry, but I don't think that we have no way to help you with a recovery procedure for a service of third party, unfortunately...

  • How to fix the error, "the procedure entry point PK11_PubDerive could not be found in the dynamic link library nss3.dll

    I use windows 7 and Firefox 39.0. Recently, when I open Firefox it gives this error, 'the entrance of procedure point PK11_PubDerive could not be located in the dynamic link library nss3.dll'. I click on the OK button, and then Firefox load without any other side effects. But this becomes quite annoying and I would not get an error message to me. I tried to uninstall Firefox (all the same when I search for it, nothing comes up) and re-install. But the message is still there. I'm lost for what to do to get rid of him. Any help would be great!

    Thank you!

    BlindingFog said

    I use windows 7 and Firefox 39.0. Recently, when I open Firefox it gives this error, 'the entrance of procedure point PK11_PubDerive could not be located in the dynamic link library nss3.dll'. I click on the OK button, and then Firefox load without any other side effects. But this becomes quite annoying and I would not get an error message to me. I tried to uninstall Firefox (all the same when I search for it, nothing comes up) and re-install. But the message is still there. I'm lost for what to do to get rid of him. Any help would be great!

    Thank you!

    I thought about it. I had Cyrstal Reports XI on my machine and when I uninstalled it the error disappeared.

  • Purchase and installation of Logic Pro procedure?

    Hi, am about to buy Logic Pro X.

    What is the procedure please? I'm new on this!

    I want it on my main computer and my laptop also.

    "My main computer: Macbook Pro15" 2015, 2.8 ghz. 1.7 image, 16gbRAM, memory Flash 512 El Capitan 10.11.3

    Laptop: Macbook Air 13 ", 2015, 2, dual-core 2 GHz 1.7, 8 GB of RAM, 256 El capitan 10.11.3 Flash memory

    Thanks in advance

    Hello

    1) connect to the AppStore with your AppleID

    (2) buy Logic Pro X

    (3) download the main application

    (4) when you run the first LPX he will insist on downloading some "core".

    (5) within the LPX, go to the menu of Logic Pro X > Sound Library. ' Either ' Download All Available sounds ' or 'Open sound libraries Manager' to manually select which is downloaded (about 50 GB total) and installed.

    If it is possible to enter the installation programs before be unpacked, it is probably easier to simply repeat the process from step 3 on your second Mac.

    TDC

  • What is the procedure for upgrading Thunderbird ESR 17.0.7 at 31.6 on Mac OSX 10.10.2?

    What is the procedure for upgrading from Thunderbird ESR 17.0.7 at 31.6 (last public version) on Mac OSX 10.10.2?

    Is it as simple as install new version and then run to see all local folders and my email and its folders from IMAP to my company as before the upgrade?

    Thank you

    Create a full backup of your Thunderbird profiles folder.
    Uninstall the old version of ESR.
    Download the latest version from https://www.mozilla.org/en-US/thunderbird/all.html and install it.

  • Do ypu have a procedure to move the Thunderbird addresses &amp; saved emails to Windows 8.1?

    I would like to know how can I migrate emails stored in folders and email addresses of Thunderbird Windows XP to another computer running Windows 8.1. If someone can provide a URL describing the procedure that would help me. I can't find it in this section of help.

    http://KB.mozillazine.org/Move_to_a_new_PC

  • The help procedure to remove a bookmark does not work.

    I follow the procedure, click on the bookmark you want to delete. Click on bookmarks and it's still there.

    grayghost2,
    Thank you very much, who fixed it!
    Best regards, DKPL

  • the procedure entry point NSSUTIL_EscapeSize could not be located in the dynamic link library nssutil3.dll

    Windows XP with Firefox 18.0.1 does not open when upgraded to the latest version.
    Error messages have been
    (1) the procedure entry that point pr_setcurrentthreadname could not be located in the dynamic library (2) ndpr4.dll the procedure entry point NSSUTIL_EscapeSize could not be located in the dynamic links (3) library nssutil3.dll was not able to load XPCOM

    A ran malware & anti-virus software then deleted Firefox via Control Panel, then residual file file C:\Documents & Folders\ApplicationData\Mozilla Director and program folder.
    Local & installed products ndpr4.dl and nssutil3.dll - fresh reinstall firefox several times - he got rid of the error message 1 but not 2 or 3 always cannot open Firefox.
    All solutions?

    I have this problem and I use Zone Alarm Extreme Security with Force active field. I found that by turning off the virtual Cache in Zone Alarm that this problem has disappeared and has been able to restart firefox.

    Here is a post I found that addresses the issue in some way. http://KB.mozillazine.org/Browser_will_not_start_up#Firefox_does_not_start_after_updating_with_ZoneAlarm_ForceField_enabled

  • NO RESPONSE TO REPEATED, NORMAL SHUT DOWN PROCEDURE: HAVE TO SWITH IT.

    FOR TWO DAYS NOW, AT THE END OF THE DAY, MY PC NOT STOP WHEN REPEATEDLY USING THE NORMAL PROCEDURE. I HAVE TO THROW THE SWITCH ON MY TOWER TO THE TAP.
    LATER COMMISSIONING IS NORMAL.

    See:

    Use ' Firefox/file > output "(Mac: ' Firefox > quit smoking";) Linux: "file > exit ') to close Firefox if you're doing that by clicking on the X close in the title bar.

Maybe you are looking for