Jump to content

Oracle


Prakash

Recommended Posts

Hi,I'm Prakash. I'm interested in Database Programming.I'm posting one problem, please tell me the solution.I've a table in Oracle with 10 Columns. If some of the columns are having some null values, How can I retreive the Column names using either SQL or PL/SQL?Please send me the replies.Thanking you all.Bye.

Link to comment
Share on other sites

Check this procedure. with PL/SQL its possible, with SQL i think its next to impossible. :)

CREATE OR REPLACE PROCEDURE pilot_test_r ISCURSOR cur is SELECT COLUMN_NAME FROM USER_TAB_COLS WHERE TABLE_NAME = 'SRM_RESOURCES';x integer:=-99;BEGINfor cur_val in curloop    execute immediate 'select count(*) from srm_resources where ' || cur_val.column_name || ' is null' into x;    if (x >0)    then        dbms_output.put_line(cur_val.column_name);    end if;end loop;END pilot_test_r;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...