Tag Archives: apex

neler var

Oracle bulutta bedava!

Zaten apex.oracle.com adresinden üye olup APEX kullanabiliyorduk. Fakat şimdi Oracle, kullanıcılarına Oracle Cloud ‘da ücretsiz, daima ücretsiz bir alan vaadediyor: Oracle Cloud Free Tier.

Sizin bulunduğunuz ülkeye göre sunulanlar küçük farklar gösterebilir ama bana deneme periyodu süresince kullanmam için 250EUR verildi. Bu “çek” tutarını harcayıp bitirince, ya da 30 gün dolunca deneme süresi sona ermiş oluyor. Bu aşamada dilerseniz ücretli devam ediyorsunuz, dilerseniz “daima ücretsiz sınırlı sürüm” ile devam edebiliyorsunuz.

Oracle ‘ın sürekli ücretsiz olacağını söylediği bu alanda neler yapabiliriz? Küçük ve orta ölçekte bence gayet başarılı işler çıkarılabilir. Bunu dilerseniz bir “ısınma turu” olarak alın, dilerseniz bir göz atayım diyin, ya da daha iyisi startup fikrinizi bu yapı üzerinde modelleyin.

Kabaca; bu alanda bir instance oluşturabilir,

sanal makinanıza ücretli bir Windows Server kurabilir ya da ücretsiz LINUX dağıtımları arasından dilediğiniz bir imajı kurabilir,

ORACLE DB oluşturabilir,

veri tabanınıza SQL Developer ile olduğu gibi, web arayüzünden de erişebilir

uygulama geliştirmek için APEX yükleyebilirsiniz.

Bir sanal makine kurduktan, bu kadar pratik şekilde Oracle veri tabanı ve APEX ‘e sahip olduktan sonra yapabilecekleriniz artık neredeyse sınırsız tabii ki.

Gözden kaçırmamanız gereken ayrıntı şu: Oracle Cloud ‘da oluşturacağınız ücretsiz ve her zaman ücretsiz bu hesabı profesyonel amaçlarla kullanabilirsiniz. Oracle ‘ın bu konuda bir kısıtlaması yok, aksine startup ‘ları teşvik ediyor. Ölçeğiniz büyüdükçe standart ücretsiz paketinizi güçlendirmek, söz gelimi sanal makinenizin CPU ya da belleğini artırmak istediğiniz takdirde ücretsiz paketten çıkmanız gerekecek, hepsi bu. Vakit Buldukça;

  • üyeliğin başlatılması,
  • veri tabanı kurulumu,
  • APEX kurulumu,
  • örnek bir APEX uygulaması hazırlama,
  • sanal makine
  • ve sanal makinemize Oracle ya da Ubuntu Linux kurulumu

konularını detaylarıyla anlatmaya çalışacağım.


APEX import. Bad Request?

The request could not be understood by server due to malformed syntax.

I needed to export one of my APEX application page to deploy it on another APEX environment.

But it raised this error: BAD REQUEST, malformed syntax.

It’s not self explanatory. Hard to understand what’s wrong at first glance. I checked .sql file to see if there is an ascii character, a non-unicode string and so on.

Better check your application logs

If you see an error like this and have used WIZARD template, perhaps the easiest work-around is: remove wizard region, export again, then import.


APEX Page Validation: a global check for special characters

I’ve been struggling with a long form which has tens of text areas on my APEX env.

At some point I needed to apply some restrictions on input fields. Basically to refrain any unwanted non-unicode characters to be inserted into table.

APEX has great Built-in restrictions and they work like a charm. However, it has only a few options. It didn’t help my case when I had to set a restriction to reject all characters but a-Z letters, all the numbers, spaces AND punctuations.

Perhaps there are easier ways to do that. Actually I’m sure there are easier ways to do that. But here is what I ‘ve done and feel free to use & feedback.

l_query VARCHAR2(100);
l_res clob;
v_out clob;
v_special NUMBER;
CURSOR cur_main IS
SELECT item_name item 
WHERE application_id = :app_id AND page_id = :app_page_id 
AND LOWER(display_as) LIKE '%text%'
v_out:= '';
   FOR rec_main IN cur_main LOOP
   l_query := 'select v('''||NVL(rec_main.item, 'null')||''') from dual';
   EXECUTE IMMEDIATE l_query INTO l_res;
   v_out := v_out||l_res;
INTO v_special 
FROM dual 
WHERE regexp_like(REPLACE(v_out, CHR(13)||CHR(10), '_carriegeReturn_'), 
                 '[^a-zA-Z0-9 .,:;?%&+-_]');
   IF v_special >0 THEN

let’s unwrap it a bit:

  1. cur_main is the cursor where I get all my text-based input fields on the page.
  2. l_query holds my dynamic sql string.
  3. v_out is concatenated string which consists of each item’s value on the screen for current page. note that it won’t work based on the data from session state.
  4. I simply hate being have to use regular expressions. So I copied a simple syntax and modified for my scenario.

Rest are just true/false conditions.

In my case it’s a Page Validation Process. To pass this validation no rows should be returned. Otherwise it will raise the error message.


Apex 5 Universal Theme – Navigation Experiment #4

His blog is a gem :)


Coloring side menu entries

Sometimes you want to add a little more color to the navigation menu. The idea in one project was to use colors for certain areas in an application. The color would show the user where he is currently working. Whether such colors are a feature that end users like, is still part of an ongoing discussion. But here are the technical details how to implement it.

The example uses a very small apex application that I’ll be using for a DOAG2015 presentation “Exotic SQL” (http://syntegris-doag.de/#vortraege).

Before / After

Steps to create this

I explain the changes in detail a little further down.

  1. Create a new List template based upon the current one.
  2. Switch the user interface from the old to the new template
  3. Edit the template
  4. Add colors to the parent list entries
  5. Update alls sub menus to match the parent color

Special Features:

  • can be…

View original post 902 more words

10 Oracle SQL features you probably didn’t know



10 Oracle SQL features you probably didn’t know

I can not guarantee that you never heared of this. But the majority of developers doesn’t know or doesn’t seem to know. And honestly –  most of this information is fairly useless – and mostly harmless.

10. Why we have the CONCAT function

There is a concat function that can be used instead of the concat operator ||.

Nobody uses that! But there is a reason why it exists.

This is from the 8.1.7 Oracle documention

On most platforms, the concatenation operator is two solid vertical bars, as shown in Table 3-3. However, some IBM platforms use broken vertical bars for this operator. When moving SQL script files between systems having different character sets, such as between ASCII and EBCDIC, vertical bars might not be translated into the vertical bar required by the target Oracle environment. Oracle provides the CONCAT character function…

View original post 2,420 more words

Why APEX running inside the database is a GOOD thing!

Johns Blog

I’ve had quite a few discussions with people regarding whether APEX running inside the database is a good thing or a bad thing. Personally I believe it is definitely a good thing, I see no downsides really. However a recent forum thread

For me, the fact that APEX runs inside the database means that one of the major positives is you are able to take full advantage of each and every database available to you. A recent forum thread illustrates this very nicely. The poster in the thread has deleted some files and has unfortunately performed a commit before realising their mistake.

Here is where the features of the database can help you, for example we are able to take advantage of the Flashback feature to get the database back to the state it was in before the files were deleted.

The user in the forum deleted some files from…

View original post 838 more words

APEX: Form on a Procedure


You have a procedure.

And you want to prepare an interface for enduser so they could execute it by themselves.

however, your procedure is expecting some input parameters which are not so-easy for the users to get..

Let ‘s go with an example:



Say this procedure is taking an account number and generating a risk report for that customer.

So you decided to publish a form on one of your APEX user dashboards:

Building form on a procedure

After a few easy steps with this wizard, you ‘ll have your form with a field (i.e. :p_acc)on it prompting you to enter an account number

Although it works just fine, it is not that easy for users to know which company has which number. It would be way easier if they could go with company name for instance..

If you have no chance to touch to that procedure, means you can ‘t modify it to make it work with another parameter instead of v_acc (account number), you still can do something similar.

i. Create a Page Item on your page region

ii. Display as: Text with autocomplete

iii. Give your new page item a unique name (i.e. :p_cust_name)

iv. Adjust the population logic of your text field to make auto-complete thing work.

v. Then take a look at execution statement which runs your SP. You can see it by double-clicking Run Stored Procedure


vi. You ‘ll see something like this

#OWNER#.basitmis_proc(V_ACC => :p_acc);

vii. Now let ‘s modify it so it could work with our other parameter :p_cust_name


Let ‘s see what we did here:


i.We declared another variable p_cust

ii.Use it to collect account number. To know which customer ‘s account should return, we used our Page Item p_cust_name and remember, this information was provided by user.

iii.Then we bind it to our SP


Now your users can type ABC to automatically get ABC Company in the company name field, then click the button that triggers your execution process. Your little declaration above will do the rest :)




APEX: dbms_scheduler

Bir sorgu hazirladiniz ve bu sorgudan donen sonucu periyodik olarak bir tabloya yazmak istiyorsunuz..

Ya da bu bir rapor ve bu rapora bakarak periyodik olarak bir kisi ya da ekibe mail gondermek istiyorsunuz..

APEX icinden nasil mail gonderilecegine dair kucuk bir ornegi su yazimda anlatmaya calismistim.

Simdi ise bunu “otomatik” hale getirmeyi deneyelim.

Farkli yontemler elbette var, ama ben -veri tabaninizin “eski” bir versiyonda olmadigini varsayarak- dogrudan dbms_scheduler uzerinden bir procedure ile ilerleyecegim.

i. Oncelikle sorgumuzu bir procedure haline getirerek objemizi olusturalim. Bunu APEX ‘in etkilesimli menulerine yaptirabilecegimiz gibi SQL konsolunda elle de yapabiliriz.

create or replace procedure “ORNEK_BASITMIS” is 

Sorgunun detaylari bu yazinin konusu degil. Fakat soz gelimi, belirli bir data setini dinamik olarak sececegimiz alicilara gondermek istiyorsak

  • Bir cursor acabilir,
  • Sonra bu cursor ‘i loop icinde %NOTFOUND oluncaya kadar fetch ederek aksiyonumuzu aldirabiliriz: mesela her defasinda bir email gondermek gibi.

Schedule etmeye karar verdiginiz islem sisteme periyodik olarak email gonderme isi vermekse ve ornek mail gonderme kismini burada isledigimiz gibi apex_mail.send uzerinden kotariyorsaniz, dikkat etmemiz gereken aslinda belki de tek onemli nokta su:

Hazirladiniz SP icinde BEGIN END arasinda APEX Workspace ID ‘nizi assign emelisiniz..

Aksi takdirde schedule ettiginiz Job ‘un calisma vakti geldiginde

ORA-20001: This procedure must be invoked from within an application session.

gibi bir hata ile karsilasirsiniz :)


APEX Workspace ID

Bu ID bilgisine ustteki gibi erisebilirsiniz. Set etmek icin asagidaki gibi bir ifade kullaniyoruz:


Stored Procedure ‘imizi hazirladik ve ORNEK_PROCEDURE ismi ile create ettik diyelim. Simdi sirasi ile DBMS_SCHEDULER ile once bir program create etmeliyiz:


Ardindan bir schedule create ediyoruz:


repeate_interval degiskenine dikkat edelim. Burada frekans, saat, dakika, saniye turunden bir cok deger verme sansimiz var..

Dolayisiyla, Ayin belirli bir gunu, Haftanin belirli gunleri, gunun belirli saatleri gibi spesifik periyod tanimlari yapabiliyoruz. Detayli bilgiye Oracle dokumanlarindan erisebilirsiniz.

Simdi de job create edelim:


Artik veri tabaninda bir SP ‘miz var ve bu SP ‘nin istedigimiz zaman araliklarinda otomatik calismasi icin bir Program tanimimiz, bir Schedule ‘imiz ve bir de Job ‘imiz var..

Simdi program ve job ‘imizi “acalim”.


Hazir.. Artik repeat_interval olarak verdigimiz vakit geldigi zaman job ‘in calismadigini kontrol edebiliriz.

Mesela az once enable ettigimiz Job ‘u suradan gorebiliriz:

select * from dba_scheduler_jobs;

Zamani geldiginde islemin calisip calismadigini ise su tablodan takip edebiliriz:

select * from user_scheduler_job_run_details;

Yaptiklarimizi drop etmek icinse yine DBMS_SCHEDULER icindeki

  • drop_job
  • drop_schedule
  • drop_program

yapilarini kullanabiliriz. Fakat tahmin edebileceginiz gibi bunlari “sirali” yapmalisiniz, aksi takdirde sistem dependency nedeniyle kizacaktir :)


DROP etmek..

Gorusmek uzere!

APEX: Send Mail Thru Report Page


You published a useful interactive report for your users and now want to let them get that as email also through that page.

Here you can find a basic example..

  • Go to your report page from Application Builder panel
  • Create a page item button 
    • Pick Defined by Dynamic Action as button action
  • Right click to your brand new Dynamic Action and select Create.

APEX Dynamic Action

As you can see above, we have to create this action with some conditions. Such as:

  • Event: Click
  • Selection Type: Button
  • Button: address your button which you ‘ve just created. This item will trigger your email sending process.

Once we completed these steps, we can add a True action. You ‘ll see a button named Add True Action at your Dynamic Action Edit page. You can also create one by choosing from right click menu.

Adding a TRUE action

You may want to uncheck Fire On Page Load. Because.. Well we want to trigger it by clicking our button, manually :)

So.. Now we need this PL/SQL code which will take care of sending email via Oracle APEX.

I ‘ll share 2 basic examples with you. One for plain-text emails, one for HTML based ones.

I personally prefer to send mails in HTML format… But it ‘s up to you and depends on your needs..


It is pretty easy, right? Just give the right parameters and a simple sentence as email body. You can always use variables to collect these informations like i did..

If you want to go with HTML format, then you ‘ll need some extra time to create a good-looking and small-sized body. That ‘s all :)

Once you store these codes you ‘ve wrote and apply the changes onto your report page, you can start using your button. It should be sending emails to given address. Click on your button and wait couple of minutes to receive it.

I am not going to remind you not to copy everything from my sample snapshots. You do need to change email addresses etc. :)

Should you want to add some extra features on this dynamic action, you can add another True action(s) as well.

You may need to.. Otherwise someone would be able to click on that button more than necessary and we don ‘t want to spam people :)

Let ‘s add a Confirmation action..



  • Right Click, Create
  • Action: CONFIRM

Now you ‘ll be prompted to click OK everytime you click on your email button..

O.K. but not enough? Well let ‘s hide the button after it ‘s got clicked.


  • Now we have a button on our report page
  • Our authorized report viewers can click on it to send email
  • We have a confirmation dialog before trigger
  • Our email send button will be hidden once it used.