Quantcast
Channel: Fox Infotech
Viewing all 231 articles
Browse latest View live

Log DBMS_OUTPUT.Put_Line Output Into Table In Oracle With DBMS_OUTPUT.Get_Lines

$
0
0
Dbms_Output.Put_Line is a good way to debug PLSQL code easily by getting print the required values to track where the things are going wrong. But if you want to log that print data into a table to analyze it any time, you can do this with Dbms_Output.Get_Lines procedure.
dbms_output.put_line output to table with dbms_output.get_lines
The example is given below to log Dbms_Output.Put_Line print values into a table in Oracle. Below is the structure of the table which is used in this example named "outputlog" or you can create your own as per your requirement.

CREATE TABLE OUTPUTLOG
(
  CHAR_COL  VARCHAR2(1000 BYTE),
  PROCNAME  VARCHAR2(100 BYTE),
  LOG_DATE  DATE
);

And the following is the PLSQL anonymous block example to log the output:

DECLARE
   n      NUMBER := 100;
   vcol   DBMS_OUTPUT.chararr;
BEGIN
   DBMS_OUTPUT.enable (100000);
   --- do something here
   DBMS_OUTPUT.put_line ('first line');
   --- do somthing here 
   DBMS_OUTPUT.put_line ('second line');
   --- do something here
   DBMS_OUTPUT.put_line ('third line');

   --- get the output into vcol array
   DBMS_OUTPUT.get_lines (vcol, n);

   FOR i IN 1 .. n
   LOOP
      INSERT INTO outputlog (char_col, procname, log_date)
          VALUES (vcol (i), 'anonymous', SYSDATE);
   END LOOP;

   COMMIT;
END;

Note I assing the value of 100 to n variable and the number of output lines are only 3 so it will loop and record only 3 times because it is having only 3 rows in output, but if the output buffer is having rows more than 100 than it will log only 100 rows, so adjust this variable value accordingly.


Set Font Properties On Mouse Hover Of Push Button And Text Items At Run time In Oracle Forms

$
0
0
Change the font size and weight of text items and push buttons on mouse hover in Oracle Forms.

An example is given below to highlight the text in text items and highlight the label of a push button item at run time whenever mouse enters or leave, by using set_item_property and get_item_property command to set the Font_Size and Font_Weight property.

The code is written on When-Mouse-Enter trigger and on When-Mouse-Leave trigger.

The following is the screen shot of this example:


This form can be downloaded from the following link Mousehover.fmb

The code is written on the When-Mouse-Enter trigger at block level is:

declare
mitem varchar2(100) := :system.mouse_item;
begin
if get_item_property(mitem, item_type) in ('BUTTON', 'TEXT ITEM') THEN
  set_item_property(mitem, font_size, get_item_property(mitem, font_size) + 2);
  set_item_property(mitem, font_weight, FONT_BOLD);
END IF;
end;

The code is written on the When-Mouse-Leave trigger at block level is:

declare
mitem varchar2(100) := :system.mouse_item;
begin
if get_item_property(mitem, item_type) in ('BUTTON', 'TEXT ITEM') THEN
  set_item_property(mitem, font_size, get_item_property(mitem, font_size) - 2);
  set_item_property(mitem, font_weight, FONT_LIGHT);
END IF;
end;

Know How To Use ID_NULL Function To Search An Object In Oracle Forms

$
0
0
ID_NULL built in function is used to find an object in Oracle Forms and returns a BOOLEAN value that indicates whether the object ID is available. 

Below is the Syntax of ID_Null function:

FUNCTION ID_NULL
(Objectid);

Where Objectid can be one of the following objects: Alert, Block, Canvas, Editor, FormModule, GroupColumn, Item, LOV, MenuItem, ParamList, RecordGroup, Relation, REPORT_OBJECT, TabPage, Timer, Viewport, VisualAttribute and Window.

Use ID_NULL when you want to check for the existence of an object created dynamically at runtime. For example, if a specific record group already exists, you will receive an error message if you try to create that record group. To perform this check, follow this general process: Use the appropriate FIND_ Built-in to obtain the object ID. Use ID_NULL to check whether an object with that ID already exists. If the object does not exist, proceed to create it. 

See Examples for ID_NULL with the following link: 



Change An Item Property Using Set_Item_Property In Oracle Forms

$
0
0
Set_Item_Property is used to change an object's settings at run time. Note that in some cases you can get but not set certain object properties. 

The following are Syntax of Set_Item_property command:

SET_ITEM_PROPERTY
(item_id ITEM,
property NUMBER,
value VARCHAR2);

SET_ITEM_PROPERTY
(item_name VARCHAR2,
property NUMBER,
value VARCHAR2);

SET_ITEM_PROPERTY
(item_id ITEM,
property NUMBER,
x NUMBER);

SET_ITEM_PROPERTY
(item_name VARCHAR2,
property NUMBER,
x NUMBER);

SET_ITEM_PROPERTY
(item_id ITEM,
property NUMBER,
x NUMBER,
y NUMBER);

SET_ITEM_PROPERTY
(item_name VARCHAR2,
property NUMBER,
x NUMBER,
y NUMBER);

Built-in Type unrestricted procedure

Where item_id is the unique ID that Oracle Forms assigned to the object when it created it. Use the FIND_ITEM Built-in to return the ID to a variable with datatype of ITEM.

Where item_name is the name you gave the item when you created it. Datatype is VARCHAR2.

You can find the examples of Set_Item_Property command through the following links:



Change Or Set Report Object Property At Run Time In Oracle Forms Using Set_Report_Object_Property Command

$
0
0
Sets the Report object property at run time in Oracle Forms of an report object.

The following are the Syntax of Set_Report_Object_Property:

PROCEDURE SET_REPORT_OBJECT_PROPERTY
(report_id REPORT_OBJECT,
property NUMBER,
value VARCHAR2
);

PROCEDURE SET_REPORT_OBJECT_PROPERTY
(report_name VARCHAR2,
property NUMBER,
value VARCHAR2
);

PROCEDURE SET_REPORT_OBJECT_PROPERTY
(report_id REPORT_OBJECT,
property NUMBER,
value NUMBER
);

PROCEDURE SET_REPORT_OBJECT_PROPERTY
(report_name VARCHAR2,
property NUMBER,
value NUMBER
);

See the example of Set_Report_Object_Property with the following link:
http://www.foxinfotech.in/2012/11/calling-running-report-in-oracle-forms.html

Parameter report_id specifies the unique ID of the report. You can get the report ID for a particular report using FIND_REPORT_OBJECT . 

Parameter report_name specifies the unique name of the report. 

property should be one of the following constants:

 REPORT_EXECUTION_MODE: The report execution mode, either BATCH or RUNTIME 

REPORT_COMM_MODE: The report communication mode, either SYNCHRONOUS or ASYNCHRONOUS 

 REPORT_DESTYPE: The report destination type, either PREVIEW, FILE, PRINTER, MAIL, CACHE or SCREEN 

 One of the following strings: 

 REPORT_FILENAME: The report filename 

 REPORT_SOURCE_BLOCK: The report source block name 

 REPORT_QUERY_NAME: The report query name 

 REPORT_DESNAME: The report destination name 

 REPORT_DESFORMAT: The report destination format 

 REPORT_SERVER: The report server name 

 REPORT_OTHER: The other user-specified report properties value  

 REPORT_EXECUTION_MODE: Value must be BATCH or RUNTIME 

 REPORT_COMM_MODE: Value must be SYNCHRONOUS or ASYNCHRONOUS 

REPORT_DESTYPE: Value must be PREVIEW, FILE, PRINTER, MAIL, CACHE, SCREEN, FTP, WEBDAV, ORACLEPORTAL, ORACLEWIRELESS, SECUREPDF, or BLOBDESTINATION, PLUGDESTYPE 

 One of the following strings: 

 REPORT_FILENAME: Value must be of type VARCHAR2 

 REPORT_SOURCE_BLOCK: Value must be of type VARCHAR2 

 REPORT_QUERY_NAME: Value must be of type VARCHAR2 

 REPORT_DEST_NAME: Value must be of type VARCHAR2 

 REPORT_DEST_FORMAT: Value must be of type VARCHAR2 

 REPORT_SERVER: Value must be of type VARCHAR2 

 REPORT_OTHER: Value must be of type VARCHAR2 

Know How And When To Use System.Message_Level To Control Messages In Oracle Forms

$
0
0
SYSTEM.MESSAGE_LEVEL is used to control the messages that end users see when they use the Oracle Form's application. You can control to not to display simple warning messages or even error messages to display to users. The following  are message severity levels: 0, 5, 10, 15, 20, or 25. The default value is 0. 

SYSTEM.MESSAGE_LEVEL can be set to either a character string or a number. The values assigned can be any value between 0 and 25, but values lower than 0 or higher than 25 will generate an error. 

There are six levels of message severity that you can affect, listed here in increasing order of severity. 

0  All types of messages from the other levels of severity. 
5  Reaffirms an obvious condition.  
10 Indicates that the end user has made a procedural mistake. 
15 Declares that the end user is attempting to perform a function for which the form is not designed. 
20 Indicates a condition where the end user cannot continue an intended action due to a problem with a trigger or another outstanding condition. 
25 Indicates a condition that could result in the form performing incorrectly. 
>25 Indicates a message severity level that you cannot suppress via the SYSTEM.MESSAGE_LEVEL system variable. 

During a Runform session, Oracle Forms suppresses all messages with a severity level that is the same or lower (less severe) than the indicated severity level. 

Assign a value to the SYSTEM.MESSAGE_LEVEL system variable with standard PL/SQL syntax: 

:System.Message_Level := value; 

The legal values for SYSTEM.MESSAGE_LEVEL are 0, 5, 10, 15, 20,and 25. Oracle Forms does not suppress prompts or vital error messages, no matter what severity level you select. 

Assume that you want Oracle Forms to display only the most severe messages (level 25). The following Pre-Form trigger suppresses all messages at levels 20 and below. :System.Message_Level := '20'; 

Check the following link for an example of System.Message_Level Refresh and Updating Form Screen At Run Time

Perform Cut Copy Paste Operations Using Cut_Region Copy_Region Paste_Region Commands In Oracle Forms

$
0
0
You can do Select, Cut, Copy and Paste operations on text items in Oracle Forms using Select_All, Cut_Region, Copy_Region and Paste_Region commands through right click popup menu.

In this example I created a popup menu which is associated with the both text items and user will do right click on each text item to perform copy paste operations. Below is the screen shot for this example:


I am sharing this Demo FMB file for the reference which you can download through the following link CopyPaste.FMB

Created a popup menu in object navigator and associated the code to each menu option:


For Select_All menu option -- Select_All;
For Cut menu option -- Cut_Region;
For Copy menu option -- Copy_Region;
For Paste menu option -- Paste_Region;
For Paste Sel Txt To --> the following code:

copy_region;
go_item('tgt');
paste_region;

Know How To Use Check Box Mapping Of Other Values Property In Oracle Forms

$
0
0
Check Box Mapping of Other Values specifies how any fetched or assigned value that is not one of the pre-defined "checked" or "unchecked" values should be interpreted. Means suppose you have specified Value When Checked property to 'Y' and Valued When Unchecked property to 'N' and the value is coming from database is 'X' then 'Check Box Mapping of Other Values' property handles to how the check box will behave in that condition, means it would be unchecked or checked or disabled.

Default value of this property is:

NOT ALLOWED

The following settings are valid for this property:

Not Allowed  
Any queried record that contains a value other than the user-defined checked and unchecked values is rejected and no error is raised. Any attempt to assign an other value is disallowed.  

Checked  
Any value other than the user-defined unchecked value is interpreted as the checked state.

Unchecked
Any value other than the user-defined checked value is interpreted as the unchecked state.

See the examples of Check Box from the following links:

http://www.foxinfotech.in/2014/12/limiting-to-select-only-5-check-boxes.html
http://www.foxinfotech.in/2012/11/checkboxchecked-built-in-in-oracle-d2k.html

Check Box Mapping of Other Values Property Oracle Forms

Freebie: Date Picker Calendar Demo Form For Oracle Forms 6i

$
0
0
I have already posted and provided the required PLSQL Library and the Calendar FMX file in my previous blog post Date Picker Calendar For Oracle Forms but some people were still not able to use this utility in their forms, so I thought to provide a demo form by using Calendar form utility into it.

I have attached the packages in Program Unit of this demo form, now no need to attached that library to this form, you can use it directly but if you want to use it in all of your forms then I will recommend to attache the library, which I am providing also in source code.

Note: File general.plx and Foxcal.fmx should be in the directory from where you are running the demo form or your form which you will develop.

You can download this demo form through the following link Download Source Code

The following is the screen shot of this demo:

Date Picker Calendar - Oracle Forms 6i

An Important Note For Error Free Oracle 12c Database Installation On Windows7

$
0
0
You have downloaded the Oracle 12c archives (zipped files) from Oracle.com and now you need to extract it to start the installation and this is important, because most people extract to wrong destinations and get the errors during installation and the errors could be related to missing files or installation get stucked in between.

So here I will tell you for proper extraction location for installation archives, please check the following:

Oracle Database 12c installation archives

Suppose you have the following archives for Oracle 12c database installations:

1. winx64_12102_database_1of2.zip
2. winx64_12102_database_2of2.zip

Then extract the first archive into any folder and the following folder would be created:

winx64_12102_database_1of2

Then extract the second archive and your archive program may suggest you the default folder winx64_12102_database_2of2 for extraction but you change it to winx64_12102_database_1of2 means with the name of your folder in which you have extracted the first archive or the better way is to copy the whole path of first extraction folder and then paste for extraction location, for example if you have extracted first archive to "D:\Software\winx64_12102_database_1of2" then copy this whole path and then specify it for second archive file extraction.

After that start the installation by running setup.exe located in winx64_12102_database_1of2\database\ folder.

Define Custom Data Filter Using Pre-Query Trigger In Oracle Forms

$
0
0
Oracle Forms is having its default records filter, which we can use through Enter Query mode to specify some search criteria or to filter records, but you can also create your own filter, which can be more user friendly and easy to use.

In this example I have created a form based on SCOTT's Emp table, below is the screen shot of this form and I am sharing also the form source code FMB file with Scott.Emp table script which can be downloaded with the following link Prequery_Filter.Zip 


Created two drop downs and one text item to specify search criteria and populating these drop downs on When-New-Form-Instance trigger, the following is the code written in it:

DECLARE
   rg_name   VARCHAR2 (40) := 'DYNGRP';
   rg_id     RecordGroup;
   errcode   NUMBER;
BEGIN
   /*
   ** Make sure group doesn't already exist
   */
   rg_id := FIND_GROUP (rg_name);

   /*
   ** If it exists then delete it first then re-create it.
   */
   IF NOT ID_NULL (rg_id)
   THEN
      DELETE_GROUP (rg_id);
   END IF;

   rg_id :=
      CREATE_GROUP_FROM_QUERY (
         rg_name,
         'select DISTINCT job, job job1 from scott_emp order by 1');
   /*
   ** Populate the record group
   */
   errcode := POPULATE_GROUP (rg_id);
   CLEAR_LIST ('FLTJOB');
   POPULATE_LIST ('FLTJOB', 'DYNGRP');
   ------- populate for department
   rg_id := FIND_GROUP (rg_name);

   /*
   ** If it exists then delete it first then re-create it.
   */
   IF NOT ID_NULL (rg_id)
   THEN
      DELETE_GROUP (rg_id);
   END IF;

   rg_id :=
      CREATE_GROUP_FROM_QUERY (
         rg_name,
         'select DISTINCT TO_CHAR(deptno), TO_CHAR(deptno) deptno1 from scott_emp order by 1');
   /*
   ** Populate the record group
   */
   errcode := POPULATE_GROUP (rg_id);
   CLEAR_LIST ('FLTDEPT');
   POPULATE_LIST ('FLTDEPT', 'DYNGRP');
   GO_BLOCK ('SCOTT_EMP');
   EXECUTE_QUERY;
END;

Then written the Pre-Query on Scott_Emp block to modify the "Where Clause" of that block at run time and following is the code:

DECLARE
VWHERE varchar2(1000) := 'empno is not null ';
begin 
-- build where clause
if :fltjob is not null then 
vwhere := vwhere || 'and job = :fltjob ';
end if;
if :fltdept is not null then
 vwhere := vwhere || 'and deptno = :fltdept ';
end if;
if nvl(:fltsal,0) > 0 then
 vwhere := vwhere || 'and sal >= :fltsal ';
end if; 
set_block_property('scott_emp', default_where, vwhere);
end;

Created a Push Button to execute query in Scott_Emp block and following is the code written in When-Button-Pressed trigger:

go_block('scott_emp');
execute_query;

Note: Run the SQL script first to create the table in your current schema before running the form which I provided in source code Prequery_Filter.zip.

Freebie - Utility Form: Generate Excel Report From SQL Query In Oracle Forms 6i And 11g

$
0
0
Sharing a form to generate Excel file report from SQL query in Oracle Forms. This form can be used in Oracle Forms 6i and 10g / 11g.

Below is the screen shot of this form and could be download from the following link:


A procedure Create_Excel_File is attached in Program Unit of the form, which is being called from the "Generate Excel Report" push button and the following code is written on When-Button-Pressed trigger:

declare
vstring varchar2(4000);
begin
vstring := rtrim(replace(replace(:sql_query, chr(10),''), chr(13),''), ';');
Create_excel_file(vstring);
end;

Note: Excel Report will be created and open automatically in New Excel Instance.

See more examples of using OLE object in Oracle Forms from the following links:

Pass The Control To Specific Line Using Labels In PL/SQL

$
0
0
An example is given below to instruct the control in PL/SQL program to go to specific line number on some condition.

Suppose you want to by pass the control to any particular line on exception when no_data_found occurs, to achieve this you have to give a label using <<anylabel>> to that particular line to point it at the time of requirement.

The following is an anonymous PL/SQL block demonstrating this scenario using <<Labels>> with GoTo Label statement:

SET SERVEROUTPUT ON;

DECLARE
   v   NUMBER;
BEGIN
   BEGIN
      SELECT 1
        INTO v
        FROM DUAL
       WHERE dummy = 'V';
   -- change dummy = 'X' to skip exception section
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         DBMS_OUTPUT.put_line ('NO_Data_Found occured.');
         GOTO mylabel;
   END;

   -- below code before <<mylabel>> would not be executed if an error occured above
   -- because in exception section above, it is sending control directly to label <<mylabel>>
   -- but if no error occurred above then the whole program would be executed

   v := v + 1;

   DBMS_OUTPUT.put_line ('The value of variable v is '||v);

  <<mylabel>>
   DBMS_OUTPUT.put_line ('After label processing starts.');
-- do some task here
END;
/
Labels PLSQL

Facebook's New Page Plugin - Its Awesome And All In One Widget For Websites / Blogs

$
0
0
Facebook launched its new Page Plugin widget to Like, Share, Comment without leaving your website or blog and there is also a feature to Embed your latest articles same as latest posts or recommended posts widgets and user can move through scroll bar on it and can click to see.

Its an alternative to Facebook Like Box because Like Box is now deprecated and will stop working from June 23rd 2015, you can check the activity feed from the following link Deprecated Social Plugins.

Below is the image of this plug in and you can create this widget at Facebook's developer page with the following link Facebook Page Plugin.

Facebook Page Plugin

Create Custom Modal Dialog Windows For User Input In Oracle Forms

$
0
0
An example is given below to how to create a modal dialog window in Oracle Forms for asking user input and return the value to any text item.

The following is the screen shot of this demo and this form could be downloaded from the following link: Custom_diag.FMB


This form is containing the following objects:


You can see in above screen shot of object navigator that there are two data blocks, one is the Main and another is DIAG_BLOCK for dialog window purpose and also one more canvas FOR_MODAL_WIN created for modal window MODAL_DIALOG.

There are some special property settings for FOR_MODAL_WIN canvas and MODAL_DIALOG window object. Below are the screen shots of both object properties:

For Canvas:

For Window:

On clicking of the buttons just setting focus to the blocks by Go_Block statement, which you can see in the downloaded form Custom_Diag.fmb


Run_Product Example Form - Oracle Forms 6i

$
0
0
I have already posted in my previous post Running Reports Using Run_Product to run reports in Oracle Forms 6i and in this post I am using the same procedure to run report but I am providing a demo form also.

Below is the screen shot of this form and source code including sql script, report file and a fmb file can be download with the following link Run_Product.Zip


You can comment below if you have any questions and queries.

5 Useful Tips To Tune Your SQL Statements

$
0
0
Whenever we get some database related task to perform some query for analysis purpose or any  other reports related, then we just don't think much and start writing SQL Query to fetch the data. You simply run a query specifying the condition you want, and the database engine process to get it, but sometimes, you can improve the performance of your SQL queries by taking care of little things.

The following are the 5 useful tips to tune and optimize Oracle SQL query.

1. Use Table Joins Rather than Multiple Queries

If you want to fetch the data from multiple tables then do not write multiple SQL statements, write single statement by joining those tables to get the results. The following is the bad example given to get the data from tables:

SELECT empno, ename, deptno
  FROM scott_emp
 WHERE empno = 7369;

SELECT department_name
  FROM dept
 WHERE department_id = 20;

Instead of writing two queries to get the information, you should write a single query to get the results in more meaningful way. The following is the example to get the same result as above but in a better way through a single query:

SELECT a.empno,
       a.ename,
       a.deptno,
       b.department_name
  FROM scott_emp a, dept b
 WHERE empno = 7369 AND a.deptno = b.department_id;

 2. Use Fully Qualified Column References In Where Clause

Always use table aliases in your queries and use the alias for each column in your query's where clause and this is very important. The following is the example in which no column references are used.

SELECT empno,
       ename,
       deptno,
       department_name
  FROM scott_emp, dept
 WHERE empno = 7369 AND deptno = department_id;

This is not recommended and will reduce the performance of the query. The following query shows the right way to do it:

SELECT a.empno,
       a.ename,
       a.deptno,
       b.department_name
  FROM scott_emp a, dept b
 WHERE a.empno = 7369 AND a.deptno = b.department_id;

3. Use CASE Expressions Rather than Multiple Queries

Use CASE expressions rather than multiple queries when you need to do calculations on the same rows in a table. The following are the examples:

SELECT COUNT ( * )
  FROM scott_emp
 WHERE deptno = 20;

SELECT COUNT ( * )
  FROM scott_emp
 WHERE deptno = 30;

SELECT COUNT ( * )
  FROM scott_emp
 WHERE deptno = 40;

Instead of this you can perform this task in a single query, here is the example:

SELECT COUNT (CASE WHEN deptno = 20 THEN 1 ELSE NULL END) dept_20,
       COUNT (CASE WHEN deptno = 30 THEN 1 ELSE NULL END) dept_30,
       COUNT (CASE WHEN deptno = 40 THEN 1 ELSE NULL END) dept_40
  FROM scott_emp;

4. Use Exists Rather Than IN

EXISTS is faster than IN, because EXISTS just checks for the existence of rows, whereas IN checks for actual values. The following are the examples:

SELECT a.empno, a.ename
  FROM scott_emp a
 WHERE a.deptno IN (SELECT b.department_Id
                      FROM dept b);

SELECT a.empno, a.ename
  FROM scott_emp a
 WHERE EXISTS (SELECT 1
                 FROM dept b
                WHERE b.department_id = a.deptno);

5. Add Indexes To All Tables Required For Query

Just check for the Indexes on the tables on which you are going to write the query, if any table is not having index then you must create an index on that columns which you are planning to use in your query's where clause.

Oracle Form's Trigger Tutorial With Sample FMB

$
0
0
Created an Oracle Form to handle specific events / triggers like When-New-Form-Instance, Pre-Insert, Post-Insert, Pre-Update, Post-Update, Post-Query and Post-Forms-Commit.

I am doing the following simple tasks on these events to give you an example:

When-New-Form-Instance Trigger

Picking up Oracle Session ID through USERENV function and User to display below the title of the form, the following is the code written:

BEGIN
   SELECT    'ORACLE SESSION ID: '
          || USERENV ('SESSIONID')
          || ' USER NAME: '
          || USER
     INTO :VAL_FORM_INSTANCE
     FROM DUAL;
END;

Post-Query Trigger

Populating the Department Name.

BEGIN
   SELECT department_name
     INTO :scott_emp.dptname
     FROM dept
    WHERE department_id = :scott_emp.deptno;
EXCEPTION
   WHEN OTHERS
   THEN
      NULL;
END;

Pre-Insert Trigger

Checking if the Hiredate is current date or not.

BEGIN
   IF :SCOTT_emp.HIREDATE <> TRUNC (SYSDATE)
   THEN
      :VAL_PRE_INSERT := 'Hire Date must be current date.';
      RAISE form_trigger_failure;
   END IF;

   -- else ok
   :VAL_PRE_INSERT := 'Hire Date is valid.';
END;

Post-Insert Trigger

Counting total number of employees in table.

BEGIN
   SELECT 'Employee Count After: ' || COUNT ( * )
     INTO :val_pOST_insert
     FROM scott_emp;
END;

Pre-Update Trigger

Checking if current day is Sunday then stopping the user the update the record.

BEGIN
   IF TO_CHAR (SYSDATE, 'DAY') = 'SUN'
   THEN
      :VAL_PRE_UPDATE := 'Update is not allowed on Sundays';
      RAISE form_trigger_failure;
   END IF;

   :VAL_PRE_UPDATE := 'Update is allowed today.';
END;

Post-Update Trigger 

Just giving a simple message.

BEGIN
   :VAL_POST_UPDATE := 'You updated ' || :scott_emp.ename || '''s record.';
END;

Post-Forms-Commit Trigger

Displaying Date and Time of Last Commit

BEGIN
   :VAL_POST_COMMIT :=
      'Last Commit executed on '
      || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS');
END;

The following is the screen shot of this form and source code(Table's Script and FMB file) can be download from the following link: Form_Triggers.Zip


Passing Value Parameters To SQL Script In Oracle

$
0
0
In this tutorial you will learn to how to pass the parameters to SQL Script and use that parameters in SQL statements. The following examples shows how to pass the Character String, Numeric and Date type parameters to SQL script.
Passing parameters to sqlplus script in Oracle
Suppose we have an SQL script "MyScript.Sql" and the following statements are in it and we need to pass the JOB, MANAGER and HIREDATE parameters to get the results.

So we will call that script as following:

@ C:\Scripts\MyScript.sql SALESMAN 7698 31-MAR-2015

-- Where (1) JOB => SALESMAN, (2) MGR => 7698 AND (3) HIREDATE => 31-MAR-2015

Parameters can be read sequentially, for eg. if you want to access JOB parameter which is in first position, then you can reference it with &1 and second parameter with &2 and so on.

In the following statement we are getting the results on the behalf of first parameter JOB which is Character String type and String type parameters can be reference within single quotes, eg. '&1'

SELECT EMPNO,
       ENAME,
       MGR,
       SAL,
       COMM
  FROM SCOTT_EMP
 WHERE JOB = '&1'
/

In the following example, it will display the records for particular Manager by its second Numeric type parameter MGR, which can be access without quoted string as &2

SELECT EMPNO,
       ENAME,
       SAL,
       COMM
  FROM SCOTT_EMP
 WHERE MGR = &2
 /
The following example will show the records matching with first two parameters, one is String and another is Numeric.

SELECT EMPNO,
       ENAME,
       SAL,
       COMM
  FROM SCOTT_EMP
 WHERE JOB = '&1' AND MGR = &2
 /

The following example will display the records by matching third parameter, which is of Date type and Date type parameter also would be refer in quotes:

SELECT EMPNO, ENAME, HIREDATE
  FROM SCOTT_EMP
 WHERE HIREDATE = '&3'
 /

The following example shows how to use parameter in PL/SQL Block:

SET SERVEROUTPUT ON;

DECLARE
   v   VARCHAR2 (100);
BEGIN
   SELECT ENAME
     INTO V
     FROM SCOTT_EMP
    WHERE EMPNO = &2;

   DBMS_OUTPUT.put_line (v);
END;
/

Calling Script From Within A Script By Parameter

@ C:\Scripts\MyScript.sql Emp.sql

Contents of MyScript.sql

@ C:\Scripts\&1

-- It will run the Emp.sql script

Oracle Forms Tutorial: Create Non-Iconic Picture Buttons Using Symbols

$
0
0
Non-iconic symbol picture buttons oracle forms

Sharing an Oracle Form CharPic.FMB in which I created Symbol Picture buttons without using icons. You can examine each button's property to check the label text for a particular symbol. The font I used is "Wingdings" or even you can choose any other symbolic font to get some different icons.

Viewing all 231 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>