Execute Immediate is not working well

We need to find tables with the same name and columns but these columns whose data type is different. The SQL below detects the difference.
select a.table_name, a.column_name, 
a.data_type ||'---> '||a.owner BASE_SCHEMA_TYPE, 
b.data_type ||'---> '||B.owner COMPARED_SCHEMA_TYPE 
from all_tab_columns a, all_tab_columns b  where a.owner =
'SCOTT' and b.owner = 'HR'  and a.table_name=b.table_name and
a.column_name=b.column_name and a.data_type!=b.data_type
Based on the SQL above, I created the procedure mentioned below which takes a base as input parameter schema and find these tables with the same name but have different data type columns. It generates dynamic SQL code properly (you can see in DBMS_OUTPUT) but for some reason, the INSERT is not the case with EXECUTE IMMEDIATE. No idea why?
create or replace procedure admin.compare_data_types (p_baseschema in varchar2)
is
v_sql   varchar2(2000);
begin

delete from admin.differences;
commit;

for rec in (select  username from  dba_users where Username IN ( 'HR'))
loop

  v_sql := 'insert into admin.differences select a.table_name, a.column_name, a.data_type ||''---> ''||a.owner BASE_SCHEMA_TYPE, b.data_type ||''---> ''||B.owner COMPARED_SCHEMA_TYPE from all_tab_columns a, all_tab_columns b      where a.owner = '''||p_baseschema||''' and b.owner = '''||rec.username||'''  and a.table_name=b.table_name and a.column_name=b.column_name and a.data_type!=b.data_type';
     
     dbms_output.put_line (v_sql);
     execute immediate v_sql;
     --commit; -- Doesn't make any difference
     --v_sql := null; -- Doesn't make any difference
     


end loop;
commit;

end compare_data_types;
Structure of the table being INSERT ed
create table admin.DIFFERENCES
(
  TABLE_NAME           VARCHAR2(200),
  COLUMN_NAME          VARCHAR2(200),
  BASE_SCHEMA_TYPE     VARCHAR2(100),
  COMPARED_SCHEMA_TYPE VARCHAR2(100)
)

How about putting in a debug message to see what he does...

(don't forget to ' set serveroutput we "before...)

create or replace procedure admin.compare_data_types (p_baseschema in varchar2)
is
v_sql   varchar2(2000);
begin

delete from admin.differences;
commit;

for rec in (select  username from  dba_users where Username IN ( 'HR'))
loop

insert into admin.differences
select a.table_name
      ,a.column_name
      ,a.data_type ||'---> '||a.owner BASE_SCHEMA_TYPE
      ,b.data_type ||'---> '||B.owner COMPARED_SCHEMA_TYPE
  from all_tab_columns a
      ,all_tab_columns b
 where a.owner          = p_baseschema  -- Procedure Paramater
   and b.owner          = rec.username
   and a.table_name     = b.table_name
   and a.column_name    = b.column_name
   and a.data_type!=b.data_type;

 dbms_output.put_line('Rows Inserted for '||rec.username||': '||sql%rowcount);
end loop;
commit;

end compare_data_types;

And see if it is one) enter the loop and b) the number of rows is inserted during the process.

If it displays 0 rows inserted, then there's something of logically wrong with your select statement, as is return nothing.

Tags: Database

Similar Questions

  • Lightning cable does not work well

    Its already 3 weeks I use iphone to. the cable of the lightning that was in the box does not work well. I need to pull up to my phone charged. How can I solve this problem.

    Clean the lint on the connector of the lightning on the phone with a toothpick.

  • my iPhone 6s has problems with the GPS when I use some applications, it does not work well and give especially the bad road. Can someone help me?

    my iPhone 6s has problems with the GPS when I use some applications, it does not work well and give especially the bad road. Can someone help me?

    My iphone 6 has started having the same problem. Its literally the GPS. Saying that it does not find me at all. Ive seen say location for more than an hour in the suburbs of chicago. It started to happen to me after I downloaded the latest update for the iphone. I hope they react and let you know what is happening because I'm dying to know as well.

  • Satellite M30-113 does not work well when I use FreeBSD 6.2

    Hello

    My M30-113 does not work well when I use FreeBSD 6, 2-RELEASE http://www.FreeBSD.Org/

    I was told that Toshiba has release a new bios to correct the problem of cooling, because it does not allow me to fan passive cooling in FreeBSD.

    So could we have a new bios to solve this issue?

    Arabian salvation

    I am sure that mobile industry is focused on Windows operating system and hardware architecture together and preinstalled software are adapted and also configured to run well and stable.

    This operating system is supported and if something should be better portable manufacturers offer different updates to the BIOS. Of course, you can preinstall what you want but you can not expect support for everything you can find on the market and because of this I n t believe that you won't find any update especially for FreeBSD 6.2 - RELEASE BIOS.

  • My touchpad does not work well on Satellite C55-A-1ND

    For several days my touchpad does not work well. It has nothing to do with the power touchpad button on the F5 key.

    The touchpad is most time does not and something a bit but I can't use the touchpad at all now.

    When I attach my external mouse on my laptop I can use my laptop otherwise I can't use my laptop.
    I already rebooted my laptop several times, but it helps not at all.

    I hope someone can help me!

    You said that this issue has nothing to do with the touchpad on/off function s.
    So what's exactly wrong with the touchpad? Is he disabled or enabled?

    Have you checked the settings in the control panel-> mouse-> last (device settings) tab-> settings button?

    Have you already tried to reinstall the software/driver for touchpad?
    If this is not the case, do.

    By the way: what model of laptop and what system you have?

  • P850 satellite and a WiFi - internet connection does not work well

    Hello

    My internet connection does not work with a Wi - Fi connection.
    I have laptop Satellite P850-131, which I bought a few months ago and I noticed that over the past two months the internet connection does not work well. When I connect to the computer shows that I am connected Wi - Fi connections, however there is no connection and I can't access the internet.

    I tried to do all the regular search but nothing works. Sometimes the message I get told that there is a problem with the DNS and other times with the IP address. However, with other computers I didn't have any problem at all to connect to the same Wi-Fis.

    All solutions?

    > When I connect to the computer shows that I am connected Wi - Fi connections, however there is no connection and I can't access the internet.

    If such a problem would appear again start the console (window BACK in typing CMS in search)
    Here, use the command * ipconfig / renew *.

  • Light does not work well on my Satellite A660

    Hello

    I have a problem with my Toshiba Satellite A660. The brightness of my screen does not work well, when I try to increase the brightness, it goes down, I mean is dimmed.
    I try to reinstall the drivers, but continue it problem. Anyone know what I could do?
    Thank you very much

    Stand by. I put t know how you try to change the brightness of your screen, but I would like to know if this work when you use FN + F6/F7 or when you change the level of brightness in power intend that you use (power options).

    Are you using the original pre-installed OS that you got with your laptop or your own installation of the OS?

  • Hello! I restored my iPhone 5 because IOS 9.2 does not work well, and now the IPhone does not recognize the SIM CARD ☹️ please someone help me! What can I do?

    Hello!! Recently, I have restored my iPhone 5 because IOS 9.2 does not work well. But now my iPhone does not recognize the SIM CARD.

    I Don' t know what to do, help me please

    You get an error message?

    What did he say?

  • On the Satellite P500 microphone does not work well

    I spent $2,000 to buy this Satellite P500 a month ago and soon found that the microphone does not work well. I used the web camera application to record a video to test, the volume level is very low that you barely hear it and it cracks.

    I called the support center, waited for half an hour and finally had someone to talk to me, I followed his instructions adjusted the level of the microphone to 100 and the boost to 0.
    The cracking sound disappeared, but the level of volume is still too low to hear. What can I do?
    Call again and wait half an hour? His Friday 17:00, they will be upset and I'm already mad!

    Hello

    Have you tried to test mic with Skype or a similar application. Friend of mine has Satellite P500-127 and he use it for Skype communication.
    I can hear it fine and everything works fine.

    Do you still have the factory settings (original operating system preinstalled)?

  • My screen touch iphone 5 does not work well when charging. Please someone help me

    Members of the apple, Hello

    When I'm using my iphone and he is in charge the touchscreen does not work well

    Why apple made this feature on ios?

    Try

    http://support.Apple.com/en-us/HT201559

  • Logitech Internet Pro mouse does not work well.

    I have a Logitech Internet Pro muse and his does not work well since last month. Maybe I should clean a tell me please to open this optical mouse to clean or may be a virus is there or Spring does not work. The model information is on the http://reviews.cnet.com/keyboards/logitech-internet-pro-desktop/1707-3134_7-31228942.html link. I don't him is not connected with a USB port THANK U. PLEASE HELP ME!

    Hello

    Were there any changes (hardware or software) to the computer before the show?

    Method 1: Yes, you can open the mouse and clean it to remove any dirt inside.

    Method 2: you can download and install the drivers for the mouse on the manufacturer's Web site and see if the problem is resolved.

    Hope this information helps.

  • Keyboard seems as if it does not work well

    Hello

    The brand of my laptop is Acer
    The product name is Esxtensa 5220.
    My Windows system is Ultimate(64Bit) 7

    I haven't installed a keyboard/mouse driver software when I installed Windows 7 because when I looked on the official website of Acer, I found no drivers keyboard and mouse for Windows 7(64Bit). Thus, Windows 7 was installed their automcatically just at the moment where it was installed. I didn't install any software dirver keyboard and mouse at all.

    I really see that my keyboard does not work well by tapping it. Sometimes I see another letter is typed though I haven't typed it.  In addition, the pointer of the mouse jumps sometimes to another location in the text box (for this text box for this forum) while typing which results in the insertion of letters in another place, other than what I want that they should be inserted.
    I don't know what it is, but I will say.
    When you type 't', so I sometimes see that another letter is typed rather instead. Also, sometimes while typing in the text box, a text, I found that the mouse pointer jumps to be placed in the middle or from the text, if the letters are written in the other place, other than I want to be they.

    So, is there a driver or a program associated with it for keyboard should be installed?

    It's shows in Device Manager that keyboard and mouse driver installed, Windows 7 was installed their automcatically just at the moment where it was installed. I didn't install any software dirver keyboard and mouse at all.

    Thank you very much.

    I tried install driver TougchPad of Snyaptic, which is specific for laptop HP Clubhouse anthter of my friends, so I'm satisied with the result, I've found so far, but the mouse has been updated only. In addition, I don't know if it's OK or it is some problems might occur in the future with driver not designed for Acer laptop.

    However, the keyboard is still with the driver of the lunch Manager.

    PS: I think that there is something bad goes with the download of the images through this forum, so I think that admins should find a sloution.

    I don't really see your screen shot post lately.

  • Keyboard does not work well

    Hello!

    The qwerty keyboard on my aqua m4 xperia phone does not work well, when I try to register somenting words aren't apears... I need to close a re message open a few times so I can sign up, but it is really annoying to do this every 10 minutes

    Am I the only one who have problems with this?

    PD. I'm from Mexico and my English int ' good t... Sorry for that

    @Ivan_valdez94

    It is a third party acting upward application

  • Z10 ATT BBZ10 10.3.2.440 blackBerry software does not work well: screen distorted, keyboard. How downgrade?

    ATT sent a software relaease 10.3.2.440 which was downloaded on my BBZ10 and does not work well: screen distorted, difficult of keys and numbers located on the edges of the keyboard, etc, etc. How downgrade to previous realease of software which worked very well? Thaks for specific support on the issue and BBZ10.

    FDR wrote:

    ATT sent a software relaease 10.3.2.440 which was downloaded on my BBZ10 and does not work well: screen distorted, difficult of keys and numbers located on the edges of the keyboard, etc, etc. How downgrade to previous realease of software which worked very well? Thaks for specific support on the issue and BBZ10.

    Switch magnifying glass Mode OFF in settings - accessibility.

  • problem with NFS MOST WANTED... car does not work well

    Hey... I installed NFS MOST wanted on my laptop a long time ago... and 2 days ago it was working properly, but now during acceleration cars, its noise is too loud, and it does not work well or normal...

    Nobody understand my problem... plz suggest me...

    Try a system restore to when it worked:
    http://Windows.Microsoft.com/en-us/Windows7/products/features/system-restore

    Check the reliability monitor to see what changed between where he worked and where you have noticed the problem:
    http://Windows.Microsoft.com/en-us/Windows7/how-to-use-reliability-monitor

    In particular, if there is no driver updates, try to back off:
    http://Windows.Microsoft.com/en-us/Windows7/restore-a-driver-to-its-previous-version

Maybe you are looking for

  • What happens if the iCloud taps does not work on iMac?

    What should I do if the iCloud taps don't work on iMac? My iMac does not show the browsers of my MBP, iPhone or iPad (and vice versa). I tried to unplug the iMac and notation on my account iCloud again. Thank you.

  • Equium L10 - touch pad stop working (mouse)

    Hi guys,. really need your help. I have an Equium L10-300 and my touch pad has stopped working. A few days back, he started to freeze, but reboot solved the problem... but now it has stopped working all together. The icon that normally indicates at t

  • HP Pavilion dv5-1190ej: looking for the original bios version

    After updating the bios that failed, I tried to update the usb drive and bios update completed with the mobile ashuting down. Yet it doesn't show anything on the screen after reboot, and no splash screen appears. I'm looking for the F.0C version that

  • Demo program continues to repeat

    I have a HP Photosmart 5510 all-in-One B111 Series printer.  Recently, the on-screen demonstration program has started playing.  Once it passes through the different screens of the program it stops for a short time while he starts to load up on its o

  • No black screen after login NO CURSOR!

    I'm using a windows vista on a computer laptop fujitsu. I have two accounts on this laptop and one account works fine but the other account goes into a blank screen WITHOUT a slider, I tried ctrl + alt + del but nothing comes. What should I do?