Tuesday, November 29, 2016

Oracle forms Alert Example

What is Alert?

An alert is a modal window that displays a message notifying the operator of some application condition.
Use alerts to advise operators of unusual situations or to warn operators who are about to perform an action that might have undesirable or unexpected consequences.
Oracle Forms has many Built-in alerts that display pre-defined messages. You can also create your own custom alerts that display in response to application-specific events.
When an event occurs that causes an alert to display, the operator must respond to the alert's message by selecting one of the predefined alert buttons.

Creating an Alert

Alerts are alternative method for communicating with the operator.
They are displayed in a modal window.
They provide an effective way for drawing attention and forcing the operator to answer the message before processing can continue.
Alerts are used to perform:
Display a message that the operator cannot ignore, and must acknowledge.
Ask the operator a question where up to three answers are appropriate( typically Yes, No or cancel).


When you create an alert, you need only specify basic information such as the message you want the alert to display and the text labels for the alert buttons.
Once you create an alert, you must write a trigger or user-named routine to display the alert in response to a particular event. In addition, the action that each button initiates is determined by the PL/SQL code you write to invoke the alert.

To create an alert:

In the Object Navigator, click the Alerts node.
Click Create in the toolbar.
Double-click the alert object icon to display the Property Palette.
Set the Alert Style property to the style that corresponds to the severity of your message: either Stop, Caution, or Note.
At runtime, an icon representing the style you select displays next to the message in the alert window.
Set the Message property by entering the message you want the alert to display at runtime. You can enter up to 200 characters.
Define one or more buttons for the alert by entering a text label in the Button 1 Label, Button 2 Label, and Button 3 Label fields.
Choose the Default Alert Button, either Button 1, Button 2, or Button 3.

Controlling an Alert using Alert Built-in’s

After creating an Alert, you can modify the definitions of that alert at run-time, by using pre-defined built-in’s.
There are 5 pre-defined built-in’s.
SHOW_ALERT
SET_ALERT_PROPERTY
SET_ALERT_BUTTON_PROPERTY
ID_NULL
FIND_ALERT
SHOW_ALERT


Displays the given alert, and returns a numeric value when the operator selects one of three alert buttons.
Syntax:
        SHOW_ALERT(alert_id Alert);
        SHOW_ALERT(alert_name VARCHAR2);
It is a function, which returns a numeric constant corresponding to the button the operator selected from the displayed alert.

SET_ALERT_PROPERTY

It is a procedure, which Changes the message text for an existing alert.
>    SET_ALERT_PROPERTY(alert_id ALERT or alert_nameVARCHAR2,
                         property NUMBER,
                         message VARCHAR2);        

>    Where property  Specifies the specific alert property you are setting,
    message  Specifies the message that is to replace the current alert message.
    If the message text exceeds 200 characters, it will be truncated.
>  SET_ALERT_PROPERTY(al_id, alert_message_text, err_txt );

SET_ALERT_BUTTON_PROPERTY
It is a procedure, which Changes the label on one of the buttons in an alert.
>    SET_ALERT_BUTTON_PROPERTY(alert_id ALERT  or                                           alert_nameVARCHAR2, button NUMBER,   property VARCHAR2,  value VARCHAR2);

>   Where button is a constant that specifies the alert button you want to change, either ALERT_BUTTON1, ALERT_BUTTON2, or ALERT_BUTTON3,     property specifies the property for the alert button and     value  Specifies the VARCHAR2 value to be applied to the property you specified.


ID_NULL

It is a function, that returns a BOOLEAN value that indicates whether the object ID is available or not.
>     ID_NULL(Alert ALERT);
>    Use ID_NULL when you want to check for the existence of an alert created dynamically at runtime.


FIND_ALERT

Searches the list of valid alerts in Oracle Forms.
When the given alert is located, the subprogram returns an alert ID.
You must return the ID to an appropriately typed variable.
Define the variable with a type of Alert.
>    FIND_ALERT(alert_name VARCHAR2);

Errors while using Alerts


FRM-11701: Alert with this name already exists. Cause:  There is already an alert with the same name defined in the active form.
FRM-11703: Unable to retrieve the alert objects from the file.
    Cause:  Internal system error.
FRM-11706: Unable to get the copied/referenced alert %s.
    Cause:  The specified alert does not exist in the database.
FRM-30170: Alert must contain at least one button - %s. Cause:  The alert contains no buttons.
FRM-30360: Alert does not contain the specified default button.
    Cause:  You specified a default button that is not part of the alert definition.
FRM-41039: Invalid Alert ID %d.
    Cause:  An invalid ID was passed to a built-in subprogram.
FRM-41313: No such Property for Set_Alert_Property.
    Cause:  An invalid property has been specified for SET_ALERT_PROPERTY.
FRM-41804: Variable was not entered: %.30s. Cause:  Your response to the Query Where alert contained a placeholder not used in any of the query items.

An alert is a modal window that displays a message notifying the operator of some application condition.
Alerts are used to interact with the users at run-time, to give instructions or give the status of the process.
Using Alert built-in’s, you can modify the contents of an Alert.
While creating an alert at design time, set the default properties to ignore the errors at run-time.

**********************************************************************************
                
**********************************************************************************


   

Tablespace Point In Time Recovery

*************************TABLESPACE POINT IN TIME RECOVERY******************
 Download this file

-->Purpose of RMAN TSPITR

Recovery Manager (RMAN) TSPITR enables quick recovery of one or more tablespaces in a database to an earlier time without affecting the rest of the tablespaces and objects in the database.

RMAN TSPITR is most useful for the following situations:

    To recover a logical database to a point different from the rest of the physical database, when multiple logical databases exist in separate tablespaces of one physical database. For example, you maintain logical databases in the orders and personnel tablespaces. An incorrect batch job or data manipulation language (DML) statement corrupts the data in only one tablespace.

   1) To recover data lost after data definition language (DDL) operations that change the structure of tables. You cannot use Flashback Table to rewind a table to before the point of a structural change such as a truncate table operation.

    2) To recover a table after it has been dropped with the PURGE option.

    3) To recover from the logical corruption of a table.

    4)To recover dropped tablespaces. In fact, RMAN can perform TSPITR on dropped tablespaces even when a recovery catalog is not used.

EXAMPLE STEP BY STEP FOR TSPITR
-------------------------------------
1) CREATE A TABLESPACE;
2) CREATE AN USER AND ASSIGNED THIS NEWLY CREATED TABLESPACE AS DEFAULT TABLESPACE
3) CREATE ANY DATABASE OBJECT IN THIS USER SCHAMA.(WE WILL CREATE A TABLE)
4) PERFORM SOME DML OPERATION
5) NOTE THE TIME OR SCN WHERE YOU WANT TO GO BACK IN TIME/SCN
6) DROP TABLE WITH PURGE OPTION
7) CONNECT TO RMAN TO PERFORM THE RECOVERY
8) CHECK THE TABLE, YOU WILL GET BACK THE TABLE OF DESIRE TIME/SCN.WE WILL BE ABLE TO SEE THE PURGE TABLE BACK


COMMANDS  lets start :)
----------
1) CREATE TABLESPACE TBS100 DATAFILE '/u01/app/oracle/oradata/orcl/tbs100.dbf' size 10m;
2) CREATE USER PUSHPJEET IDENTIFIED BY ORACLE DEFAULT TABLESPACE TBS100;
   GRANT CONNECT,RESOURCE TO PUSHPJEET;
3) CONN PUSHPJEET/PUSHPJEET
   CREATE TABLE EXAMPLE(ID NUMBER,NAME VARCHAR2(20));
4) INSERT INTO EXAMPLE VALUES(1,'INDIA');
   INSERT INTO EXAMPLE VALUES(2,'USA');
   COMMIT;
5) SELECT TIMESTAMP_TO_SCN(SYSDATE) SCN FROM DUAL;
 
6) DROP TABLE EXAMPLE PURGE;
 --CHECK IT IS PURGED OR NOT
   SELECT * FROM EXAMPLE;
--YOU WILL GET ERROR TABLE OR VIEW DOES NOT EXIST
7) $rman target /
    RMAN>recover tablespace tbs100
         until scn 12345                                   --give the scn you recorded earlier
         auxiliary destination '/u01/';
8) conn PUSHPJEET/ORACLE
   SELECT * FROM EXAMPLE;

--YOU WILL BE ABLE TO SEE YOUR TABLE IS BACK...



 




















Monday, August 1, 2016

What is BCNF?

Boyce Codd normal form (BCNF)

It is an advance version of 3NF that’s why it is also referred as 3.5NF. BCNF is stricter than 3NF. A table complies with BCNF if it is in 3NF and for every functional dependency X->Y, X should be the super key of the table.
Example: Suppose there is a company wherein employees work in more than one department. They store the data like this:
emp_id emp_nationality emp_dept dept_type dept_no_of_emp
1001 Austrian Production and planning D001 200
1001 Austrian stores D001 250
1002 American design and technical support D134 100
1002 American Purchasing department D134 600
Functional dependencies in the table above:
emp_id -> emp_nationality
emp_dept -> {dept_type, dept_no_of_emp}
Candidate key: {emp_id, emp_dept}
The table is not in BCNF as neither emp_id nor emp_dept alone are keys.
To make the table comply with BCNF we can break the table in three tables like this:
emp_nationality table:
emp_id emp_nationality
1001 Austrian
1002 American
emp_dept table:
emp_dept dept_type dept_no_of_emp
Production and planning D001 200
stores D001 250
design and technical support D134 100
Purchasing department D134 600
emp_dept_mapping table:
emp_id emp_dept
1001 Production and planning
1001 stores
1002 design and technical support
1002 Purchasing department
Functional dependencies:
emp_id -> emp_nationality
emp_dept -> {dept_type, dept_no_of_emp}
Candidate keys:
For first table: emp_id
For second table: emp_dept
For third table: {emp_id, emp_dept}
This is now in BCNF as in both the functional dependencies left side part is a key.

Hope you got the concept.

Monday, May 2, 2016

Understanding Authid Current_user Authid Define with example

In this post I am going to show a video that how you can use Authid Current_user and Authid definer clause in procedure or function in plsql.




You can download the notepad file from here.. DOWNLOAD 


Watch it on Youtube Watch Now

Sunday, April 17, 2016

Creating database manually

Creating database manually step by step by Pushpjeet Cholkar 

Download the text file from her Download

1)
Create required directories at OS level as oracle user

/u01/app/oracle/oradata/info
/u01/app/oracle/oradata/info/log
/u01/app/oracle/oradata/info/data
/u01/app/oracle/oradata/info/control

2)
Compose a parameter file with name initinfo.ora at database default location   $ORACLE_HOME/dbs

db_name=info

instance_name=info

db_block_size=8192

control_files=(/u01/app/oracle/oradata/info/control/control1.ctl,/u01/app/oracle/oradata/info/control/control2.ctl)

sga_max_size=400m

shared_pool_size=300m

undo_management=auto

undo_tablespace=undotbs1

remote_login_passwordfile=exclusive

compatible=11.2.0

3)  
Create a database script file with name db.txt    at database default location    -- Create sql script file or normal text file anywhere at os level or even just write the below command to create database.

create database info

logfile  group 1 '/u01/app/oracle/oradata/info/log/redo1a.log' size 50m,

         group 2 '/u01/app/oracle/oradata/info/log/redo2a.log' size 50m,

         group 3 '/u01/app/oracle/oradata/info/log/redo3a.log' size 50m,

         group 4 '/u01/app/oracle/oradata/info/log/redo4a.log' size 50m

datafile '/u01/app/oracle/oradata/info/data/system01.dbf' size 200m autoextend on maxsize unlimited

sysaux datafile '/u01/app/oracle/oradata/info/data/sysaux01.dbf' size 200m autoextend on maxsize unlimited

default temporary tablespace info_temp tempfile '/u01/app/oracle/oradata/info/data/temp1.dbf' size 200m autoextend on maxsize unlimited

undo tablespace undotbs1 datafile '/u01/app/oracle/oradata/info/data/undo1.dbf' size 200m autoextend on maxsize unlimited;


4)
Create password file by the following command

orapwd file=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwinfo password=admin entries=10



5)
Make entry in /etc/oratab file

info:/u01/app/oracle/product/11.2.0/dbhome_1:N

6)
  Set the enviornment to start the instance

[oracle@oracle ~]$ . oraenv
ORACLE_SID = [orcl] ? info
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle
[oracle@oracle ~]$

Check it is set or not

[oracle@oracle ~]$ env | grep ORACLE
ORACLE_UNQNAME=info
ORACLE_SID=info
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=oracle.localdomain
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
[oracle@oracle ~]$


7)
Startup database in nomount state to run the 3 important script to create data dictionary view,procedure,function,package and other object automatically.

[oracle@oracle ~]$ sqlplus / as sysdba

SQL> startup nomount
SQL> @'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/db.txt'
SQL> create spfile from pfile;
SQL> @'/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql'
SQL> @'/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql'

* For the 3rd script pupbld.sql login as system the default password will be manager

SQL> conn system/manager
SQL> '/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/pupbld.sql'

*Again login as sys

SQL> connect sys/admin as sysdba

SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area  418484224 bytes
Fixed Size                  1336932 bytes
Variable Size             360712604 bytes
Database Buffers           50331648 bytes
Redo Buffers                6103040 bytes
Database mounted.
Database opened.

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
INFO      READ WRITE

Congratulation your database is created and now in open mode!!!!!!
Thanks Pushpjeet Cholkar.