Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6206713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:29:51+00:00 2026-05-24T05:29:51+00:00

I am attempting to write a generic trigger that can inspect each tuple that

  • 0

I am attempting to write a generic trigger that can inspect each tuple that is to be inserted into the database. In this inspection I want to replace characters that are of interest to me, such as the curly quotation mark (MS word) with the regular quotation mark (“). Since I do not want to have to write two replace calls for each column that stores data that the user supplies, nor do I want to do this in the application for a myriad of reasons. pseudocode as follows:

create or replace trigger changeChars
before insert  
on @tableName  
reference new as var
for each row  
Begin 
loop  
:var.@column  := replace(:var.@column,'”', '"');   
end 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:29:52+00:00Added an answer on May 24, 2026 at 5:29 am

    Why do you want to replace these characters? A lot of folks have problems with characters like the Microsoft curly quotes because those characters are not supported by their database character set which, by default, causes character set conversion to replace those characters with replacement characters like ‘?’. If that is the problem that you’re trying to solve, database code can’t help because the character set conversion happens at the network layer before the data even gets to the database. Potentially, you could use Oracle Locale Builder to build a custom locale for your client machines that would allow you to specify different replacement characters (i.e. double-quotes rather than Microsoft curly quotes).

    If your problem is not character set related, there is no way to create this sort of dynamic trigger. You could write a bit of dynamic SQL that created a trigger for every table that called REPLACE on every VARCHAR2 column in the table. Of course, you’d need to maintain the trigger every time an additional VARCHAR2 column was added (either by changing the trigger or re-running the PL/SQL block).

    Untested, and I’m sure the DDL generated isn’t correct, but you’d want something like

    DECLARE
      l_sql_stmt VARCHAR2(4000);
    BEGIN
      FOR tbl IN (SELECT * FROM user_tables)
      LOOP
        l_sql_stmt := 'CREATE OR REPLACE TRIGGER ' || tbl.table_name || '_changeChars ' ||
                      '  BEFORE INSERT ON ' || tbl.table_name ||
                      '  FOR EACH ROW ' ||
                      'BEGIN ';
        FOR col IN (SELECT * FROM user_tab_cols WHERE table_name = tbl.table_name)
        LOOP
          l_sql_stmt := l_sql_stmt ||
                        ' :new.' || col.column_name || 
                            ' := replace( :new.' || col.column_name || ',''"'', ''"''');';
        END LOOP;
        l_sql_stmt := l_sql_stmt || 
                        'END; ';
        dbms_output.put_line( 'SQL statement = ' || l_sql_stmt );
        EXECUTE IMMEDIATE l_sql_stmt;
      END LOOP;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write a search function for a database table that needs to
I've been attempting to write a Lisp macro that would perfom the equivalent of
I am attempting to write an application that uses libCurl to post soap requests
I'm attempting to write a Python C extension that reads packed binary data (it
I am attempting to write a one-line Perl script that will toggle a line
I am attempting to write a time management tool with wxPython that is ideally
I am attempting to write this type of program as stated in the question.
I'm attempting to write my own Log4Net Glimpse plugin (so I can interface with
I am attempting to write integration tests for a Grails service that does, among
I am attempting to write a interpreter that will turn a string like: vector(random(0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.