21 Feb 2013

Floatting Currency in SQL Query

SQL> ---------------------------- USING FLOATING LOCAL CURRENCY (L)
/*
   START--->RUN-->REGEDIT
    HKEY LOCAL MACHINE-->>SOFTWARE-->>ORACLE-->>HOME0
    PRESS RIGHT CLICK ON RIGHT SIDE PORTION
    OPTION APPEAR WITH NEW-->>STRING_VALUE-->>NLS_CURRENCY
    THEN DOUBLE CLICK IT. PROVIDE THE Rs. IN VALUE OF DATA AND THEN PRESS OK
    CLOSE THE REGISTRY EDIT. AND RESTART THE COMPUTER TO SEE THE EFFECT
*/
SQL> SELECT SAL, TO_CHAR(SAL,'$99,999.99') FORM1,
  2* TO_CHAR(SAL,'L99,999.99') FROM EMP;

       SAL FORM1       TO_CHAR(SAL,'L99,999                                                        
---------- ----------- --------------------                                                        
       800     $800.00            Rs.800.00                                                        
      2600   $2,600.00          Rs.2,600.00                                                        
      1250   $1,250.00          Rs.1,250.00                                                        
      2975   $2,975.00          Rs.2,975.00                                                        
      1250   $1,250.00          Rs.1,250.00                                                        
      2850   $2,850.00          Rs.2,850.00                                                        
      2450   $2,450.00          Rs.2,450.00                                                        
      3000   $3,000.00          Rs.3,000.00                                                        
      5000   $5,000.00          Rs.5,000.00                                                        
      1500   $1,500.00          Rs.1,500.00                                                        
      1100   $1,100.00          Rs.1,100.00                                                        
       950     $950.00            Rs.950.00                                                        
      3000   $3,000.00          Rs.3,000.00                                                        
      1300   $1,300.00          Rs.1,300.00                                                        
      3500   $3,500.00          Rs.3,500.00                                                        

15 rows selected.

SQL>
 --- FOR TEMPORAY CHANGES
ALTER SESSION SET NLS_CURRENCY='£';

Session altered.

SQL>  SELECT SAL, TO_CHAR(SAL,'$99,999.99') FORM1,
  2   TO_CHAR(SAL,'L99,999.99') FROM EMP;

       SAL FORM1       TO_CHAR(SAL,'L99,999                                                        
---------- ----------- --------------------                                                        
       800     $800.00              £800.00                                                        
      2600   $2,600.00            £2,600.00                                                        
      1250   $1,250.00            £1,250.00                                                        
      2975   $2,975.00            £2,975.00                                                        
      1250   $1,250.00            £1,250.00                                                        
      2850   $2,850.00            £2,850.00                                                        
      2450   $2,450.00            £2,450.00                                                        
      3000   $3,000.00            £3,000.00                                                        
      5000   $5,000.00            £5,000.00                                                        
      1500   $1,500.00            £1,500.00                                                        
      1100   $1,100.00            £1,100.00                                                        
       950     $950.00              £950.00                                                        
      3000   $3,000.00            £3,000.00                                                        
      1300   $1,300.00            £1,300.00                                                        
      3500   $3,500.00            £3,500.00                                                        

15 rows selected.

Using Hijri Calendar in Oracle


select
to_char(sysdate,'fmday dd month yyyy','nls_calendar=''Arabic Hijrah''') Arab_Hijra,
to_char(sysdate,'fmday dd month yyyy','nls_calendar=''English Hijrah''') English_Hijra,
to_char(sysdate,'fmday dd month yyyy','nls_calendar=''gregorian''') Geor
from dual ;

In Arab Hijra we need to set
alter session set nls_calendar = 'Arabic Hijrah';
gives the names of the Hijrah months in Arabic

Regarding Arab Hijra we can used English Hijra.

NLS_CALENDAR

Property Description
Parameter type String
Syntax NLS_CALENDAR = "calendar_system"
Default value None
Modifiable ALTER SESSION
Range of values Any valid calendar format name
Basic No
NLS_CALENDAR specifies which calendar system Oracle uses. It can have one of the following values:
  • Arabic Hijrah
  • English Hijrah
  • Gregorian
  • Japanese Imperial
  • Persian
  • ROC Official (Republic of China)
  • Thai Buddha
    select
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''Arabic Hijrah''') Arab_Hijra,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''English Hijrah''') English_Hijra,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''gregorian''') Geor,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''Japanese Imperial''') Japan,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''Persian''') Persian,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''ROC Official''') China,
    to_char(:PF_FROM_DATE ,'fmday dd month yyyy','nls_calendar=''Thai Buddha''') Thai
    from dual;
 
ARAB_HIJRA ENGLISH_HIJRA GEOR JAPAN PERSIAN CHINA THAI
friday 5 ¿¿¿¿ ¿¿¿¿¿¿ 1424 friday 5 Rabi' Thani 1424 friday 6 june 2003 friday 6 6¿ 15 friday 16 Khordad 1382 friday 6 6¿ 92 friday 6 ¿¿¿¿¿¿¿¿ 2546

For example, suppose NLS_CALENDAR is set to "Japanese Imperial", the date format is "E YY-MM-DD". ("E" is the date format element for the abbreviated era name.) If the date is May 15, 1997, then the SYSDATE is displayed as follows:
SELECT SYSDATE FROM DUAL;
SYSDATE
--------
H 09-05-15

Iconic Buttons On Oracle Application Server

1. On Single OC4J PC (Stand Alone)


Design time Configuration
To display the icons in your Forms builder, modify your windows registry
HKEY_LOCAL_MACHINE\Software\Oracle\<Forms10 g_Home>\UI_ICON by entering the path of your GIF/JPG files for e.g. C:\MY_APP\ICONS. And create ui_icon_extension and give it value GIF

Extracting Icons From frmall.jar
1.  Search the frmall.jar file
2.  Right click on the file choose option Extract Files and define the folder where you want to extracts the icons.

Runtime Configuration
1) Creating Jar file
      i) Once you are ready with your GIF files or JPG files, create a folder called ICONS. You can create this folder anywhere. For e.g.   you can create ICONS folder on a C drive under root directory or as    a sub-folder under any folder.
      ii) Assuming you have created ICONS folder as a root folder on C drive, now copy all your GIF files in this folder.
      iii) Go to the DOS prompt and enter cd\
iv) Set the Path on Command Prompt,
 C:\>path=d:\devsuitehome_1\jdk\bin

       v) At C:\ prompt enter the following command to create Java
      Archive File (JAR) called my_icons Jar -cvf my_icons.jar icons
      C:\>jar -cvf icons.jar C:\Source6i_Form\icons

      vi) Copy this file in <Forms10g_Home>\Forms\Java folder with Icons folder. Please remember that having the name of the folder holding GIF/JPG files as ICONS is very important. Because if the folder name is something else, icons will not be displayed in your form at run time. This reason is not mentioned anywhere in Oracle's documentation. I learnt about this through metalink  (Service Request no. 6602276.993) after struggling for more than one day to display the icons.

2) Modify REGISTRY.DAT file
      i) Open this file located in
      <Forms10g_Home>\forms\java\oracle\forms\reg istry folder.
      ii) Append the existing parameter default.icons.iconpath as       follows:
      DEFAULT.ICONS.ICONPATH=ICONS/
iii) If you are going to use GIF files as image files for icons, then leave the existing parameter default.icons.iconextension=gif as it is. If you want to use JPG files instead of GIF files, replace GIF with JPG or JPG with GIF, Default value of this parameter is GIF, so do not change if your icons extension are gif.     Parameter values are as shown below:
      DEFAULT.ICONS.ICONEXTENSION=GIF
3) Modify FORMSWEB.CFG file,This file exists under <Forms10g_Home>\Forms\Server folder. Append the following existing parameters:
      i) imagebase=codebase
      ii) archive_jini=frmall_jinit.jar,frmwebutil.jar,jacob            .jar,my_icons.jar
4) Modiyf Default.Env file, this file exists under <Forms10g_Home>\Forms\Server. Append the following Parameter
CLASSPATH=D:\DevSuiteHome_1\j2ee\OC4J_BI_Forms\applications\formsapp\formsweb\WEB-INF\lib\frmsrv.jar;D:\DevSuiteHome_1\jlib\repository.jar;D:\DevSuiteHome_1\jlib\ldapjclnt10.jar;D:\DevSuiteHome_1\jlib\debugger.jar;D:\DevSuiteHome_1\jlib\ewt3.jar;D:\DevSuiteHome_1\jlib\share.jar;D:\DevSuiteHome_1\jlib\utj.jar;D:\DevSuiteHome_1\jlib\zrclient.jar;D:\DevSuiteHome_1\reports\jlib\rwrun.jar;D:\DevSuiteHome_1\forms\java\frmwebutil.jar;D:\DevSuiteHome_1\forms\java\icons.jar

2. On Application Server. 
Step 1
---
1.  Create one folder on E:\PQGTL
2.  Copy all object libraries and Plsql Libraries in.
3.  Create new folder name EXECUTABLE contain all fmx and rep files
4.  Create new folder name Forms10g contain FMB and RDF Files
Step 2
1.  Creating Jar file
   i) Once you are ready with your GIF files or JPG files, create a folder called ICONS. You can create this folder anywhere. For e.g.      you can create ICONS folder on a C drive under root directory or as       a sub-folder under any folder.
      ii) Assuming you have created ICONS folder as a root folder on C drive, now copy all your GIF files in this folder.
      iii) Go to the DOS prompt and enter cd\
iv) Set the Path on Command Prompt,
 e:\>path= E:\oracle\FRHome_1\jdk\bin
v) At C:\ prompt enter the following command to create Java
Archive File (JAR) called my_icons Jar -cvf my_icons.jar icons
      e:\>jar -cvf icons.jar E:\PQGTL\icons

2.  Now copy the icons.jar and icon folder on E:\oracle\FRHome_1\forms\java
3.  Apply the following changes in E:\oracle\FRHome_1\forms\java\oracle\forms\registry\registry.dat
Open in notepad
Add following Parameters
default.icons.iconpath=icons/
default.icons.iconextension=gif
4.  Apply the following changes in formsweb.cfg located in E:\oracle\FRHome_1\forms\server
# Forms runtime argument: which form module to run
#form=test.fmx
form=login_win.fmx
# Forms runtime argument: database connection details
userid=pqgtl/pqgtl@tims
# Forms runtime argument: whether to run in debug mode
debug=no
# Forms runtime argument: host for debugging
host=http://pq-hrsvr:18100
# HTML page title
pageTitle=Pak Qatar General & Family Takaful Limited.
# Forms applet parameter
#imageBase=DocumentBase
imageBase=codeBase
# Forms applet parameter
width=1200
# Forms applet parameter
height=800
# Forms applet parameter
separateFrame=true
# Forms applet parameter
splashScreen=false
# Forms applet archive setting for JInitiator
archive_jini=frmall_jinit.jar,frmall.jar,icons.jar
5.  Apply the following changes in Default.env file, its also find on same location of formsweb.cfg
#
FORMS_PATH=E:\oracle\FRHome_1\forms;E:\PQGTL;E:\PQGTL\Executable\; E:\PQGTL\Reports;
#
CLASSPATH=E:\oracle\FRHome_1\j2ee\OC4J_BI_Forms\applications\formsapp\formsweb\WEB-INF\lib\frmsrv.jar;E:\oracle\FRHome_1\jlib\repository.jar;E:\oracle\FRHome_1\jlib\ldapjclnt10.jar;E:\oracle\FRHome_1\jlib\debugger.jar;E:\oracle\FRHome_1\jlib\ewt3.jar;E:\oracle\FRHome_1\jlib\share.jar;E:\oracle\FRHome_1\jlib\utj.jar;E:\oracle\FRHome_1\jlib\zrclient.jar;E:\oracle\FRHome_1\reports\jlib\rwrun.jar;E:\oracle\FRHome_1\forms\java\frmwebutil.jar;E:\oracle\FRHome_1\forms\java\icons.jar

6.  Press Start à Run à Type REGEDIT
HKEY LOCAL MACHINEàSOFTWAREàORACLEàKEY_FRHOME1
DOUBLE CLICK THE FORMS_PATH And add the following values in existing values
E:\oracle\FRHome_1\forms; E:\PQGTL;E:\PQGTL\Executable;

7.  Add the following value in REPORTS_PATH with existing values of same screen
E:\PQGTL\Reports;

8.  Find the TNSNAMES.ORA file, and add the particular data links.
TIMS =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.3.80)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = pqgtl)
    )
  )

9.  Configuring The Report Server
            i.     In Formsweb.cfg File, change the following parameter if its value is TRUE.
# application-specific section to enable Single Sign-On for that application.
ssoMode=false
          ii.     Remove the following parameter value in rep_app_server.conf file located in E:\oracle\FRHome_1\Reports\conf folder.
 <!--security id="rwSec" class="oracle.reports.server.RWSecurity">
      <property name="securityUserid" value="%PORTAL_DB_USERNAME%/%PORTAL_DB_PASSWORD%@%PORTAL_DB_TNSNAME%" confidential="yes" encrypted="no"/>
      <property name="oidEntity" value="%REPORTS_OID_ENTITY%"/>
   </security-->
        iii.     Change the Paramater in rwservelet.properties, file in wordpad. This file located in  E:\oracle\FRHome_1\Reports\conf folder. Palce # Sign on
            #SINGLESIGNON=YES

From Oracle To Excel

1. Create the form with Emp Data block in Tabular Style

2. Create Control Block having One Push Button

   Properties                Push_Button1

   Name                        PB_BROWSE           
   Key board navigation            no               
   mouse navigation            no               
   Label                    Export

3.Write Following Code on Above button (When Button Press)Trigger
  DECLARE
        AppID   PLS_INTEGER;
        ConvID   PLS_INTEGER;
        last_rec number:=0;
    cntr number:=0;
        c number:=0; lno number:=1;
BEGIN   
         go_block('emp');
         last_record;
         cntr :=to_number(:system.cursor_record);

    /* Start Microsoft Excel with spreadsheet emp.xls loaded. */
--        AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe C:\emp.xls',
--          AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe',
--            DDE.APP_MODE_MaxiMIZED);
        ConvID:= DDE.Initiate('EXCEL', 'book1');
        DDE.Poke(ConvID, 'R1C1', 'S.No.', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C2', 'Emp_ID', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C3', 'Name', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C4', 'Job', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C5', 'Mgr_ID', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C6', 'Join Date', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C7', 'Salary', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C8', 'Commission', DDE.CF_TEXT, 1000);
        DDE.Poke(ConvID, 'R1C9', 'Dept_ID', DDE.CF_TEXT, 1000);
go_block('emp');
   if :global.lno<>0 then
        lno:=:global.lno;
   end if;
  
  for i in 1..cntr loop
          c:=c+1; lno:=lno+1;
         go_record(c);
         DDE.Poke(ConvID, 'R'||lno||'C1', c, DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C2', :empno, DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C3', :ename, DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C4', :job,   DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C5', nvl(:mgr,0), DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C6', to_char(:hiredate,'dd/mm/rrrr'), DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C7', :sal, DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C8', nvl(:comm,0), DDE.CF_TEXT, 1000);
         DDE.Poke(ConvID, 'R'||lno||'C9', :deptno, DDE.CF_TEXT, 1000);
   end loop;
   :global.lno:=lno;
      DDE.App_Focus(AppID);
 End;

4.Save and Compile then run the form               

20 Feb 2013

Steps Of 10g Webutil

Steps Of 10g Webutil

plz copy webutil object library and pll in forms folder of oracle developer home directory.

Webutil Steps
=========================

1. On drive C create a folder name Webutil.
Extract the jacob_18.zip file into C:\Webutil_Final Folder.

2. Switch to Command Prompt, and perform following:
C:\>cd webutil
C:\>cd webutil_final
C:\Webutil_Final>COPY JACOB.JAR D:\oracle\DevSuiteHome_1\forms\java
C:\Webutil_Final>COPY JACOB.DLL D:\oracle\DevSuiteHome_1\forms\webutil
C:\Webutil_Final>COPY calendar90.pll D:\oracle\DevSuiteHome_1\forms
C:\Webutil_Final>COPY stndrd20.OLB D:\oracle\DevSuiteHome_1\forms

3. On Dos Prompt Sign frmwebutil.jar and jacob.jar with following commands
C:\>set path=D:\oracle\DevSuiteHome_1\jdk\bin;%PATH%

Sign the files by using
C:\>D:\oracle\DevSuiteHome_1\forms\webutil\sign_webutil D:\oracle\DevSuiteHome_1\forms\java\frmwebutil.jar

Output
Generating a self signing certificate for key=webutil2...
...successfully done.

.
Backing up D:\oracle\DevSuiteHome_1\forms\java\frmwebutil.jar as D:\oracle\DevSu iteHome_1\forms\java\frmwebutil.jar.old...
1 file(s) copied.
Signing D:\oracle\DevSuiteHome_1\forms\java\frmwebutil.jar using key=webutil2...
...successfully done.

C:\>D:\oracle\DevSuiteHome_1\forms\webutil\sign_webutil D:\oracle\DevSuiteHome_1\forms\java\jacob.jar

Output
Generating a self signing certificate for key=webutil2...
keytool error: java.lang.Exception: Key pair not generated, alias already exists
.
There were warnings or errors while generating a self signing certificate. Please review them.
.
Backing up D:\oracle\DevSuiteHome_1\forms\java\jacob.jar as D:\oracle\DevSuiteHome_1\forms\java\jacob.jar.old...
1 file(s) copied.
Signing D:\oracle\DevSuiteHome_1\forms\java\jacob.jar using key=webutil2...
...successfully done.


4. Now open the SQL Session connecting with SYS user, and create a user named WEBUTIL and Password is ORACLE.
SQL> CREATE USER WEBUTIL IDENTIFIED BY ORACLE
2 DEFAULT TABLESPACE USERS
3 TEMPORARY TABLESPACE TEMP;

User created.

SQL> GRANT CONNECT, CREATE PROCEDURE, CREATE PUBLIC SYNONYM TO WEBUTIL;

Grant succeeded.

SQL> CONN WEBUTIL/ORACLE
Connected.
USER is "WEBUTIL"
linesize 100
pagesize 100
long 80
SQL> @D:\Webutil_Final\create_webutil_db.sql

Package created.


Package body created.
SQL> CREATE PUBLIC SYNONYM WEBUTIL_DB FOR WEBUTIL.WEBUTIL_DB;

Synonym created.
SQL> CONN SYS/ORACLE AS SYSDBA
Connected.

SQL> GRANT EXECUTE ON WEBUTIL_DB TO PUBLIC;

Grant succeeded.

5.Modify the DEFAULT.ENV file, you can find default.env file at D:\oracle\DevSuiteHome_1\forms\server\Default.env
append the following path in CLASSPATH entry
;d:\oracle\DevSuiteHome_1\jdk\jre\lib\rt.jar
append the following path in FORMS_PATH
;D:\oracle\DevSuiteHome_1\forms\webutil

6.Modify the FORMSWEB.CFG file, you can find this file at D:\oracle\DevSuiteHome_1\forms\server\formsweb.cfg
add:
archive_jini=frmall_jinit.jar,frmwebutil.jar,jacob.jar
archive=frmall.jar
also add :
[webutil]
WebUtilArchive=frmwebutil.jar,jacob.jar,f90all.jar
WebUtilLogging=off
WebUtilLoggingDetail=normal
WebUtilErrorMode=Alert
WebUtilDispatchMonitorInterval=5
WebUtilTrustInternal=true
WebUtilMaxTransferSize=16384
baseHTMLjinitiator=webutiljini.htm
baseHTMLjpi=webutiljpi.htm
archive_jini=frmall_jinit.jar
archive=frmall.jar,f90all.jar
lookAndFeel=oracle
7.Modify the WEBUTIL.CFG file locate at the same place where you found the FORMSWEB.CFG file and change the
following
#transfer.database.enabled=FALSE (default value)
transfer.database.enabled=TRUE
#transfer.appsrv.enabled=FALSE (default value)
transfer.appsrv.enabled=TRUE

8. Logon scott user in sqlplusw.
SQL> DESC EMP
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)

SQL> CREATE TABLE EMP_IMAGE
2 (EMPNO NUMBER(04) PRIMARY KEY REFERENCES EMP(EMPNO),
3* IMAGE BLOB);

Table created.

SQL> INSERT INTO EMP_IMAGE
2 (EMPNO)
3* SELECT EMPNO FROM EMP;

SQL> COMMIT;

Commit complete.

9. Start OC4J instance,Open the Form Builder, and connect with WEBUTIL/ORACLE@orcl, Open the WEBUTIL.PLL file, located at
D:\oracle\DevSuiteHome_1\forms folder, compile all (Shift+Control+K), and genearte to PLX. Then Open the WEBUTIL.OLB, and
Subclass object to the form. Now attache the webutil.pll library and remove the path.


10.Create a new form module as Master&Detail using EMP and EMP_IMAGE data block.
After completing the wizard switch to Object naviagtor->Object Library->Open Webutil.olb which are located on
D:\oracle\DevSuiteHome_1\forms folder. Subclass the following, which are located in object library
WEBUTILCONFIG into Parameter Node.
WEBUTIL into Object Group Node.

11. Now attached the Pl Library WEBUTIL.PLL file, located at D:\oracle\DevSuiteHome_1\forms folder, and Press Yes button
when message appeared after pressing attach button.
PUSH_BUTTON1 PUSH_BUTTON2
NAME GET_FILE_NAME UPLOAD_DB


12. Now create One Text item, and Two Push buttons on WEBUTIL data block, and choose the Canvas where EMP Block are shown.

13. Apply following codes.

At form level
==================
WHEN NEW FORM INSTANCE
declare
fake_timer TIMER;
begin

--
-- Purpose of the fake timer is the we cannot call webutil in this trigger since the
-- beans have not yet been instantiated. If we put the code in a when-timer-expired-trigger
-- it means that this timer will not start running until Forms has focus (and so the webutil
-- beans will be instantiated and so call canbe made.
--
fake_timer:= CREATE_TIMER('webutil',100,NO_REPEAT);
end;

WHEN TIMER EXPIRED
:global.user_home := webutil_clientinfo.get_system_property('user.home');


At Program Unit Node
=====================
PROCEDURE UPLOAD_DB IS
l_success boolean;
BEGIN
l_success := webutil_file_transfer.Client_To_DB_with_progress
(clientFile => :file_name
,tableName => 'EMP_IMAGE'
,columnName => 'IMAGE'
,whereClause => 'EMPNO ='||:EMP.EMPNO
,progressTitle => 'Upload to Database in progress'
,progressSubTitle=> 'Please wait'
,asynchronous => false
,callbackTrigger => null
);
if l_success then
message('File uploaded successfully into the Database');
else
message('File upload to Database failed'||SQLERRM);
end if;

exception
when others then
message('File upload failed: '||sqlerrm);
END;

When Button Pressed Trigger
============================
On GET_FILE_NAME Push Button

declare
l_filename varchar2(200);
begin
l_filename := client_get_file_name(directory_name => :global.user_home
,file_name => null
,file_filter => null
,message => null
,dialog_type => null
,select_file => null
);
:file_name := l_filename;
end;

On UPLOAD_DB Push Button
begin
upload_db;
exception
when others then
message('File upload failed: '||sqlerrm);

end;


14.Under Edit->Preferences->Runtime in Forms Builder, click on "Reset to Default" if the "Application Server URL" is empty.Then append "?config=webutil" at the end, so you end up with a URL of the form http://server:port/forms/frmservlet?config=webutil

ERWIN Steps

------------------------------------------ ERWIN STEPS --------------------------------------
"______" SOLID LINE IS THE IDENTIFICATION OF IDENTIFYING RELATION.
"------" DOTTED LINE IS THE IDENTIFICATION OF UN-IDENTIFYING RELATION.
THE ENVIORNMENT OF ERwin IS LOGICAL(BY DEFAULT).
AT THE TIME OF CREATION OF TABLE IN ERwin DONOT INCLUDE THOSE COLUMNS
WHICH ARE REFRENCED FROM OTHER TABLES.THEY WILL BE AUTO GENERATED(FK).
PRESS ALT+N TO CREATE NEW FORM/ATTRIBUTE.

----------------------------FOR CREATING SELF-JOIN COLUMNS-------------
1- MUST BE IN LOGICAL MODE
2- SELECT THE RELATION AND DOUBLE CLICK IT. ITS ACTIVE THE RELATIONSHIP EDITOR.
3- CHOOSE ROLE NAME RI ACTION TAB.
4- DEFINE COLUMN NAME IN ROLE NAME FIELD, PRESS OK NOW FOREIGN KEY IS CREATED.



---------------------------FOR CREATING THE UNIQUE KEY COLUMN----------
1- MUST BE IN LOGICAL MODE.
2- SELECT THE TABLE AND DOUBLE CLICK ON IT CHOOSE THE KEY GROUP TAB.
3- PRESS KEY GROUP MEMBERSHIR BUTTON KEY GROUP ACTIVE.
4- NOW PRESS THE NEW BUTTON, NEW GROUP KEY EDITOR ACTIVE.
5- APPLY THE KEY GROUP NAME AND PRESS OK.
6- MOVE THE COLUMN NAME IN THE KEY GROUP MEMBERSHIP COLUMN PRESS OK TO COMPLETE THE TASK.


------------------------FOR APPLYING THE DEFAULT VALUES---------------
1- MUST BE IN PHYSICAL MODE.
2- PRESS DEFAULT BUTTON IN COLUMN EDITOR, DEFAULT EDITOR ACTIVE.
3- PRESS NEW BUTTON AND APPLY THE NAME AND PRESS OK.
4- APPLY THE DEFAULT VALUE/EXPRESSION IN SERVER VALUE TEXT FIELD.
5- AFTER APPLY PRESS OK TO END THE TASK AGAIN PRESS OK BUTTON TO COMPLETE THE TASK.


----------------------FOR APPLYING CHECK VALUES------------------------
1- MUST BE IN PHYSICAL MODE.
2- PRESS VALID BUTTON ON COLUMN EDITOR SCREEN.
3- PRESS NEW BUTTON ON VALID ROLE EDITOR SCREEN.
5- APPLY THE NAME AND PRESS OK KEY.
6- DEFINE VALUE ON ORACLE CHECK CONDITION FIELD THEN PRESS OK.
7- PRESS OK TO COMPLETE THE TASK.


-----------------------FOR CREATING FORWARD ENGINERRING----------------
AFTER DESIGN THE ENTITES AND RELATION FOLLOW THE FOLLOWING STEP
1- CHOOSE PHYSICAL MODE.
2- CLICK ON MENU OPTION TASK-->FORWARD ENGINERRING.
3- SELECT REQUIRED OPTION FROM 'ORACLE SCHEMA GENERATION' SECTION AS SHOWN IN THE HANDOUT NO# 7-14.

-------------------------------YOUR SELECTION-------------------------

SCHEMA ---> NONE
VIEW ---> NONE
TABLE ---> CREATE TABLE,DROP TABLE,TABLE CHECK
COLUMN ---> CHECK CONSTRAINT
PHYSICAL ORDER
DEFAULT VALUE
INDEX ---> NONE
REFRENTIAL INTEGRITY ---> PRIMARY KEY
CREATE/PK
FOREIGN KEY
CREATE/FK
ON DELETE(UNSELECT IT)
CREATE/UK
TRIGGER ---> NONE
OTHER OPTIONS ---> CONSTRAINT NAME

Uploading Data From Excel to Oracle Datbase(Through Forms 6i)


1. Create the form with Emp Data block in Tabular Style
2. Create Control Block having Two Push Buttons

   Properties            Push_Button1            Push_Button2
   Name                PB_BROWSE            PB_IMPORT
   Key board navigation        no                no
   mouse navigation        no                no
   Label            Browse                Import

3. Create two Display Item in Control Block having following Properties
   Properties            Display_Item1            Display_Item2
   Name                v_line_buf            file_name
   Data Type            Character            Character
   Maximum Length        2000                30


4. Create Following Function on Program Unit
FUNCTION DATA_VALID (EMP_ID IN NUMBER) RETURN BOOLEAN IS
V_EMPNO NUMBER;
BEGIN
    SELECT EMPNO INTO V_EMPNO FROM EMP
    WHERE EMPNO=EMP_ID;
    RETURN(FALSE);
EXCEPTION
    WHEN NO_dATA_FOUND THEN
  RETURN(TRUE);
END;

5. Create Following Procedure on Program Unit
PROCEDURE SHOW_MSG (p_text varchar2, p_title varchar2 default 'Message', pms_type out number) IS
msgbox number;
BEGIN
    set_alert_button_property('msg_alert',alert_button1, label,'Add on Existing');
    set_alert_button_property('msg_alert',alert_button2, label,'Create New');
  set_alert_property('msg_alert',title,P_title);
    set_alert_property('msg_alert',alert_message_text,p_text);
    msgbox :=show_alert('msg_alert');
    if msgbox=alert_button1 then
        pms_type:=1;
    elsif msgbox=alert_button2 then
        pms_type:=2;
    end if;
   
END;

6. Create an Alert and name them Msg_Alert

7. Write following code on Browse Button (When Button Pressed)

declare
    v_path    varchar2(1000);
begin
 v_path := get_file_name(file_filter=> 'CSV Files (*.csv)|*.csv|'
                ||'XLS Files (*.xls)|*.xls|'
                ||'TXT Files (*.txt)|*.txt|');   
 :file_name:= v_path;
exception
    when others then null;
end;

8.Write the following code on Import Button (When Button Pressed)
Declare
in_file     Text_IO.File_Type;
linebuf     VARCHAR2(20000);
filename     VARCHAR2(30);
CHK         VARCHAR2(1000);
LOC_VALUE     VARCHAR2(1000);
SNO         NUMBER:=0;
AA         NUMBER:=0;
V_EMPNO     EMP.EMPNO%TYPE;
V_ENAME     EMP.ENAME%TYPE;
V_JOB       EMP.JOB%TYPE;
V_MGR       EMP.MGR%TYPE;
V_HIREDATE     EMP.HIREDATE%TYPE;
V_SAL        EMP.SAL%TYPE;
V_COMM        EMP.COMM%TYPE;
V_DEPTNO    EMP.DEPTNO%TYPE;
V_CURR            NUMBER:=0;
v_ret_no          number:=0;

BEGIN
go_block('emp');
if :empno is not null then
    show_msg('What You Want To Do','Alert',v_ret_no);
    if v_ret_no=1 then
        next_record;
    elsif v_ret_no=2 then
        clear_block(no_validate);
    end if;
end if;

in_file:=Text_IO.Fopen(:file_name,'r');
LOOP
    AA:=AA+1;
Text_IO.Get_Line(in_file,linebuf);
IF AA>1 THEN
  :V_LN_BUFF    :=LINEBUF;
  V_EMPNO       :=RTRIM(SUBSTR(:V_LN_BUFF,1,4));
  v_curr       :=INSTR(LINEBUF,',',1,1)+1;
  V_Ename       :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,10),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,2)+1;
  V_JOB        :=  RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,10),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,3)+1;
  V_MGR            :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,10),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,4)+1;
  V_HIREDATE       :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,15),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,5)+1;
  V_SAL            :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,10),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,6)+1;
  v_COMM           :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,INSTR(SUBSTR(:V_LN_BUFF,V_CURR,10),',',1,1)-1));
  v_curr       :=INSTR(LINEBUF,',',1,7)+1;
  V_DEPTNO         :=RTRIM(SUBSTR(:V_LN_BUFF,V_CURR,10));
  IF DATA_VALID(V_EMPNO) THEN
      :EMPNO:=V_EMPNO; :ENAME:=V_ENAME; :JOB:=V_JOB; :MGR:=V_MGR;
      :HIREDATE:=V_HIREDATE; :SAL:=V_SAL; :COMM:=V_COMM; :DEPTNO:=V_DEPTNO;
  END IF;
 
     
END IF;
next_record;
END LOOP;
FIRST_RECORD;
EXCEPTION
    WHEN no_data_found THEN
  Text_IO.Fclose(in_file);
  --COMMIT;
  WHEN OTHERS THEN
  NULL;
  previous_record;
END;

9 Save and Run the Form