1 2 Previous Next 16 Replies Latest reply on Apr 14, 2014 7:44 PM by Ziut

    Desktop app vs Mobile app




      Apex: otn



      I create two applications (with Calendars) working with the same table (mobile and desktop).

      There are differences between them and I would like to distinguish them in eg. triggers.


      First solusion: I employed APP_ID:


      .....if v('APP_ID') = 7865 then

             /* to do */

           end if;

      And it works fine.


      I would like to find better way. I would like to use Theme number (theme 50):


      .....if ......Theme = 50(????) then ...... end if;


      or the best Type of app (mobile or desktop):


      .....if ......App_Type = Desktop(????) then ...... end if;


      How to do it?


        • 1. Re: Desktop app vs Mobile app

          if you only have one theme for your desktop and one theme for your mobile appl, you can use application express view APEX_APPLICATION_THEMES :


          select theme_number from APEX_APPLICATION_THEMES where application_id = :APP_ID



          1 person found this helpful
          • 2. Re: Desktop app vs Mobile app
            Mike Kutz


            Think about this scenario:  It is the year 2021 and you now have a 3rd app that uses Theme 150


            Do you really think you're going to remember that there is a trigger on that table?

            From some very horrible experience, the answer is:  NO.


            Save your sanity and move the logic out of the trigger and into a procedure (in a package).

            With a procedure, you can include an additional parameter that states how to process it.  (eg desktop, mobile, bulk loader)


            And remember, you're dealing with a database.

            As such, you must allow for situations where other applications will use the same data at the same time.

            Those other apps are not necessarily APEX apps.  They could be written in C/C++/Java/C#/.NET/Fortran/COBOL/Perl/PHP/Ruby/P9/<latest and greatest language>


            Again, my $0.02:  Move your logic into a procedure with an additional parameter that states how to process it.



            • 3. Re: Desktop app vs Mobile app

              SO you need to determine if you running on a desktop or mobile device?? Maybe this will help: Oracle &amp;amp; Apex Geekery: &amp;quot;Who are you?&amp;quot; &amp;#8211; client device Categorizr for APEX


              Thank you,


              Tony Miller
              LuvMuffin Software
              Ruckersville, VA

              • 4. Re: Desktop app vs Mobile app


                Trigger was only example. Of course it will be procedure or function but still I have question: "How?"

                You don't give me answer. In procedure I must answer the question: 'Mobile or not?", too.


                Solution of Robert is better because (in this moment) we have only one mobile theme - Theme 50. We don't know what will be in the future. Maybe 51 and 52?


                • 5. Re: Desktop app vs Mobile app


                  it is no problem in devices but applications.

                  With tablet I may run desktop application or mobile application.

                  With standard computer I may run desktop application or mobile application too.


                  With smaller devices I may run mobile application only because screen is too small for desktop application.

                  That is problem for me.


                  • 6. Re: Desktop app vs Mobile app
                    Mike Kutz

                    I guess my suggestion was not obvious...


                    For the pages with the Desktop theme, call the procedure like this:

                    schema_name.my_package.my_procedure( ...
                       ,p_input_class => 'desktop' );


                    For the pages with the Mobile theme, call the procedure like this:

                    schema_name.my_package.my_procedure( ...
                       ,p_input_class => 'mobile' );


                    Remember, there is nothing wrong with using hard-coded values (when they make sense).



                    • 7. Re: Desktop app vs Mobile app


                      I have first solution:


                      1. In application I create Application Items (Application xxxx/Shared Components/Application Items) - GL_APEX_APP_TYPE,


                      2. Next I create Application Computations (Application xxxx/Shared Components/Application Computations):

                           Computation Item - GL_APEX_APP_TYPE

                           Computation Point - On New Instance

                           Computation Type - Static Assignment

                           Computation - MOBILE  (* for mobile app *)


                      3. In PL/SQL code (eg trigger) I may write:



                          if v('GL_APEX_APP_TYPE') = 'MOBILE' then




                          end if;



                      It works OK.


                      For few days I will try reverse solution. I will create PL/SQL package with variable and use it in apex computations.



                      • 8. Re: Desktop app vs Mobile app



                        1. I create package:

                        create package pkg_calendar as


                        gl_apex_app_type varchar2(30);





                        2. In Mobile application I create application process (Application xxxx/Shared Components/Application Processes) with point: On New Instance:


                        pkg_calendar.gl_apex_app_type := 'MOBILE';




                        3. in PL/SQL code I change:


                           if pkg_calendar.gl_apex_app_type = 'MOBILE' then


                           end if;



                        But it doesn't work. I think gl_apex_app_type is still NULL but I don't know exactly.

                        • 9. Re: Desktop app vs Mobile app
                          Mike Kutz

                          Database package variables are set at the Database Session level.

                          An APEX Session has zero relationship to a Database Session.


                          This means:

                          1. APEX can use multiple database sessions to serve the same APEX session
                          2. APEX uses the same database session to serve multiple APEX session



                          With #1:

                          It is very possible that your login page can use one database session while then next page can use a different database session.

                          That means, page 2 is using an uninitialized variable. (since the package variable was never initialized in that database session)


                          With #2:

                          When a 2nd user logs in, the value for user 1 is over written by the value for user 2.


                          Fixing your problem - method 1

                          APEX 4.2 can handle both Desktop and Mobile themes in the same application.

                          With that, you need to HARD CODE which value you are going to use on each page... session level is insufficient.

                          Again, that value should be a parameter of the procedure that you call for your update/insert/delete.

                          In other words, your Automatic DML Processes needs to be removed and replaced with custom DML Processes that take in (as a parameter) a value that indicates "mobile/desktop/other".


                          Fixing your problem - method 2

                          Use the Enterprise Edition feature Virtual Private Database to record "mobile/desktop/other".


                          Fixing your problem - method 3

                          Drop the requirement all together.

                          (IMHO) Your requirement to know the UI type is abnormal.


                          How data is processed should not be dependent by which user interface is being used.

                          APEX Mobile should process identically to APEX Desktop should process identically to SQL*Developer should process identically to JDBC should process.....



                          • 10. Re: Desktop app vs Mobile app

                            Thanks Mike


                            I tested my applications with one computer.

                            Desktop application run with FF and mobile with Chrome.

                            And both work fine.

                            If you want to test it please let me know.


                            Differences between them refer to Date Picker. in Theme 25 I may use standard picker and plug_in but in theme50 (mobile) - no.


                            my workspace on otn: tb2/tb2/tb2.

                            numbers 37985 and 40822.


                            • 11. Re: Desktop app vs Mobile app


                              In my mobile and dektop applications I have one problem with date and time.


                              I have table:

                              Create table demo_calendar


                              cal_date date,       -- YYYY-MM-DD

                              cal_hour varchar2(5), -- hour:minutes

                              cal_datetime timestamp,




                              When I insert row into table:


                              insert into demo_calendar (...,cal_date, cal_hour,...) values (..., '2014/04/14', '15:10'...)


                              I would like (in trigger) set:

                              :new. cal_datetime := (cal_date || cal_hour) -???  format: YYYY-MM-DD HH24:MI


                              How to do it?

                              Thanks for help

                              Regards Ziut

                              • 12. Re: Desktop app vs Mobile app
                                Mike Kutz

                                Oracle's DATE date type includes the TIME component.

                                Your cal_hour is unnecessary.


                                You need to do the conversion of String/VARCHAR2 into DATE at the INSERT level. (ie as part of the APEX process)

                                The "Automatic DML" process won't work.

                                You'll need to remove it and create your own custom DML process. (or three.. one each for insert,update,delete)


                                insert into demo_calender (.., cal_date, /* time is unnecessary */ ... ) values (...,  TO_DATE( :P25_DATE || ' ' || :P25_TIME, 'YYYY/MM/DD HH24:MI' ), ... )

                                • 13. Re: Desktop app vs Mobile app

                                  Thanks Mike but my problem is: how convert variable  from varchar to time. I have column cal_hour as '19:15'  but it is varchar. I would like to convert it into HH24:MI.

                                  Column cal_date has only date. ('2014-04-14 00:00.....').

                                  Look in my workspace and check it.


                                  • 14. Re: Desktop app vs Mobile app
                                    Mike Kutz

                                    You may want to read this recent thread:  Only time format.


                                    Oracle does not have a TIME data type.


                                    basic solution:

                                    Store both date and time as a single DATE (with time) value.

                                    Use 11g's Virtual Column feature to extract out what you want....

                                    eg --  cal_date_only as (trunc( date_time ) )

                                    You'll need to decide if you want the time format as a varchar2 or as an INTERVAL DAY TO SECOND.

                                    1 2 Previous Next