Friday, June 7, 2019

Count of Each Table Oracle

small and simple plsql script is created to find count of each table in oracle database for one schema.
This PLSQL can execute either on SQL Developer or SQLPlus editor. It's a small plsql used cursor and for loop and concept of dynamic query execution in Oracle.

See below code

set serveroutput on
declare
    
    cursor c2 is select * from user_tables;
    v_sql1 varchar(4000);
    v_count number;
begin
   for ii in c2 loop
    v_sql1 := 'select count(*) from '|| ii.table_name;
    
    execute immediate v_sql1 into v_count;
    dbms_output.put_line(ii.table_name ||'-'|| v_count);
   end loop;
end;
/

Simple Cursor and For Loop in Oracle

in oracle we can open cursor and need to start loop (while similar as SQL Server) so that we can process data what ever is coming in cursor.

In this post i am going to show you simplest code or plsql to do cursor and for loop of cursor.
See below syntax

set serveroutput on
declare
    cursor c2 is select * from user_tables;
begin
   for ii in c2 loop
    dbms_output.put_line(ii.table_name);
   end loop;
end;
/


In this cursor Oracle will automatically open and close the cursor before start and end of the program. so do not worry about the having 'open cursor' and 'close cursor' in your code.

Tuesday, June 4, 2019

py0018 : Change color of button on hover and borderless button

while working in python we might need to create border less button or change the color of button on hover.
for this we can add parameter in method (def) of button, activebackground='green', borderwidth=0. Activebackground will be responsible of change color of button when mouse cursor hover on the the button
and borderWidth will remover the border from the button

import tkinter as tk

class HoverButton(tk.Button):
    def __init__(self, master, **kw):
        tk.Button.__init__(self,master=master,**kw)
        self.defaultBackground = self["background"]
        self.bind("Add**less**than**Enter**Add**greater**than", self.on_enter)
        self.bind("Add**less**than**Leave**Add**greater**than", self.on_leave)

    def on_enter(self, e):
        self['background'] = self['activebackground']

    def on_leave(self, e):
        self['background'] = self.defaultBackground

root = tk.Tk()

classButton = HoverButton(root, text="Classy Button", activebackground='green', borderwidth=0)
classButton.grid()

root.mainloop()

Note* Add**less**than** *** **Add**greater**than
please modify the code before execution, add less than and greater than sign

Monday, June 3, 2019

py0017 : Parameter 'bg' value is not used less... (ctrl+F1)

Error:
Parameter 'bg' value is not used less... (ctrl+F1)
Inspection infoL This inspection highlights local variablem parapmeters or local function unused in scope

Requirement:
How to set default color of button default to white

Solution:
Used "bg" paramter to set color value

   def numrcbtn(self, val, write=True, width=12, height=4, padx=1, pady=1) :
   return HoverButton(root, text=val, command=lambda: self.click(val, write), width=width, height=height, padx=padx, pady=pady, activebackground='Gainsboro' , bg='white')
   
   

Wednesday, May 29, 2019

Traceonly option is currently not supported

Problem :

set autotrace traceonly;

Execute above query on sql developer.

If you are looking for traceonly option in sqldeveloper then answer is no , they query you executed on oracle CMD will not work on SQL Developer.

Instead you can write the query on SQL Developer whose xplain plan your trying to get.

It is more simple in SQL Developer , see below how

1. Write a SQL query on SQL Developer
2. Select query
3. Click on third icon (right to "Execute statement") "Explain Plan) or Press F10
4. On Pressing third icon click on , it will generate the query and 
5. Execute it


web stats