Why nested block is not executed here?

I created a procedure that will populate the tables and their counts in a scheme from when you run this procedure. For pl/sql nested block demonstration purposes and also I will create a trigger to update this table. Here is my code.

create or replace procedure schema_tab_count as

c number;

Start

Declare

Table_exist exception;

pragma exception_init (Table_exist,-00955);

Start

run immediately ' create table schema_tab_cnt (table_name varchar2 (30), count of number (10))';

exception when Table_exist then

run immediately 'Truncate table schema_tab_cnt;

end;

because me in (select * from tab) loop

run immediately ' count (1) select "| i.tname in c;

insert into schema_tab_cnt values (i.tname, c);

end loop;

commit;

exception: when other then null;

end;

/

CAUTION: Procedure created with compilation errors.

SQL > sho err

Errors in PROCEDURE SCHEMA_TAB_COUNT:

LINE/COL ERROR

-------- -----------------------------------------------------------------

14/1 PL/SQL: statement ignored

14/13 PL/SQL: ORA-00942: table or view does not exist

SQL >

Since the error log, its clear that the code in the nested block is not running.

What is the reason and the solution for this?

Thank you.

Ok as you have stated this code is for DEMO purpose I am going
to proceed further and fix your code. If you are going to use it for
any actual production purpose then its a bad idea and you should not
do it.

Also do not use EXCEPTION WHEN OTHERS the way you have used. Its always
certainly a bug. Always WHEN OTHERS exception must be followed by RAISE.

The issue is with your insert statement. The table actually does not exist
when you are compiling the code. So you need to make your insert
statement as Dynamic SQL so that it is not validated during compilation.

Like this.

SQL> create or replace procedure schema_tab_count
  2  as
  3       c number;
  4  begin
  5       declare
  6            table_exist exception;
  7            pragma exception_init (table_exist, -00955 ) ;
  8       begin
  9            execute immediate 'create table schema_tab_cnt(table_name varchar2(30),count number(10))';
 10       exception
 11            when table_exist then
 12                 execute immediate 'truncate table schema_tab_cnt';
 13       end;
 14
 15       for i in (select * from tab)
 16       loop
 17            execute immediate 'select count(1)  from "' || i.tname || '"' into c;
 18            execute immediate 'insert into schema_tab_cnt values(:1,:2)' using i.tname, c;
 19       end loop;
 20
 21       commit;
 22  end;
 23  /

Procedure created.

SQL> exec schema_tab_count

PL/SQL procedure successfully completed.

SQL> select * from schema_tab_cnt;

TABLE_NAME                          COUNT
------------------------------ ----------
BIN$+4sdomixCCXgRAAUTz6XRg==$0         12
BIN$+4sdomiyCCXgRAAUTz6XRg==$0          2
BIN$/BgKoshic2jgRAAUTz6XRg==$0     500000
DEPT                                    4
EFF_RATE_TMP                            0
EMP                                    11
E_MAIL_LOG                              0
LOGGER                                  0
SCHEMA_TAB_CNT                          8
TEST_MIG                                2

10 rows selected.

SQL>

Tags: Database

Similar Questions

  • Why is blocked and not resolved.

    Why is it that is "Keep getting we noticed you can have signed in or logged out in another window. Click OK to reload your page. each time I start firefox' blocked and unsolved. I had this problem since FF upgrade ver 13. Mozilla is going to solve this problem? I use Win XP. None of the answers to question solves the problem for me.

    This question-> https://support.mozilla.org/en-US/questions/836545?s=Keep+getting+We+noticed+you+may+have+signed+in+or+signed+out+in+another+window.+Click+OK+to+reload+your+page.+everytime+I+start+firefox

    is blocked because the original question is more than a year. Advice given on the previous versions of Firefox may vary advice given on the current versions of Firefox. Assignment to similar issues with the same/similar topic may be allowed.

    Search for an another thread/question similar or post a new question giving all your details.

    If this answer solved your problem, please click 'Solved It' next to this response when connected to the forum.

  • PLSQL block does not run

    Hi all

    PLSQL block is not executing .showing reference out of reach. ?


    create or replace procedure sma
    is

    cursor c4 (P_no number) is select * from employee where department_id = P_no;
    I have used % rowtype;
    Start
    Open c4 (90);
    loop
    extract the c4 inside;
    When the exit c4% notfound;
    dbms_output.put_line (I.employee_id |) I.first_name);
    end loop;
    Close c4;
    end;

    /

    Start
    SMA. C4;
    end;

    image.png

    Capture.PNG

    And how he can run if the procedure name is SMA when you call ADM. C4? Question:

    BEGIN

    ADM;

    END;

    /

    PYM

  • Why read emails do not block.

    Why read emails do not block. They default to Outlook express block No. How can I fix it

    If you don't see all the toolbars allow them:

    Click on the 3 bars menu icon
    Place the cursor on the 'Options '.
    Make sure all the toolbars are enabled because this makes life so much easier.
    See the image below as an aid.

    Then check your settings:
    Tools > Options > advanced > tab reading and display
    I love having my messages ranging from "BOLD" to unbold immediately when I select to read.
    See the second image below

  • Why an asynchronous call would lead to "the VI is not executable. The full development version... »

    I built a labview moderately complex program to connect with a new parser that I build.  To briefly describe the application, the main VI is a user interface which, in an initialization step, asynchronously calls a dozen other screws each called VI is a state machine that handles communication with a component specific for my parser, whether heat controllers, regulators debit, NI DAQmx channels, a SQL database, etc..  I use the VFG and/or EI to communicate information between the main VI and each component. The system works well when it passes through NI Labview 2012 SP1 (full development Version).  I build the project successfully, but when I run the construction (on the same development machine), I encounter the "the VI is not executable.  The full development of LabVIEW version is needed to correct errors"message.

    My first troubleshooting step that was supposed to isolate the problem.  I removed all the asynchronous calls, rebuilt and the program works without errors (granted, no State machines that handle I/O bundles are running). This gave me the impression that my UI screws are not the problem.

    The next step that I took was to create a test project with a simplified user interface to call asynchronously, and control a single component.  The first part, I tried to control a heating unit, and it works perfectly.  I have build it and run without errors or problems.

    Thinking that the component should not be a problem, I add the async call for this component in my main VI, to test it.  This works well in the built environment of Labview development, without errors, but alas, I get the same message as the "VI is not executable' when I try to run the build.

    I am at a loss on how to make trouble, or it could be the cause of the problem.  Why an asynchronous call to the VI even break the construction of an executable project, but don't cause problems in an executable of side projects?


  • Grant permission to select the function but not executed in a PL/SQL block

    Hello.

    I know that there are only two permissions on procedures/functions - RUN and DEBUG.

    But I want to grant EXECUTE permissions for a user so that the user can Select the function to double or to any other request, but not to run(to prevent the user to trigger the update of LMD - insertion, etc.) inside a BEGIN-END block.

    I know that we can revoke access to tables etc. But that access has to give. The user must be able to perform the DML operation, but just not through a function.

    Can someone please help?

    I know that there are only two permissions on procedures/functions - RUN and DEBUG.

    Fix - so give one or both of those who depend on your use case.

    
    But I want to grant the EXECUTE permission to a user in such a way that the user can select the function using dual or any other query but not execute( to prevent the user from firing DMLs - Insert, update etc) inside any BEGIN-END block.
     
    

    You already know that there is NO "select" privileges for functions. a query such as "select the function of double" RUNS the function. That's all what you can do with the functions is execute them.

    I know that we can revoke access to tables etc. But that access has to be given. The user should be able to do perform DML operation, but just not through a function.
    

    Then revoke execute on the service. Then the user cannot run the service either directly or in the context of a dml statement.

  • Why Flash cookies are not deleted the first time I'm leaving Firefox?

    I am running XP, Firefox 16.0.1 and Flash Player 11.4.402.287 and have Firefox configured to 'Clear history of Firefox closing', with 'Cookies' (among others) checked "settings to erase history. I also have Flash Player configured to "Block all sites to store information on this computer."

    As I understand it, from Firefox 4 and Flash Player 10.3, have Firefox configured in this way should cause cookies Flash should be deleted out of Firefox. I also understand that even though I have Flash configured as I do, a list of websites that try to plant a cookie Flash is always recorded in the main settings.sol cookie.

    I noticed, however, that this list of empty Flash cookies is not removed the first time I have quit Firefox; on the contrary, the list is deleted after launch and then leaving Firefox again.

    Here is a step-by-step example:

    (1) Control Panel-> Flash Player-> storage tab-> storage Local to Site-> button settings confirm that the list is empty

    (2) output, that manage Flash Player settings

    (3) launch Firefox-> go to http://www.Hulu.com/ and click on a video to start playing

    (4) recovery Control Panel-> Flash Player-> storage-> Local website storage settings... tab button-> make sure that the list indicates http://www.Hulu.com/, 0 bytes, block

    (5) leave the Flash Player Settings Manager

    (6) Firefox exit

    (7) raise Control Panel-> Flash Player-> storage-> storage settings Local to Site-> NOTE THAT THE LIST SHOWS AGAIN http://www.Hulu.com/, 0 bytes, block

    (8) leave the Flash Player Settings Manager

    (9) restart Firefox

    (10) raise Control Panel-> Flash Player-> storage-> storage settings Local to Site-> NOTE THAT THE LIST SHOWS AGAIN http://www.Hulu.com/, 0 bytes, block

    (11) exit the Flash Player Settings Manager

    (12) exit Firefox

    (13) stimulus Control Panel-> Flash Player-> storage-> storage settings Local to Site-> NOTE THAT THE LIST IS now EMPTY

    Once again, my question is - why this list is not emptied the first time around?

    Safe mode disables plugins, I think not, so that you can put those aside for now.

    I suggest disable all non-essential extensions. We all tend to accrue to those who are not really necessary. You can do so here:

    Orange Firefox button or classic menu Tools > Modules > category: Extensions

    If the kernel extensions, you really like the cause of the same problem, then I think you will have to just live with it. Please note that Flash is followed correctly your bet as a block, so I don't think that something is actually stored.

  • Open vi FPGA gives error xnode (Lv 8.6) (not executable)

    Hello

    I wrote my description of the error also here: http://forums.ni.com/ni/board/message?board.id=280&message.id=5055&jump=true#M5055

    When using "run vi on the development computer" I get an error broken pointing me to the "open FPGA vi function", the problem

    be 'an xnode object is not executable. I have not found this problem under discussion anywhere, I tried uninstalling FPGA and Rio soft.

    and resinstalling, but not help. All ideas are welcome.

    Thank you

    Staffan

    Hello

    JMota wrote:

    "Here's something to try. I think that the configuration of your FPGA target to run on the development computer (with simulation of IO) will not work if you try to run your host VI on RT. test by dragging the VI to my computer and run it from there. Altenatively, you can reconfigure your FPGA target for not performing on the development computer (what used to be called emulation).

    Hope that explains why the VI has broken. »

    And it solved the problem - works fine now - if this issue is resolved.

    Staffan

  • ORA-00934: Group feature is not allowed here

    CREATE or REPLACE PROCEDURE First(
    date1 IN Date,
    date2 IN Date
    )
            AS
    
    date3 employee.start_date%TYPE;
    date4 employee.start_date%TYPE;
    
    Begin
    select min(start_date) into date3 from employee where start_date between date1 AND date2;
    END;
    /
    Above procedure is completed successfully

    But when I changed the query to

    Select min (start_date) date3, max (start_date) in date4 of employee where start_date between date1 AND date2.
    then I get the error message
    ORA-00934: Group feature is not allowed here.
    Why this error happens during execution, but on sqlplus query is executed successfully.
    I checked this in oerr ora-00934 but not able to understand what measures should be taken
    select min(start_date)
    ,      max(start_date)
    into   date3
    ,      date4
    from   employee
    where  start_date between date1 AND date2;
    
  • Why this scriipt does not work with Firefox? < embed src = "News2008Fall.pdf" width = '615' height = '3200' > < / embed > "

    Please tell me why this script does not work with Firefox. It works with Safari. Here is the page that includes the script: www.lionsgatehoa.org/newslettertest.html. Thank you. Tom Engleman

    Here's the script in my html document:

    < embed src = "News2008Fall.pdf" width = '615' height = '3200' > < / embed > "

    Edit: removed # phone

    Works for me on Linux.

    Your system details list does not display the Adobe Reader plugin, so you'll have to (re) install this program.

    See:

  • Why Apple cards does not work in Saudi Arabia?

    Why Apple cards does not work in Saudi Arabia?

    Hi msmadi,

    I understand you are trying to use cards for Apple in Saudi Arabia, but faced problems. I don't know what questions you are running, but if you want to use a specific feature, it may not be available here. Take a look at the link below to review what features are available with an iOS device using iOS 9.

    iOS 9 feature availability
    http://www.Apple.com/iOS/feature-availability/

    Nice day

  • Why wireless keyboards are not compatible with the Apple TV (4th generation)?

    Why wireless keyboards are not compatible with the Apple TV (4th generation)?  Similarly, why didn't the App compatible with Apple TV Remote (4th generation)?  They will be in the future?

    No one here knows why Apple have so far decided not to support Bluetooth keyboards, or if they are likely to do so in the future. The iOS app is compatible with the 4 ATV in its latest version (4.2.3) - https://itunes.apple.com/gb/app/remote/id284417350?mt=8

  • Why my documents are not marking?

    I notice I can only tag 1 document at once (excel spreadsheet) if I try to bulk mark them by selecting all the and apply a new label, the label appears in the list of tags, but on the selection tag, elements are not displayed as tag.

    I find in bulk tagging works with some things, but not with others.

    all these files/folders that I have tested on my mac (not an external drive) lie.

    I don't have a projector set to hide (Privacy).

    I posted in the wrong forum here

    Re: why are my documents not marking?

    Leonie gave a suggestion I tried (adding my drive to honor confidentiality tab then remove for re - index the reader)

    not sure how long it will take for re-index, so far, no change to the situation.

    fixed after a reboot.

  • HP Deskjet 1010: Why HP 61xl will not work in HP dj1010?

    Why the HP61xl does not work in my printer HP1010?

    The HP SureSupply site here says the right cartridge for the 1010 Deskjet is 61, it seems that this printer does not support the 61xl.

  • Under VI 'DAQ Assistant': Sub VI is not executable

    Salvation OR engineer,

    My task is to acquire and record data of input voltage analog with PCI-MIO-16-1 and BNC-2110 connector. I can get the signal via MAX, but as soon as I drop down the function palette DAQ assistant in FASHION Lab blocks diagram, my run button becomes broken. I got the error message like "Sub VI"DAQ Assistant": Sub VI is not executable. How can I overcome this?

    Thank you

    Yvette.

    Hi Paul,.

    Unfortunately, SignalExpress is a different license than LabVIEW. However, you don't need a SignalExpress to acquire and record data. LabVIEW has every ability to SignalExpress and many more.

    Kind regards

Maybe you are looking for