giovedì 4 agosto 2011

SQL: date datatypes & milliseconds (aka how to use timestamps instead of sequences)

This morning I was playing with dates while executing an anonymous plslq block from a java class. My goal was to trace the execution time of a class... including milliseconds.

The well known SYSDATE use the "DATE" datatype but from oracle 9i we can use SYSTIMESTAMP (using "TIMESTAMP" datatype):

SELECT
to_char(sysdate, 'YYYY:MM:DD:HH24:MI:SS')
,to_char(systimestamp, 'YYYY:MM:DD:HH24:MI:SS.FF6')
FROM dual

when using TIMESTAMP the comparison can be made through TO_TIMESTAMP (or TO_TIMESTAMP_TZ if having more than one zone field, TZ_OFFSET for getting the region time delay)

so... why we still have to use sysdate?
Because we can configure what is returned from the SYSDATE function modifing the "fixed_date" init parameter; I found it very usefull when testing application that are date-related.

ALTER SYSTEM SET FIXED_DATE = '2011-01-01-00:00:01';
System altered.

select sysdate from dual;

SYSDATE
-----------

01-JAN-2011


select systimestamp from dual;

SYSTIMESTAMP
------------------------------

08-JUL-2011 11.05.02.298000 AM

Another userful feature of the DATE type is the easy language conversion done by the TO_CHAR function:
SELECT TO_CHAR(SYSDATE, 'FMDD Month YYYY', 'NLS_DATE_LANGUAGE=italian') FROM DUAL

or in a more fashionable way:
WITH     target_languages     AS
(
 SELECT     'German' AS language FROM dual  UNION ALL
 SELECT     'French'             FROM dual  UNION ALL
 SELECT     'Italian'            FROM dual 
)
SELECT language
      ,TO_CHAR ( SYSDATE,'FMDD Month YYYY','NLS_DATE_LANGUAGE=' || language) AS t_c
  FROM target_languages

Nice tricks Mack, nice tricks. but... why have you used TIMESTAMP?

In my case i needed to track down the user insert/updates and i chose to add a column that simulated an oracle sequence without using a sequence:
TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISSFF6')

as the default value of the new column. try it yourself.
It can be used instead of a sequence, you can order the column and you can find out date and time of the insert.

mercoledì 15 giugno 2011

Adobe LiveCycle vs. Chrome

While developing a new UCM service showing an in-line view of some loaded PDF documents, I discovered that Chrome uses the "Chrome PDF Viewer" proprietary plugin.

My goal was to force the official Adobe plugin for viewing my LiveCycle encrypted PDF.
Here's what I've done:
- open chrome;
- in the Chrome address bar, type "chrome://plugins";
- click "Disable" on the "Chrome PDF Viewer" plugin;
- close chrome;
- install Acrobat reader 10.1 (the only version i found fully functional with Chrome and LiveCycle);
- open chrome;
- enable the "Adobe Acrobat - Version: 10.1.X.X" plugin ("chrome://plugins");

done.

lunedì 21 marzo 2011

venerdì 25 febbraio 2011

UCM: default datepicker with idoc

If you need to include a datepicker in a page template or in an hcsp and you won't use jquery, you can use the default UCM calendar with datepicker.
Check the following code as an example:



FROM:<input type="text" id="calendarFrom" />
<img onClick="javascript: pucToggleCalendar('calendarFrom');" border="0" style="cursor: pointer; cursor:hand; vertical-align: middle;" src="images/PopUpCalendar/calendar.png"/>

TO:<input type="text" id="calendarTo">
<img onClick="javascript: pucToggleCalendar('calendarTo');" border="0" style="cursor: pointer; cursor:hand; vertical-align: middle;" src="images/PopUpCalendar/calendar.png"/>

<script type="text/javascript">
pucCreateCalendar({ id: "calendarFrom",caption: "From date"}, "calendarFrom");
pucCreateCalendar({ id: "calendarTo",caption: "To date"}, "calendarTo");
</script>


Pay attention to include "std_checkin_html_head_declarations" in your template ; the static javascript code (with the "pucToggleCalendar" function) used to create the popup is included in that resource:

<$include std_checkin_html_head_declarations$>


Linux: boot with terminal

I've just finished installing "stuff" on a VM with Oracle Enterprise Linux and I need to configure the machine without the resource consuming X11 automatically loaded at startup.

The Linux boot process has six states of operation of which "0" is the shutdown state and "3" and above are fully operational with all essential processes running for user interaction. The init process is the last step of the boot procedure and it is identified by process with id=1; Init is responsible for starting system processes as defined in the "/etc/inittab" file.

Editing the inittab file, I changed the default line:

id:5:initdefault:

with the following:

id:3:initdefault:

Here there are the available states:

0 halt system (loaded the /etc/rc.d/rc0.d/ library)
1 single user (/etc/rc.d/rc1.d/)
2 multiuser with no network (...2.d)
3 terminal
4 reserved for local use
5 X11 GUI mode
6 reboot


After startup type "starx" or "init 5" to enter X11.

domenica 6 febbraio 2011

WLS: embedded LDAP client access

To view the entries of the embedded LDAP server through an LDAP client browser, first of all you have to change the embedded LDAP credentials:

1. Access WLS admin console
2. Expand the Domain node.
3. Select the Security-->Embedded LDAP tab.
4. Change the Credential attribute from its generated value to a new password
5. Click SAVE.
6. At last, reboot WebLogic Server.

Now configure a new connection in the LDAP browser (as a suggestion, I use Apache Directory Studio based on Eclipse).

Use the http server port 7001 (7002 if SSL is being used), "dc=[UCM_DOMAIN_NAME]" as the base dn, cn=Admin as the ldap administration user with the newly created password.