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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:30:58+00:00 2026-05-25T19:30:58+00:00

I have jsp page where user selects table name, column name and column value,

  • 0

I have jsp page where user selects table name, column name and column value, with those three condtion I want to delete all matching row from the database. Is there a way to pass table name, column name and column value in oracle to delete certain row from the table? Any example would help me.. Thank you

  • 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-25T19:30:58+00:00Added an answer on May 25, 2026 at 7:30 pm

    I’d worry about SQL Injection attacks as you are supplying the table and column names.
    You could create an Oracle function to remove the records required and test for certain conditions to be met before removing the row:

    CREATE OR REPLACE
    FUNCTION delete_record (
       p_table  IN VARCHAR2,
       p_column IN VARCHAR2,
       p_value  IN VARCHAR2
    )
    RETURN NUMBER
    AS
       v_table   user_tables.table_name%TYPE;
       v_columns user_tab_cols.column_name%TYPE;
    BEGIN
       -- Check table exists in DB
       SELECT table_name
         INTO v_table
         FROM user_tables
        WHERE table_name = UPPER(p_table);
    
       -- Check column exists in DB table
       SELECT column_name
         INTO v_colums
         FROM user_tab_cols
        WHERE table_name = UPPER(p_table)
          AND column_name = UPPER(p_column);
    
       EXECUTE IMMEDIATE 
          'DELETE FROM '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_table)||
          ' WHERE '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_column)||' = :col_value'
         USING p_value;
    
       RETURN SQL%ROWCOUNT;
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
            -- Either return -1 (error) or log an error etc.
            RETURN -1;
       WHEN others
       THEN
            <Your exception handling here>
    END delete_record;
    /
    

    This (or something like this) would check the table and column variables supplied exist in the database before then deleting the records and returning the number of records deleted.
    If there is a problem with the number deleted you can issue a rollback statement, if it is OK then you can issue a commit.

    Of course, if you want to supply a fully qualified table name (recommended) then you would use the DBMS_ASSERT.QUALIFIED_SQL_NAME function instead of the DBMS_ASSERT.SIMPLE_SQL_NAME function.

    Hope it helps…

    EDIT: In response to Jack’s question about adding date from and date to.

    If you add two new conditions that are passed in to the function as:

    CREATE OR REPLACE
    FUNCTION delete_record (
       p_table     IN VARCHAR2,
       p_column    IN VARCHAR2,
       p_value     IN VARCHAR2,
       p_date_from IN DATE,
       p_date_to   IN DATE
    )
    

    Then you’d need to expand the EXECUTE IMMEDIATE with:

    EXECUTE IMMEDIATE 
      'DELETE FROM '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_table)||
      ' WHERE '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_column)||' = :col_value'||
      ' AND date BETWEEN :date_from AND :date_to'
     USING p_value,
           p_date_from,
           p_date_to;
    

    N.B. This assumes your date column in the table is called “date”.
    I don’t have a SQL interface in front of me at the moment but this should be close enough to what you need to get it working.

    If you are passing the p_date_XXXX parameters in as VARCHAR2 and not DATE types then you’s need to “TO_DATE” the values before passing them into the dynamic SQL.

    e.g.

    EXECUTE IMMEDIATE 
      'DELETE FROM '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_table)||
      ' WHERE '||DBMS_ASSERT.SIMPLE_SQL_NAME(p_column)||' = :col_value'||
      ' AND date BETWEEN :date_from AND :date_to'
     USING p_value,
           TO_DATE(p_date_from, <date_format>),
           TO_DATE(p_date_to, <date_format>);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have put fckeditor in jsp page. I want to get the value whatever
I have a JSP page, which accepts user strings in more than 23 languages.
I have a functional JSP page that accepts URL parameters and updates a table
I have a .jsp page that the user loads directly. The request it with
I currently have a JSP page with a Form for the user to enter
I have HTML code in the jsp page that I want it to be
Hello i have a JSP page that displays records from animal table in my
I have a jsp page. if a user enters a certain text a ajax
I have a jsp page that is trying to reference some user defined classes.
If you want to show content in JSP page based on user's access to

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.