APEXblog.nl - Tips and Tricks

About This Blog:
I (Richard Weug) started this blog primary for myself to save all kinds of Apex tips and tricks in one place. To use it as a place to write down how I used some coding in my own projects, but also to copy and paste all kinds of articles I find on the Internet. (So I never have to wonder on what website did I read about??? When I see something interesting I collect the content so I have my own archive/knowlegde base.

View my profile on LinkedIn

 

Tips & Tricks

Print
09
May

APEX simple cookie example

Written by Richard Weug on Wednesday, 09 May 2012 09:18. Posted in Tips and Tricks

This is an example for the use of a simple cookie which gets created after submit when click on a button. Afterwars a region inside my page shouldn't be shown anymore. The cookie itself is valid for 30 days and will save the value "1".

Print
06
Apr

Get client IP Address in APEX

Written by Richard Weug on Friday, 06 April 2012 10:30. Posted in Tips and Tricks

Um die Client-IP-Adresse mit Hilfe von PL/SQL auszulesen, können Sie zwei unterschiedliche Prozeduren verwenden:

select
owa_util.get_cgi_env('REMOTE_ADDR')
from dual;

select
sys_context('userenv','ip_address')  
from dual;

Das Ganze funktioniert super solange Sie keinen vorgeschalteten Proxy Server verwenden! Aber auch dafür gibt es einen Workaround. Stellen Sie folgende Einstellung in Ihrer http.conf ein:

RewriteCond %{REMOTE_ADDR} (.*)
RewriteRule .* - [E=REMOTEA:%1]
RequestHeader set X-Oracle-Cache-User "%{REMOTEA}e"

# Außerdem müssen folgende Einstellung mit gesetzt werden:
# 1. Konfiguration der RewriteRule muss in einem VirtualHost hinterlegt sein:
<VirtualHost 192.168.0.1:80>

# 2. Rewrite muss aktiviert werden
RewriteEngine on

# 3. ModHeader muss mit geladen werden
LoadModule headers_module modules/mod_headers.so

Die Lösung wurde von Dietmar Aust im Oracle APEX Forum auch noch tief greifender beschrieben: https://forums.oracle.com/forums/thread.jspa?messageID=1262928&#1262928
Weitere Forum Einträge zu Thema:
https://forums.oracle.com/forums/thread.jspa?threadID=926109
http://redmine.lighttpd.net/boards/2/topics/3626
Das auslesen der Info in PL/SQL sieht dann so aus:

select
owa_util.get_cgi_env('HTTP_X_ORACLE_CACHE_USER')
from dual;

Info: Es kann vorkommen das andere Einstellungen verhindern das die Variable richtig durchgeroutet wird.

Original article by :Tobias Arnhold

Link: http://www.apex-at-work.com/2012/04/client-ip-adresse-in-apex-auslesen.html

Print
10
Apr

APEX Best Practices

Written by Richard Weug on Tuesday, 10 April 2012 10:27. Posted in Tips and Tricks

When building many APEX applications, it is good to think about some best practices concerning as you go along.

APEX is so easy to get started with, that many developers just start an application, as a prototype, and gradually this application is adapted by the end users, and “glides” into a production state. Thinking about at few simple guidelines during the development phase, can really help make the maintenance/enhancement phase a lot easier.

I have divided the best practices into 3 areas: Installation, Pre-development and Development. Many of the practices are learnings from APEX books, seminars, and experience from many APEX projects.

Print
11
Apr

APEX interactive report aggregate cell font color

Written by Richard Weug on Wednesday, 11 April 2012 10:20. Posted in Tips and Tricks

Here is how change style for APEX interactive report aggregate cell e.g when calculated value is negative.

On this solution I pass aggregate cell value using Ajax to database. Application process checks passed values and returns JSON witch cells have e.g. negative value.

Values are checked on database side because all possible number formats we can have on report. This is of course one extra call to database, but I find this is easier than try handle numbers on JavaScript.

Posted on 18-APR-2012 05:59 by Jari.Laine

Print
23
Apr

Weekday Numbers in Apex sensitive to Application Primary Language

Written by Richard Weug on Monday, 23 April 2012 10:11. Posted in Tips and Tricks

The weekday in Apex is dependent on of the language set in the Application Properties. For that you cannot rely on TO_CHAR(datevalue,’d’), but should use TRUNC(datevalue)-TRUNC(datevalue,'iw')+1 to get ISO weekdays, that are independent of the language set. SQL Workshop did not show differences because the language for SQL Workshop remained the same. This made the analysis more difficult as the results of queries in Apex and SQL Workshop were inconsistent.