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 7985581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:35:52+00:00 2026-06-04T11:35:52+00:00

I am developing a SQL script in SQL Developer which will obfuscate personal data

  • 0

I am developing a SQL script in SQL Developer which will obfuscate personal data in a schema using Oracle SQL. The script looks into a table called “OBFUS_TABLE” which contains a list of which tables and columns need to be obfuscated and how. It then loops through the table, altering the data as it goes.

I have tested the actual loop and obfuscate process and it works fine, I have also successfully tested the beginning of the script up to just before the loop, which creates OBFUS_TABLE and inserts the values into it. The problem comes when it tries to do the two together, failing on a “table or view does not exist” error when it attempts to execute the loop. Snippet of code below:

    alter session set current_schema = SYSTEM;

    DECLARE
      t_count                   NUMBER;
      t_count2                  NUMBER;
      p_tname                   VARCHAR2(100);
      p_cname                   VARCHAR2(100);
      l_datatype                VARCHAR2(100);
    BEGIN

      SELECT COUNT(*) INTO t_count FROM all_tables  WHERE table_name = 'OBFUS_TABLE';
      SELECT COUNT(*) INTO t_count2 FROM all_tables  WHERE table_name = 'OBFUS_LOG';

      IF (t_count = 0)
        THEN
          EXECUTE immediate 'create table OBFUS_TABLE( TABLENAME VARCHAR2(200 BYTE), COLUMNNAME VARCHAR2(200 BYTE), DATA_TYPE VARCHAR2(20 BYTE), ACTIVE  VARCHAR(1 BYTE)  )';
      END IF;

      IF (t_count2 = 0)
        THEN
          EXECUTE immediate 'CREATE TABLE OBFUS_LOG (SRC_TABLENAME VARCHAR2(50 BYTE), SRC_TABLE_ROW_COUNT NUMBER, COPY_TABLENAME VARCHAR2(50 BYTE), COPY_TABLE_ROW_COUNT NUMBER, UPDATE_DATE TIMESTAMP(6) )';
      END IF;

    EXECUTE immediate 'INSERT INTO OBFUS_TABLE VALUES (''OB_MYTABLE1'',''SRNM'',''NAME'',''Y'')';
    COMMIT;


      FOR x IN (SELECT TABLENAME, COLUMNNAME, DATA_TYPE FROM OBFUS_TABLE WHERE ACTIVE='Y')
      LOOP
        p_tname    := upper(x.TABLENAME);  -- Table name
        p_cname    := upper(x.COLUMNNAME); -- Column name
        l_datatype := upper(x.DATA_TYPE);
        dbms_output.put_line('Started: '||TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'));
      END LOOP;

    END;

NB: There are actually around 30 insert statements in exactly the same format as the one above. I removed them since they would pad out this post too much, but I have manually checked every insert statement and they’re all correct.

I assume the problem is that SQL Developer does a “sanity check” on the code before running, and looks ahead to the loop and realises OBFUS_TABLE doesn’t exist, but fails to understand that by the time that piece of code is executed, OBFUS_TABLE will definitely exist.

Is there a way to get around this? I thought maybe a GOTO statement might help but no luck. I would rather keep the solution as one single script rather than two seperate ones, but if the only way around this is to do so then I could do that I suppose. Any help would be much appreciated.

  • 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-06-04T11:35:54+00:00Added an answer on June 4, 2026 at 11:35 am

    You will need to use dynamic SQL for the select like this:

    declare
        ...
        l_tname    varchar2(100);
        l_cname    varchar2(100);
        l_datatype varchar2(100);
        rc         sys_refcursor;
    begin
        ...
        open rc for 'SELECT TABLENAME, COLUMNNAME, DATA_TYPE  
                     FROM OBFUS_TABLE WHERE ACTIVE=''Y''';
        loop
            fetch rc into l_tname, l_cname, l_datatype;
            exit when rc%notfound;
            dbms_output.put_line('Started: '||TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'));
        end loop;
        close rc;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a report which outputs data in a SQL Table via an
Hey, I am currently developing a vbs script, which installs SQL server 2008 +
I'm developing an ASP.NET app (C#) that connect to SQL Server 2008 using ADO.NET
I've recently started developing my first serious application which uses a SQL database, and
I'm developing a web app and currently using sql server 2008 for it. But,
We are developing a web application using asp.net and sql server. We are required
I am developing a website using SQL Server Express on my development machine. My
I am developing an ASPX file to return all records from a SQL table.
I'm developing a timesheet application using SQL Server as my backend and I am
I am developing a contact manager application using SQL Server 2008 (service-based database) .

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.