Pages

Saturday, June 9, 2012

Changing Background color in Oracle APEX.

We all get many requirements when it comes to changing the background color or style change in APEX , but we feel handicapped many times especially when  we are accessing the remote server and we donot have rights to change the core css or images of the theme.

We can still do it in apex , using shared components . 

Lets Try to change some background color of my theme .

Now the first question is how do i come to know what is that i actually need to edit . 

Steps:-

1) Create an application with  default theme , currenlty i had choosen as ( Mightnight blue theme which comes as one of the options of the apex themes).


2) Run the application , right click on the page , got to the    VIEW PAGE SOURCE  option .

3)  Try to find the test
  <link rel="style sheet" href="/i/themes/theme_3/css/theme_4_0.css" type="text/css"/> in the source of the page .


4) Click on the link /i/themes/theme_3/css/theme_4_0.css and open it in new tab .ou

5) Now you can view the whole css related to the theme you have choosen .



and soooo onn....


Currently lets try to edit the background color of the theme.


To edit it , there can be two ways , one thru local and another @ server side , the best example i can give is to edit @ shared components level such that we can test this example on oracle apex site.


6) Create an .css file as blackbg.css file .


body { background-color:black; min-width: 980px; max-width: 1920px; margin: 0 0 24px 0; padding: 0; font-family: Arial, Helvetica, Geneva, sans-serif; font-size: 12px; color: #CCC; }


try to change the background color of it , as you wish too . here i opted for black .


7) Upload this file to the application shared components , while uploading it , you can choose the application level or the workspace level upload.

Workspace upload can be used for multiple application , where as the application upload will be specific to the application for which it has been uploaded .



8) Now next step is to make a reference to this css using

<link rel="stylesheet" href="#WORKSPACE_IMAGES#blackbg.css" type="text/css">


one shud make sure that we are including this link only after the 

<link rel="style sheet" href="/i/themes/theme_3/css/theme_4_0.css" type="text/css" />

Else this last link will override your css and gives the same background o/p as that was previous .




9) Now run the application .


Troubles faced during this :-

1) i had uploaded the file and again when i changed the color directly in the shared components and saved , then run the application the changes were not reflected @ all.

Then i had deleted the file completely and uploaded the chnaged file from the system itself.


Now this was running perfectly.



2) I uploaded the changed file but though the page source was showing the old css uploaded , i had deleted all the files which i had upload but the old version of the css link was still accessible on from my page source view .

Need to check the root cause of this and get back on this .








Tuesday, June 5, 2012

Report on Function Returning Query


1)Create A page and Create a basic report on the page with the option of the source as the sql query (PLSQL function body returning the sql query).


2) Create an function which will take the table name as the input and return the query as the o/p.


create or replace function "QUERY_FOR_REPORT"
(table_name in VARCHAR2 default 'EMP')
return VARCHAR2
is
l_query varchar2(2000);
begin
l_query:='select * from '||table_name;
return l_query;
end;


3)
Call this function on the report as following .
BEGIN
RETURN QUERY_FOR_REPORT('AGENDA ' ||';');
END;



4) to check the o/p pf your function you can  run the same function on the sql workshop and check it.
Declare
l_r varchar(200):=QUERY_FOR_REPORT('AGENDA ' ||';');
Begin
dbms_output.put_line(l_r);
END;


5) now runt the page , it displays the report .

Changing the Element Properties on fly , example making a field required or optional on fly


  • Create an page item in apex called AGE.
  • Add the span tag to thew item label along with the label of the item as  
  • <
    span id="P1_AGE"
    >
    Age of Customer
    :
    <
    /span
    >
Now in case you want to make the age as mandatory field depending on any other field lets call it as ...Admission_class .
In case the Admission_class field is as play school then the age is not required to be made as mandatory and in the case when admission_class is choosen as  KG then this field AGE needs to be made as mandatory.
So lets create one more item called p1_admission_Class .
Lets call a javascript on the change of the field admission_Class to make the other field as mandatory.
function show_fields_mandatory(v1)
{
if (v1=='PLAY SCHOOL')
{
// alert(v1);
var x=document.getElementById("P1_Admission_class');
x.style.color = 'red';
}
if (v1=='KG')
{
// alert(v1);
var y=document.getElementById("P1_ADMISSION_CLASS");
var x=document.getElementById("P1_AGE");
x.style.color = 'black';
y.selectedIndex = 0;
}
}
call this javascript on the admission_class field .

Reports Quieries and Reports Layouts in Oracle APEX


Report Queries N  Report Layouts in Oracle APEX
Report Queries :- A report query is a printable document, which can be integrated with an application using buttons, list items, branches or any other navigational components that allow for using URLs as targets.
A report query is based on a standard SQL query. It can be downloaded as a PDF document, a Word document (RTF based), an Excel Spreadsheet (HTML based) or as an HTML file. The layout of a report query is customizable using RTF templates.
Report Layout :-   Use Report Layouts in conjunction with a report region or report query to render data in a printer-friendly format, such as PDF, Word or Excel. A report layout can be designed using the Template Builder Word plug-in and uploaded as a file of type RTF or XSL-FO. Report regions use a generic XSL-FO layout, which is customizable.
Report Query concept is used not only for the External 3rd party tool printing but it can be even used to execute the report and send the report as the attachment to the email  when called from the  process or the scheduler job.

Creating Report Query :-

Steps :-
  • Oracle Apex Development environment login with developer access .
  • Application Builder.
  • Database application.
  • Choose any existing application or create new one.
  • Click on application for edit mode of it  à shared components.
  • Go to Reports Region of the Shared components
  • Click on the Reports Layout Link
  • Click on the Create Button.
  • Choose the option of the header naming for the columns . Currently you can go with generic column .
  • Click on the Next icon  and name the layout as emplayout  or anything. This layout is nothing but the actual look and feel of the report which will be displayed during the report printing . modifiying the heading or the color attributes in case you want to .
  • Click on the create icon.
  • The Report Layout is created and you can see the following report layout listed in your shared components.


Creating the Report Query:-
  • This is the place where you will be writing your actual query.
  • Shared components  à click on the Report Queries icon -> create Icon.
  • Specify the report query name , output format and view file as attachment in case you want to send this as attachment in your email notification and click next
  • Specify the Query along with the bind variable in case you need to specify, and then click on the set bind variable button .
  • Now you can test the report by passing the values of your bind variable and see the output.
Once you enter value click on test and see the output and the click on Apply Changes Button.
You will be taken back to the same screen as shown above.
  • Click on the next icon and specify the source layout as name of the layout which you have created or use any file that contains the layout and upload it else default it to use the generic layout,.
  • Click on next icon.
  • Using this url you can call your report created in the shared components from anywhere , I mean button , navigation , redirect , list .
  • Click on the test report icon, to check whether the report is being printed or not.
In a case its giving the error as above then, you need to do the following.
"ORA-20001: The printing engine could not be reached because either the URL specified is incorrect or a proxy URL needs to be specified."
This is because of the grants. See the details mentioned below:-
“ORA-20001: The printing engine could not be reached  top
By default, the ability to interact with network services is disabled in Oracle Database 11g release 1 (11.1). Therefore, if running Oracle Application Express with Oracle Database 11g release 1 (11.1), use the new DBMS_NETWORK_ACL_ADMIN package to grant connect privileges to any host for the FLOWS_030100 database user. Failing to grant these privileges results in issues with PDF/report printing, specifically, you will get the following error message:
ORA-20001: The printing engine could not be reached because either
The URL specified is incorrect or a proxy URL needs to be specified.
Follow the steps mentioned in the Oracle Application Express Installation Guide, Enabling Network Services in Oracle Database 11g."
Once done your report is ready to be used with any third party tool or email package .

SQL insert statement with returning clause


Declare
var1 number;
Begin
Insert into  tablename
(col1,col2 , ....) values ( value1,value2 ,....)
RETURNING
col1 into var1;
End;

popup in oracle apex


<script language="JavaScript" type="text/javascript">
  function callMyPopup (formItem1,formItem2,formItem3) {
    var formVal1 = document.getElementById(formItem1).value;
    var formVal2 = document.getElementById(formItem2).value;
    var formVal3 = document.getElementById(formItem3).value;
    var url;
  url = 'f?p=&APP_ID.:2:&APP_SESSION.::::P2_ENAME,P2_JOB,P2_SAL:' + formVal1 + ',' + formVal2 + ',' + formVal3 ;
  w = open(url,"winLov","Scrollbars=1,resizable=1,width=800,height=600");
  if (w.opener == null)
  w.opener = self;
  w.focus();
  }
</script>

Mobile Application in Oracle APEX


I am eagerly waiting for the apex 4.2 release it is just simple out of this world.
I had attended the siminar on the mobile application creation which was published in linked in , it was live and was just wonderful.
He had answered my all questions.
On the same day i had created this application in just next 2 hours .
It is just very very raw, i was too lazy to enhance it more :P
I was amazed with this.
The changes were not major when it comes to implementing the fucntionality, but the changes were only @ theme side, thats template level changes.
we have to simple include few jquery mobile libaray which are comptaible with our apex version and the use it , we can use all possible  mobile widgets and functioanlities available.
I was looking more deeper in it , one day saw a tutorial on oracle site to create data loader functionality.
I came across a screen shot that has a  mobile theme radio button befopre we choose a page , i quciky looked into all versions which i was holding but @last came to know that it is gona b released in apex 4.2.
Hence stopped worrying about the mobile themes any more as i know that oracle will do its best for it :P.
Eagerly waiting for Oracle APEX 4.2 . Please come fast come :P

Exploring few Oracle apex 4.1 features


Yesterday i was exploring Oracle apex 4.1, i was amazed with new features included .
Thanks to Oracle team for making Developer's  life easier :D
when ever i thought there is a particular problem with Oracle apex and i see it getting resolved with a very qucik release of new version :P.
Its great to see Oracle APEX is in BOOM  ...:P
1) Interactive Reports :-
* Email functionality has been included in the options.
* HTML download
*Enhanced Flash charts
2) Lists :-
This was the most wonderful option i had seen , i have not used it much in earlier versions so not aware of what is new , but i found many things as interesting.
I cud see that this one particular list cud act as n no of page components like
1) drop down menu ( this is awesome)
2)horizontal train
3) vertical wizard
4) tree with + symbol
5) Tree without + symbol
3) wizard based page is more enhanced .
4)feedback page i have implemented very first time , so but not aware a upgrades , but i found it to b grt .
5)Application level items are the items on the page levels, these can b used acrross application with :item_name, these are many used as cookies or the global variable for the security purpose.
6)Access Control administration :-
It s a page with a tabular form to add user to default access tables and a region to change the view mode of the application .
I need to have more detail of it .
7)Utilities :- These are just highlights of the apex 4.1 , the utilities are actually made  into two levels , one is @ application level
and another @sql workshop level.
Utilites @ application level :-
1) application dashboard :- it displays report of the application with respect to different aspects , component , security,page type,overview,application component.
2)change history:- It will list out the changes made , insert , alters, acess everything in detail this was not there before.
3)Recently updated pages
4)Export Repository
5)Debug Messages
6)Advisor
7) Upgrade application is to upgrade few upgradable regions or items of the applications like charts , reports wihtout ny coding just a click on upgarde.
8)Attribute dirictory
9)apex views
SQL    Workshop Utilities
1) Query  Builder with less bugs.
2)Repository as usual
3)Generate DDL
4)scripts
 5) Methods on tables , this will generate  all the possible methods on the table give then table name.  It include  md5 checksum . which c is awesome feature of it .
6)User Interface defaults
7)Manage Table dictionary
8)schema comparision
9) Object reports

Upgarding apex 4.0 to 4.1


Once you install the 11gxe , you get the 4.0 installed by default.
Now, to cross check it , start ur database first.
Once the database is up, type this url in the browser
http://127.0.0.1:8080/apex
this is the default apex and it will take you to the adminidatration screen , you can create workspace and proceed further.
Incase you wanna upgrade it to the apex 4.1.
Download Zip file of apex4.1 and unzip it to c:\apex41\apex
once done.
Go to the command prompt , go to the C:apex41\apex\ and login to sql as sys as sysdba
SQlplus
username : sys as sysdba
password:- the password u gave for admin during installation of oracle db.
sqlplus>@apexins SYSAUX SYSAUX TEMP/i/;
this will update the schema of your database.
once done
sqlplus>@apxldimg.sql C:\apex41
done :D
now acces the same url as mentioned above , go and create workspace and login to workspace and see the apex version installed :D

Email Notification in Oracle APEX


Email Process in Oracle APEX.

1)       We need to configure the email  setting at the administration level of apex .
  • Log in to Oracle Application Express Administration Services. Application Express Administration Services".
  • Click Manage Instance.
  • Under Instance Settings, click Instance Settings.
  • Under Email, enter the following:
  • SMTP Host Address - Defines the server address of the SMTP server. By default on installation, this is set to local host. If you are using another server as an SMTP relay, change this parameter to that server's address.
  • SMTP Host Port - Defines the port the SMTP server listens to for mail requests. The default setting is 25.
  • Administration Email Address - Defines the from address for administrative tasks that generate email, such as approving a provision request or resetting a password.
  • Notification Email Address - Enter the email address to receive notification email messages for new workspace requests and change workspace requests. If not specified, no workspace request notification email messages are sent.
  • Click Apply Changes.
2)       Use the Email API provided by apex for sending the mails in the dev environment .
  • APEX_MAIL is the Apex API which can be used for sending the email notification in apex once the instance is configured.
  • This package is built on the UTL_SMTP package; hence UTL_SMTP must be installed and functioning in order to use APEX_MAIL.
  • There are three sub programs which are used in the package.
    • ADD_ATTACHMENT Procedure
    • PUSH_QUEUE Procedure
    • SEND Procedure

 ADD_ATTACHMENT Procedure
  • This procedure sends an outbound email message from an application as an attachment. To add                  multiple attachments to a single email, APEX_MAIL.ADD_ATTACHMENT can be called repeatedly for a single email message.
        APEX_MAIL.ADD_ATTACHMENT(p_mail_id                  IN    NUMBER,
                                                                    p_attachment                IN    BLOB,
               p_filename                  IN    VARCHAR2,
                      p_mime_type                 IN    VARCHAR2);
  • Parameter            
  • p_mail_id
The numeric ID associated with the email. This is the numeric identifier returned from the call to APEX_MAIL.SEND to compose the email body.
  • p_attachment
A BLOB variable containing the binary content to be attached to the email message.
  • p_filename
The filename associated with the email attachment.
  • p_mime_type
A valid MIME type (or Internet media type) to associate with the email attachment.





SEND Procedure


APEX_MAIL.SEND(
    p_to                        IN    VARCHAR2,
    p_from                      IN    VARCHAR2,
    p_body                      IN  [ VARCHAR2 | CLOB ],
    p_body_html                 IN  [ VARCHAR2 | CLOB ] DEFAULT NULL,
    p_subj                      IN    VARCHAR2 DEFAULT NULL,
    p_cc                        IN    VARCHAR2 DEFAULT NULL,
    p_bcc                       IN    VARCHAR2 DEFAULT NULL,
    p_replyto                   IN    VARCHAR2
);
Parameter            
  • p_to
Valid email address to which the email will be sent (required). For multiple email addresses, use a comma-separated list
  • p_from
Email address from which the email will be sent (required). This email address must be a valid address. Otherwise, the message will not be sent
  • p_body
Body of the email in plain text, not HTML (required). If a value is passed to p_body_html, then this is the only text the recipient sees. If a value is not passed to p_body_html, then this text only displays for email clients that do not support HTML or have HTML disabled. A carriage return or line feed (CRLF) must be included every 1000 characters.
  • p_body_html
Body of the email in HTML format. This must be a full HTML document including the <html> and <body> tags. A single line cannot exceed 1000 characters without a carriage return or line feed (CRLF)
  • p_subj

Subject of the email
  • p_cc
Valid email addresses to which the email is copied. For multiple email addresses, use a comma-separated list
  • p_bcc
Valid email addresses to which the email is blind copied. For multiple email addresses, use a comma-separated list
  • p_replyto
Address of the Reply-To mail header. You can use this parameter as follows:
  • If you omit the p_replyto parameter, the Reply-To mail header is set to the value specified in the p_from parameter
  • If you include the p_replyto parameter, but provide a NULL value, the Reply-To mail header is set to NULL. This results in the suppression of automatic email replies
If you include p_replyto parameter, but provide a non-null value (for example, a valid email address), you will send these messages, but the automatic replies will go to the value specified (for example, the email address).

Scheduling the Email.

In order to schedule the email outside of the application express  for example using the DMBS_SCHEDULER pakcgae or the DBMS_JOB package  .
We need to access in the following format .
for c1 in (
   select workspace_id
     from apex_applications
    where application_id = p_app_id )
loop
   apex_util.set_security_group_id(p_security_group_id =>
c1.workspace_id);
end loop;
Sample example which we used in oracle1 env to test the email functionality is :-
DECLARE
l_id NUMBER;
BEGIN
l_id := APEX_MAIL.SEND(
p_to => 'thakurdurgeshnandini@gmail.com',
p_from => ‘nandini.thakur@jnettechnologies.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
dbms_output.put_line(l_id);
END;

ABOUT RSS

using a RSS reader like Google Reader, the built-in readers of Firefox and Internet Explorer or some other web-based or stand alone readers.

Such a reader can make your life so much easier, because instead of regularly visiting all the blogs manually (and most blogs don’t have any new postings anyway) – so you are pulling the information – RSS will pushes new articles to your RSS reader. You don’t miss any new article and get instantly informed if there is something new.

Links to useful apex Blogs / sites

http://builderplugin.oracleapex.info/

http://www.click-click.at/apex-themes

http://apexlib.oracleapex.info/#install

http://www.inside-oracle-apex.com/

http://twitter.com/patrickwolf

http://www.commoncraft.com/rss_plain_english

http://digitalbush.com/
projects/masked-input-plugin/

About Plugins in APEX 4.0

Process Type Plug-Ins
- Twitter Status Update

Dynamic Action Plug-Ins
- Timer
- Notification
- Hide "Check All" Tabular Form Checkbox
- Fade Out
- Fade In

so this all plugins not shown for item.

http://www.oracle.com/technetwork/developer-tools/apex/plugins-155231.html

closing all popup windows in apex using javascript

The following code is a cross-browser solution for closing all popup windows opened by a particular page:

CODE
--<-- html>
--<--head>
----<--script type="text/javascript">

<--/script>
<--/head>
<--body onunload="closeChildWindows();">
Click here to open another new window.
<--/body>
<--/html>

As long as you call the openNewWindow function to open your new windows, this will work.



U can use the function called :-
javascript:html_PopUp(’url’, ‘windowName’, 800, 600);
to open a pop up in Oracle APEX .

convert the typed form input or typed text into the file

1) create an application with blank page .
2) ADD the Text area item (P1_ADD) .
3) Create a Button (Name:MAKEFILE, REQUEST:MAKEFILe)
Now when the Make file button is pressed you need to create a file and append the content of the P1_ADD to that file .


To do this , we need to create A Procedure as

create or replace procedure writefile(path varchar2,filename varchar2,content varchar2)
is
output_file utl_file.file_type;
begin
output_file := utl_file.fopen (path ,filename , 'W');
utl_file.put_line (output_file, content );
-- utl_file.put_line (output_file,'second added here ');
utl_file.fclose(output_file);

--exception
-- when others then null;
end;
/



Note: - the Path which we give here will be the relative , not absolute path .

EX:- if ur files need to be placed in E:\myfiles
then u need to do following .


Login to oracle :sys as sysdba;

create or replace directory MYDIR as "E:\myfiles";

Now to make this accesible to your schema on which the application is created .

U need to

GRANT READ,WRITE ON DIRECTORY mydir TO myschema;


Incase u wanna create the directory with in the same schema then ur schema must have the rights to create the directory .

GRANT CREATE ANY DIRECTORY TO MYSCHEMA;

So , now u can create the directory using the same schema also .


Now on Page1 , create a process and call this procedure on the Click of the MAKEFILE button .




NOTE:- MYDIR needs to be in uppercase for sure.
Declare
l_n_fileno number;

begin
select demo_order_items_seq.nextval into l_n_fileno from dual;
writefile('MYDIR',l_n_fileno||'.txt',:P1_ADD);
end;

This will generate the files and name it using seq .









SEE refernces:-

http://www.cs.umbc.edu/portal/help/oracle8/server.815/a68001/utl_file.htm


http://forums.oracle.com/forums/thread.jspa?messageID=9169498�

http://www.adp-gmbh.ch/ora/plsql/utl_file.html

http://psoug.org/reference/utl_file.html

Modal Form in APEX

http://apex.oracle.com/pls/apex/f?p=20411:1:888811517916461


Database :-

Create a table with following columns :-
id
sex
first_name
Last_name


1)Create a HTML Region (NAME : modal FOrm )

---ADD this in Region Header of it


2) Now create the following on the above region (MODAL FORM )


10 P1_ID Hidden
20 P1_FIRST_NAME Text Field
30 P1_LAST_NAME Text Field
40 P1_SEX Radio Group


3) Create a sql report as

select * from Persons;


4) Create a button calles "ADD Person " on this report region "

Redirect to URL
Javascript:OpenModalForm();


5) Add the following code for onload event of page :-

Page -> make the cursor on first field as disable , and add this following code for 3.2 , else for 4.0 add it directly to onload region of the page .

$('#ModalForm').dialog({
autoOpen : false ,
modal : true ,
buttons : { dummy : function(){} } ,
width : 400
});

---> this makes a created html region as the nonvisible and makes it modal and craetes a jquery button on it.


Copy paste the following in the header part of the page .


function openModalForm(pID)
{
$('#ModalForm input[type="text"]').removeClass('ui-state-error');
$('#msg').html('');
var btns ={};
btns['Cancel'] = function(){ closeForm() };
if( pID )
{
$('#ModalForm').dialog({title : 'Update' });
btns['Save Changes'] = function(){ addUpdate(pID) };
initilizeForm(pID);
}
else
{
$('#ModalForm').dialog({ title : 'Add'});
btns['Add'] = function(){ addUpdate() };
}
$('#ModalForm').dialog('option', 'buttons', btns);
$('#ModalForm').dialog('open');
}


function initilizeForm( pID )
{
var ajaxRequest = new htmldb_Get( null , &APP_ID. ,'APPLICATION_PROCESS=getPerson' , 0);
ajaxRequest.addParam( 'x01' , pID);
ajaxResult = ajaxRequest.get().split(',');

$s('P1_FIRST_NAME' , ajaxResult[0]);
$s('P1_LAST_NAME' , ajaxResult[1]);
$s('P1_SEX' , ajaxResult[2]);

}



function closeForm()
{
$('#ModalForm input[type="text"]').each( function() {
$(this).val('');
});
$('#ModalForm').dialog('close');
}

function addUpdate( pID )
{
if( !valid() )
return;
if(!pID)
{
var ajaxRequest = new htmldb_Get( null , &APP_ID. , 'APPLICATION_PROCESS=addPerson' , 0);
}
else
{
var ajaxRequest = new htmldb_Get( null , &APP_ID. , 'APPLICATION_PROCESS=updatePerson' , 0);
ajaxRequest.addParam('x04', pID);

}
alert($v('P1_FIRST_NAME'));
ajaxRequest.addParam('x01', $v('P1_FIRST_NAME'));
ajaxRequest.addParam('x02', $v('P1_LAST_NAME'));
ajaxRequest.addParam('x03', $v('P1_SEX'));
var ajaxResult = ajaxRequest.get();
alert( ajaxResult );
ajaxRequest = null ;
closeForm();
if( ajaxRequest !='Error')
gReport.search('SEARCH');
}


function valid()
{
$('#ModalForm input[type="text"]').removeClass('ui-state-error');
var valid = true;
var msg ='';
$('#ModalForm input[type="text"]').each( function() {
if( $(this).val().length == 0)
{
$(this).addClass('ui-state-error');
err_msg='Error : ' + $(this).attr('id').substr(3).replace('_',' ') + ' is blank'
msg = msg.length==0 ? err_msg : msg + '
' + err_msg;
valid = false;
}

});
$('#msg').html(msg);
return valid;
}



6) Create an 3 application Process ...


Go to Shared Componenets -> Application Process -> On damand application Process ..


a) Process Point on Demand
Name:getPerson
Type:PLSQL Anonymous Block .


Source :-

declare
l_id number;
l_first_name varchar2(100);
l_last_name varchar2(100);
l_sex char(1);
begin
l_id := wwv_flow.g_x01;
select FIRST_NAME , LAST_NAME , SEX into l_first_name , l_last_name , l_sex from PERSON where ID = l_id;
htp.prn(l_first_name || ',' || l_last_name || ',' || l_sex );
end;



b)Process Point on Demand
Name:addPerson
Type:PLSQL Anonymous Block .


Sorce :-

declare
l_first_name varchar2(100);
l_last_name varchar2(100);
l_sex char;
begin
l_first_name := wwv_flow.g_x01;
l_last_name := wwv_flow.g_x02;
l_sex := wwv_flow.g_x03;
insert into person( first_name , last_name ,sex)
values( l_first_name , l_last_name , l_sex);
htp.prn('Record successfully added');
EXCEPTION
when others then
htp.prn('Error');
end;


c))Process Point on Demand
Name:updatePerson
Type:PLSQL Anonymous Block .



declare
l_first_name varchar2(100);
l_last_name varchar2(100);
l_sex char(1);
l_id number;
begin
l_first_name := wwv_flow.g_x01;
l_last_name := wwv_flow.g_x02;
l_sex := wwv_flow.g_x03;
l_id := wwv_flow.g_x04;
update Person
set
FIRST_NAME = l_first_name ,
LAST_NAME = l_last_name ,
SEX = l_sex
where ID = l_id;
htp.prn('Record Successfully updated ');
EXCEPTION
when others then
htp.prn('Error');
end;


Now run the application

changing script_name (/apex) in apex

Get server URL in Apex



The OWA_UTIL package contains utility subprograms for getting the value of environment variables. Specifically the OWA_UTIL.GET_CGI_ENV function returns the value of CGI environment variables, like REQUEST_PROTOCOL, HTTP_HOST, SERVER_PORT and SCRIPT_NAME, this last one to get the mod_plsql cartridge and the database access descriptor name.

Usage:

view plaincopy to clipboardprint?
owa_util.get_cgi_env('REQUEST_PROTOCOL')
owa_util.get_cgi_env('HTTP_HOST')
owa_util.get_cgi_env('SERVER_PORT')
owa_util.get_cgi_env('SCRIPT_NAME')


You can quickly test these values creating a PL/SQL Dynamic Content region like this:

view plaincopy to clipboardprint?
BEGIN
HTP.p ( 'Apex URL: '
|| OWA_UTIL.get_cgi_env ('REQUEST_PROTOCOL') || '://'
|| OWA_UTIL.get_cgi_env ('HTTP_HOST') || ':'
|| OWA_UTIL.get_cgi_env ('SERVER_PORT') || '/'
|| OWA_UTIL.get_cgi_env ('SCRIPT_NAME') || '/'
);
END;


Now to complete the URL you just need to append the well known f function with the right values. In case you have forget, here is the Apex f function URL Syntax:

view plaincopy to clipboardprint?
f?p=App:Page:Session:Request:Debug:ClearCache:itemNames:itemValues:PrinterFriendly

acessing the parent elements on child page

function assign_value(vname, vid)
{
window.opener.document.getElementById('P2_VENDOR_NAME').value = vname;
window.opener.document.getElementById('P2_VENDOR_ID').value = vid;
window.opener.document.getElementById('P2_X').value = vid;


window.opener.document.getElementById('P2_VENDOR_NAME').focus();
window.opener.doSubmit('LOAD_HEADER');

window.close();

}


callinng popup from the parent page
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=1');");
}

setting regions dymanically as parent


$( function() {

alert( $x('child1'));
$dom_MakeParent('child1','cell1');
$dom_MakeParent('child2','cell2');

});

print button , close button


<div dir="ltr" style="text-align: left;" trbidi="on">
<blockquote>
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<span style="white-space: pre;"></span><br />
<div>
<input div="" id="ipt_print_01" onclick="javascript:window.print();" /><br />
<div>
onmouseover="this.style.background='#62BB46'" </div>
<div>
onmouseup="this.style.background='#F0F0F0'"</div>
<div style="text-align: center;">
onmouseout="this.style.background='#F0F0F0' "</div>
<div>
onmousedown="this.style.background='#BDD646' "</div>
<div>
class="t17Button" value="Print" type="button" STYLE="width: 75px"/&gt;</div>
</div>
</div>
<br />
<br />
<br />
<br />
Code for close button <br />
<br />
<br />
<input <br="" id="ipt_close_01" onclick="javascript:window.close();" />onmouseover="this.style.background='#62BB46'" <br />
onmouseup="this.style.background='#F0F0F0'"<br />
onmouseout="this.style.background='#F0F0F0' "<br />
onmousedown="this.style.background='#BDD646' "<br />
class="t17Button" value="Close" type="button" STYLE="width: 75px"/&gt;</div>
</blockquote>
</div>