Prakash Posted March 22, 2006 Share Posted March 22, 2006 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 More sharing options...
Rachit Shah Posted March 22, 2006 Share Posted March 22, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now