Link to home
Start Free TrialLog in
Avatar of RUA Volunteer2?
RUA Volunteer2?Flag for United States of America

asked on

Rules for embedding code in SQL in just the right place. PL/SQL Developer for Oracle.

Based on the question and response in the LINK below. I had an Expert be so kind as to help me with what I need. So I have been working the last 2 hours on how to embed this inside of the existing code in order to get the desired result seen here.
Blob fields and how to manage them when they throw an error.
I need to embed the code that I think identifies the type of data (DATA_TYPE) to search for. My concern is where do I embed it? IF there are rules somewhere or "best practices" on the when and where rules on how to embed code so that it runs in the right order without throwing error messages. If anyone knows I am all ears...?

[b][i]
/*IF THIS IS THE CORRECT CONTENT I NEED TO INSERT .... NOT 100% SURE?*/
CASE 
WHEN main.DATA_TYPE = 'VARCHAR2' 
	AND val.IsValueNumeric = 0 
		THEN main.COLUMN_NAME || ' = ''' || val.SearchValue || ''''
               
WHEN main.DATA_TYPE = 'NUMBER' 
	AND val.IsValueNumeric = 1 
		THEN main.COLUMN_NAME || ' = ' || val.SearchValue  
        ELSE ''
END

/* I think this statement has to go in the WHERE clause in the Second Section.
AND   main.DATA_TYPE IN ( 'VARCHAR2','NUMBER' )[/i][/b]

*/ Information above needs to go into this Second Section of code below*/

Select * From JAS.JOBS  ;
Select * From JAS.JOB_BLOCKS  ;
Select * From JAS.JOB_CONTACTS  ;
Select * From JAS.JOB_CONTACT_DIVISIONS ;
Select * From JAS.JOB_CPR_CLASSES ;
Select * From JAS.JOB_DETAILS ;
Select * From JAS.JOB_DETAIL_REC_TYPES  ;
Select * From JAS.JOB_EXPENSES  ;
Select * From JAS.JOB_GROUPS  ;
Select * From JAS.JOB_ITEM_PRICING  ;
Select * From JAS.JOB_LABOUR  ;
Select * From JAS.JOB_OVR_PROFILES  ;
Select * From JAS.JOB_REPORTING_CLASSES ;
Select * From JAS.JOB_REP_CLASSES ;
Select * From JAS.JOB_REQUESTS  ;
Select * From JAS.JOB_REQUEST_DETAILS ;
Select * From JAS.JOB_REQUEST_DOCUMENTS ;
Select * From JAS.JOB_REQUEST_REC_TYPES ;
Select * From JAS.JOB_REQUEST_SETUP ;
Select * From JAS.JOB_SECTIONS  ;
Select * From JAS.JOB_STATUSES  ;
Select * From JAS.JOB_SUBCONTRACTS  ;
Select * From JAS.JOB_SUBCON_DETAILS  ;
Select * From JAS.JOB_SUPPLIERS ;
Select * From JAS.J_ITEMS ;
Select * From JAS.J_ITEM_GROUPS ;
Select * From JAS.J_ITEM_LABOUR ;
Select * From JAS.J_MAT_EPA ;
Select * From JAS.J_MAT_EPA_LOGS  ;
Select * From JAS.J_MAT_LISTS ;
Select * From JAS.J_MAT_LIST_DETAILS  ;
Select * From JAS.J_OVERHEAD_CHART  ;
Select * From JAS.LABOR_LOGS  ;
Select * From JAS.LABOR_LOG_ERRORS  ;
Select * From JAS.LABOR_LOG_FILE_STYLES ;
Select * From JAS.LABOR_LOG_MAPPINGS  ;
Select * From JAS.LABOR_TIME_LOGS ;
Select * From JAS.LABOR_TIME_LOG_MOBILE_HISTORY ;
Select * From JAS.LABOR_TIME_LOG_SETUP  ;
Select * From JAS.LABOR_TIME_LOG_STAGE_DATA ;
Select * From JAS.LABOUR_ADDITIONAL_CODES ;
Select * From JAS.LABOUR_ANALYSIS ;
Select * From JAS.LABOUR_CODES  ;
Select * From JAS.LABOUR_CODES_PRV_SETUP  ;
Select * From JAS.LABOUR_COMPARISONS  ;
Select * From JAS.LABOUR_RATES  ;
Select * From JAS.LAB_GROUPS  ;


select table_name,column_name from (
  select table_name,
    column_name,
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) count
  from All_tab_cols
  where owner ='JAS' and table_name like '%' 
  order by table_name, column_name
)
where count=1
/

Open in new window

SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RUA Volunteer2?

ASKER

I am so grateful you guys are here and feel bad I am causing so much to be written here. When I have a problem I google it. Like I think a lot do. My process is when I see the error that I get here:
User generated imageSo with that, I work through the ORA-Errors and try to find each one defined then backtrack the problems looking for a solution. I looked for "data_type" assuming that it was a function that is part of SQL Language? Or that it could just be a variable.
I found "data_type" in a couple of places. I am just not sure if it is a function as I assume "table_name and Column_Name" are?
So is "data_type" a:
1. unique value like "1234567.." or "Howdy"......."Which initially I did NOT think that was what it was."
2. A function that identifies to code there is a data_type being either "number" or "varchar"......I thought this is more likely what it was?
3. A variable identifyer of some kind that users enter that performs some task?......I was just guessing at this point?

These are the places I get stuck and I know experience and time will help me. I am so sorry you guys are having to deal with me. You have no idea how grateful I am that is for sure.

Initially I thought that slightwv's idea of putting the code in as seen below was the simple fix. I understood exactly what you said and I did it. Then started experimenting to see what I did that was out of place. Then started to think maybe "data_type" as in the "main.data_type" code mentioned in the original question above. Then I saw Sujith's comment was a complimentary statement of you (meaning me) needed the extra Case When Extract part and that slightwv may have assumed I knew how to do?

On another note. I thought maybe I need to shorten the list and narrow down the specific table and see if I can just remove them from the search list. I think that is another solution. I may have to just manually look through those with a Select Distinct query and try to find any records I need in that table that way?

Again So sorry my terms, my knowledge, my way of doing things is probably driving you guys insane. I apologize for any suffering I may cause. It is not intentional I assure you.

Select * From JAS.ITEMS ;
Select * From JAS.ITEM_CHARGES  ;
Select * From JAS.ITEM_CHARGE_SETUP ;
Select * From JAS.ITEM_COMMISSIONS  ;
Select * From JAS.ITEM_COSTS  ;
Select * From JAS.ITEM_DIMENSIONS ;
Select * From JAS.ITEM_DIMENSION_PACKAGES ;
Select * From JAS.ITEM_LABOUR_GROUPS  ;
Select * From JAS.ITEM_LAB_RATES_CODES_FORMULAS ;
Select * From JAS.ITEM_MANUFACTURER_DESCRIPTIONS  ;
Select * From JAS.ITEM_TYPES  ;
Select * From JAS.ITEM_TYPE_FORMULAS  ;
Select * From JAS.ITEM_TYPE_GROUPS  ;
Select * From JAS.ITEM_TYPE_LABOUR_PERCENT  ;
Select * From JAS.ITEM_TYPE_PROPERTIES  ;
Select * From JAS.ITEM_USAGE  ;
Select * From JAS.I_CATEGORIES  ;
Select * From JAS.I_DEPTHS  ;
Select * From JAS.I_DIMENSIONS  ;
Select * From JAS.I_GAUGES  ;
Select * From JAS.I_LENGTHS ;
Select * From JAS.I_LINKED_ITEMS  ;
Select * From JAS.I_PROPERTIES  ;
Select * From JAS.I_RATES ;
Select * From JAS.I_R_VALUES  ;
Select * From JAS.I_TYPES ;
Select * From JAS.I_TYPE_GROUPS ;
Select * From JAS.I_TYPE_PROPERTIES ;
Select * From JAS.I_WIDTHS  ;
Select * From JAS.JAVA$CLASS$MD5$TABLE  ;
Select * From JAS.JD_BUDGETS  ;
Select * From JAS.JD_DETAIL_GROUPS  ;
Select * From JAS.JD_PRODUCTION_DETAILS ;
Select * From JAS.JD_STATUS_DETAILS ;
Select * From JAS.JD_STATUS_RESOURCES ;
Select * From JAS.JOBS  ;
Select * From JAS.JOB_BLOCKS  ;
Select * From JAS.JOB_CONTACTS  ;
Select * From JAS.JOB_CONTACT_DIVISIONS ;
Select * From JAS.JOB_CPR_CLASSES ;
Select * From JAS.JOB_DETAILS ;
Select * From JAS.JOB_DETAIL_REC_TYPES  ;
Select * From JAS.JOB_EXPENSES  ;
Select * From JAS.JOB_GROUPS  ;
Select * From JAS.JOB_ITEM_PRICING  ;
Select * From JAS.JOB_LABOUR  ;
Select * From JAS.JOB_OVR_PROFILES  ;
Select * From JAS.JOB_REPORTING_CLASSES ;
Select * From JAS.JOB_REP_CLASSES ;
Select * From JAS.JOB_REQUESTS  ;
Select * From JAS.JOB_REQUEST_DETAILS ;
Select * From JAS.JOB_REQUEST_DOCUMENTS ;
Select * From JAS.JOB_REQUEST_REC_TYPES ;
Select * From JAS.JOB_REQUEST_SETUP ;
Select * From JAS.JOB_SECTIONS  ;
Select * From JAS.JOB_STATUSES  ;
Select * From JAS.JOB_SUBCONTRACTS  ;
Select * From JAS.JOB_SUBCON_DETAILS  ;
Select * From JAS.JOB_SUPPLIERS ;
Select * From JAS.J_ITEMS ;
Select * From JAS.J_ITEM_GROUPS ;
Select * From JAS.J_ITEM_LABOUR ;
Select * From JAS.J_MAT_EPA ;
Select * From JAS.J_MAT_EPA_LOGS  ;
Select * From JAS.J_MAT_LISTS ;
Select * From JAS.J_MAT_LIST_DETAILS  ;
Select * From JAS.J_OVERHEAD_CHART  ;
Select * From JAS.LABOR_LOGS  ;
Select * From JAS.LABOR_LOG_ERRORS  ;
Select * From JAS.LABOR_LOG_FILE_STYLES ;
Select * From JAS.LABOR_LOG_MAPPINGS  ;
Select * From JAS.LABOR_TIME_LOGS ;
Select * From JAS.LABOR_TIME_LOG_MOBILE_HISTORY ;
Select * From JAS.LABOR_TIME_LOG_SETUP  ;
Select * From JAS.LABOR_TIME_LOG_STAGE_DATA ;
Select * From JAS.LABOUR_ADDITIONAL_CODES ;
Select * From JAS.LABOUR_ANALYSIS ;
Select * From JAS.LABOUR_CODES  ;
Select * From JAS.LABOUR_CODES_PRV_SETUP  ;
Select * From JAS.LABOUR_COMPARISONS  ;
Select * From JAS.LABOUR_RATES  ;
Select * From JAS.LAB_GROUPS  ;


select table_name,column_name from (
  select table_name,
    column_name,
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) count
  from All_tab_cols
  where owner ='JAS' 
  and table_name like '%'
  AND data_type IN ( 'VARCHAR2','NUMBER' )
  order by table_name, column_name
)
where count=1
/

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Again, this does nothing:   and table_name like '%'   I had taken it out and put it back in I had tried it many ways

From your most recent post:  Is the SQL you posted working, not working, causing your keyboard to catch fire?
This question... It works with the JOB tables not any above or below and finds records that match. When I open

>> manually look through those with a Select Distinct query and try to find any records I need in that table that way?

Why?  DISTINCT is normally BAD because it is an easy way to attempt to fix bad SQL. With Distinct I can find a possible column out of 200 and select distinct records to see if any of the results match my search term.

>> I looked for "data_type" assuming that it was a function that is part of SQL Language? Or that it could just be a variable.

It is a column in a view.  Nothing more. I have to keep understanding the terms. That was why I posted the question on Terms in SQL so I can be more clear and not be so confusing. Yours are solid because of your expertise.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is what I know with certainty. The Sub_Contract Table has 'Insulation' & 'Fire Proofing' in the Description Table. I used the small query just to make a small illustration.
User generated image
If I use the following changes to the code. I get these results. One works the rest do not.
User generated image
User generated image
User generated image
User generated image
User generated image
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get it but cannot see a mistake as I got the MULTIPLE ERROR Image above. 2nd Image up. ORA-19202,00932,06512, at line 1
If you can scroll to the bottom. I cannot see any mistakes myself. Wondering if it is a data issue it is hitting or?

Select * From JAS.ITEMS ;
Select * From JAS.ITEM_CHARGES  ;
Select * From JAS.ITEM_CHARGE_SETUP ;
Select * From JAS.ITEM_COMMISSIONS  ;
Select * From JAS.ITEM_COSTS  ;
Select * From JAS.ITEM_DIMENSIONS ;
Select * From JAS.ITEM_DIMENSION_PACKAGES ;
Select * From JAS.ITEM_LABOUR_GROUPS  ;
Select * From JAS.ITEM_LAB_RATES_CODES_FORMULAS ;
Select * From JAS.ITEM_MANUFACTURER_DESCRIPTIONS  ;
Select * From JAS.ITEM_TYPES  ;
Select * From JAS.ITEM_TYPE_FORMULAS  ;
Select * From JAS.ITEM_TYPE_GROUPS  ;
Select * From JAS.ITEM_TYPE_LABOUR_PERCENT  ;
Select * From JAS.ITEM_TYPE_PROPERTIES  ;
Select * From JAS.ITEM_USAGE  ;
Select * From JAS.I_CATEGORIES  ;
Select * From JAS.I_DEPTHS  ;
Select * From JAS.I_DIMENSIONS  ;
Select * From JAS.I_GAUGES  ;
Select * From JAS.I_LENGTHS ;
Select * From JAS.I_LINKED_ITEMS  ;
Select * From JAS.I_PROPERTIES  ;
Select * From JAS.I_RATES ;
Select * From JAS.I_R_VALUES  ;
Select * From JAS.I_TYPES ;
Select * From JAS.I_TYPE_GROUPS ;
Select * From JAS.I_TYPE_PROPERTIES ;
Select * From JAS.I_WIDTHS  ;
Select * From JAS.JAVA$CLASS$MD5$TABLE  ;
Select * From JAS.JD_BUDGETS  ;
Select * From JAS.JD_DETAIL_GROUPS  ;
Select * From JAS.JD_PRODUCTION_DETAILS ;
Select * From JAS.JD_STATUS_DETAILS ;
Select * From JAS.JD_STATUS_RESOURCES ;
Select * From JAS.JOBS  ;
Select * From JAS.JOB_BLOCKS  ;
Select * From JAS.JOB_CONTACTS  ;
Select * From JAS.JOB_CONTACT_DIVISIONS ;
Select * From JAS.JOB_CPR_CLASSES ;
Select * From JAS.JOB_DETAILS ;
Select * From JAS.JOB_DETAIL_REC_TYPES  ;
Select * From JAS.JOB_EXPENSES  ;
Select * From JAS.JOB_GROUPS  ;
Select * From JAS.JOB_ITEM_PRICING  ;
Select * From JAS.JOB_LABOUR  ;
Select * From JAS.JOB_OVR_PROFILES  ;
Select * From JAS.JOB_REPORTING_CLASSES ;
Select * From JAS.JOB_REP_CLASSES ;
Select * From JAS.JOB_REQUESTS  ;
Select * From JAS.JOB_REQUEST_DETAILS ;
Select * From JAS.JOB_REQUEST_DOCUMENTS ;
Select * From JAS.JOB_REQUEST_REC_TYPES ;
Select * From JAS.JOB_REQUEST_SETUP ;
Select * From JAS.JOB_SECTIONS  ;
Select * From JAS.JOB_STATUSES  ;
Select * From JAS.JOB_SUBCONTRACTS  ;
Select * From JAS.JOB_SUBCON_DETAILS  ;
Select * From JAS.JOB_SUPPLIERS ;
Select * From JAS.J_ITEMS ;
Select * From JAS.J_ITEM_GROUPS ;
Select * From JAS.J_ITEM_LABOUR ;
Select * From JAS.J_MAT_EPA ;
Select * From JAS.J_MAT_EPA_LOGS  ;
Select * From JAS.J_MAT_LISTS ;
Select * From JAS.J_MAT_LIST_DETAILS  ;
Select * From JAS.J_OVERHEAD_CHART  ;
Select * From JAS.LABOR_LOGS  ;
Select * From JAS.LABOR_LOG_ERRORS  ;
Select * From JAS.LABOR_LOG_FILE_STYLES ;
Select * From JAS.LABOR_LOG_MAPPINGS  ;
Select * From JAS.LABOR_TIME_LOGS ;
Select * From JAS.LABOR_TIME_LOG_MOBILE_HISTORY ;
Select * From JAS.LABOR_TIME_LOG_SETUP  ;
Select * From JAS.LABOR_TIME_LOG_STAGE_DATA ;
Select * From JAS.LABOUR_ADDITIONAL_CODES ;
Select * From JAS.LABOUR_ANALYSIS ;
Select * From JAS.LABOUR_CODES  ;
Select * From JAS.LABOUR_CODES_PRV_SETUP  ;
Select * From JAS.LABOUR_COMPARISONS  ;
Select * From JAS.LABOUR_RATES  ;
Select * From JAS.LAB_GROUPS  ;

select table_name,column_name from (
  select table_name, column_name,
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) count
  from All_tab_cols
  where owner ='JAS' 
  and (table_name LIKE 'JOB%'
                  or table_name like 'JAVA%'
                  or table_name like 'ITEM%'
                  or table_name like 'J_%'
                  or table_name like 'JD%'
                  or table_name like 'I_%'
                  or table_name like 'LABOR%'
                  or table_name like 'LABOUR%'
                  or table_name like 'LAB%')
    order by table_name, column_name
)
where count=1
/

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The error now says Binary. I would have thought that this code should also work. Left out tables. Looks like I am going to have to check not only for BLOB type fields but also Binary..? Is that what that means?
select table_name,column_name from (
  select table_name, column_name,
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) count
  from All_tab_cols
  where owner ='JAS' 
  and data_type in ('VARCHAR2','NUMBER')
  and (table_name LIKE 'J%'
                  or table_name like 'I%'
                  or table_name like 'LAB%')
    order by table_name, column_name
)
where count=1
/

Open in new window

User generated image
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

My guess is you are hitting a bug.

What version are you running?

select * from v$version;
Yes, I had mentioned it before, Can you work it around with the CASE statement I suggested?
I tried RAW here based on another post about this error.
  and data_type in ('VARCHAR2','NUMBER','RAW')
and it seemed to switch from Binary to BLOB but now it is only showing Binary.
User generated image
RAW cannot be searched this way.

You can try Sujith's suggestion.  Not sure I understand why it would make a difference but I learn new things all the time.
Sujith
I have everything in the code as suggested but I am confused on these two lines. Can you help me see.
and   table_name like '%'.....I know what this line does just more confused about what goes below?
  and   table_name not in (select table_name from all_external_tables where owner = 'JAS')

/*All 902 Tables above left out intentionally*/
Select * From JAS.LABOUR_COMPARISONS  ;
Select * From JAS.LABOUR_RATES  ;
Select * From JAS.LAB_GROUPS  ;

select table_name,column_name from (
  select table_name, column_name,
  case 
    when data_type in ('VARCHAR2', 'NUMBER') then 
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) end count
  from All_tab_cols atc inner join all_objects ao on atc.table_name = ao.object_name
  where atc.owner ='JAS' and ao.owner ='JAS' 
  AND table_name LIKE '%'
  AND table_name not in
                 and (table_name LIKE 'J%'
                  or table_name like 'I%'
                  or table_name like 'LAB%')
                 and ao.object_type = 'TABLE'
    order by table_name, column_name
)
where count=1
/

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...All Same Tables  As Above....
select table_name,column_name from (
  select table_name, column_name,
  case 
    when data_type in ('VARCHAR2', 'NUMBER') then 
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) end count
  from All_tab_cols atc inner join all_objects ao on atc.table_name = ao.object_name
  where atc.owner ='JAS' and ao.owner ='JAS' 
                 and ao.object_type = 'TABLE'
    order by table_name, column_name
)
where count=1
/

Open in new window

Throws this error?
User generated image
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Don't ask me how or why cause I do not know. I am starting to wonder since this was a Live Data Base and the client more than likely is out of the system and dealing with CA traffic .... might be the reason who knows. But at least I got results......Yippee. I had better not get too happy just yet don't want to jinx it.
select table_name,column_name from (
  select table_name, column_name,
  case 
    when data_type in ('VARCHAR2', 'NUMBER') then 
    EXTRACTVALUE(
      DBMS_XMLGEN.getxmltype(
        'select count(*) X from ' || table_name || ' where to_char(' || column_name || ') = ''Insulation'' and rownum=1'
      ),
      '/ROWSET/ROW/X'
    ) end count
  from All_tab_cols atc inner join all_objects ao on atc.table_name = ao.object_name
  where atc.owner ='JAS' and ao.owner ='JAS' 
    AND (table_name LIKE 'J%'
                  or table_name like 'I%'
                  or table_name like 'LAB%')
                 and ao.object_type = 'TABLE'
                   order by table_name, column_name
)
where count=1
/

Open in new window


User generated image
Does Oracle have some kind of restriction on a live database where querying or certain functions just do not work when it is being accessed. I may be drunk and in left field but I wonder?
>> just do not work when it is being accessed

No.


I'm still wondering what difference moving the data_type check into a CASE makes.  I cannot think of any reason it matters.

Can you try running both statements back to back?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I wanted to know how I could request an extra thousand points for you guys each for helping me. This is the longest question or thread I have ever made. Who would I contact to do that?