Wednesday, July 10, 2013

Show Oracle current jobs which name starts with

SELECT COUNT(*) FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME LIKE 'MBQT_DEQ%';

Sunday, May 19, 2013

How to find id of enclosing tr

var myId = $(this).closest('tr').attr('id');

How to post without redirecting / reloading the page

$.post(action, $('#MY_FORM').serialize());

How to deal with dots in HTML id

/* "." and ":" are problematic within the context of a jQuery selector
 * because they indicate a pseudo-class and class, respectively */
myId = myId.replace(/(:|\.)/g, "\\$1");

Thursday, May 2, 2013

PL/SQL: sum per month

SELECT TO_CHAR(CDR_DATE, 'mm/yyyy') MONTH, SUM(CHARGED_VOL) CHARGED_VOL FROM...GROUP BY TO_CHAR(CDR_DATE, 'mm/yyyy')

PL/SQL: date to epoch

SELECT (TO_DATE('26/10/2012 12:34:14', 'dd/mm/yyyy hh24:mi:ss') - TO_DATE('01/01/1970', 'dd/mm/yyyy')) * 86400 FROM DUAL;

Diff 2 XML files

Let's say we have XML files stripped on 1 line and we want to compare them.
We just need to re-format them, then use whatever tool to compare them (e.g. diff or p4merge)
xmllint --format /tmp/GET_SUB_INFO.log > /tmp/13.xml

Perl: Date to epoch

perl -MDate::Parse -e 'print str2time("01/25/2013 19:23:22 UTC"), "\n"'

Tuesday, April 30, 2013

PL/SQL: epoch to date

SELECT TO_CHAR(TO_DATE('19700101','YYYYMMDD') + (1364986608/(60*60*24)),'DD:MM:YYYY HH24:MI:SS') my_date FROM dual;

Monday, April 15, 2013

Git: How to retrieve a single file from specific revision?

> git show $REV:$FILE
E.g.
> git show 4b286e8:./src/com/mobiquithings/gprstrial/ConnectivityService.java
NB: use a ./ syntax or an absolute path

Friday, April 12, 2013

PL / SQL UPDATE + JOIN

MERGE INTO T1
USING T2
ON (T1.PK = T2.PK)
WHEN MATCHED THEN 
UPDATE SET T1.VAL = T2.VAL;

Monday, April 1, 2013

Exit AirDroid

Disconnect, then press Back, and the application will ask if you want to exit

Monday, March 4, 2013

Remove empty Google+ album

There is only one way to achieve this: from Picasa3

Thursday, February 28, 2013

Good bye stupid Flash ads

A native setting of Firefox prevents any plugin from being fired automatically:

This holds for Flash plugin, Java plugin, etc.

Friday, February 15, 2013

Remove Git tag

 git tag -d EXTRANET_v2.1

Friday, January 25, 2013

Check invalid packages

SELECT * FROM ALL_OBJECTS WHERE STATUS!='VALID' and owner not in ('SYS', 'PUBLIC', 'SYSTEM', 'WMSYS', 'SYSMAN', 'APEX_030200', 'VAS_P2P_DB', 'VAS_INDICATOR_DB', 'VAS_MULTIMSI_DB', 'VAS_PROPERTY_DB', 'VAS_ACK_DB', 'VAS_LOG_DB', 'VAS_TOEMAIL_DB');
Then to recompile invalid packages:
EXEC UTL_RECOMP.recomp_serial('CRM_DB');
EXEC UTL_RECOMP.recomp_serial('PROV_DB');
EXEC UTL_RECOMP.recomp_serial('RAF_CONS_DB');
EXEC UTL_RECOMP.recomp_serial('RATING_DB');
EXEC UTL_RECOMP.recomp_serial('RESOURCE_DB');
EXEC UTL_RECOMP.recomp_serial('SHARED_DB');
Or to perform the same task in parallel using the specified number of threads
EXEC UTL_RECOMP.recomp_parallel(4, 'PROV_DB');
or at database level:
EXEC UTL_RECOMP.recomp_parallel(4);
See http://www.oracle-base.com/articles/misc/recompiling-invalid-schema-objects.php for more details

Friday, January 18, 2013

Toad: Find Backward does not work, the Direction Forward and Backward are greyed out

Toad For Oracle 11
  • Description

    In Find dialog, the Direction Forward and Backward are greyed out.
    Only the Forward option is selected.
    Thus, only F3 works but not Shift+F3.

  • Cause

    User Setting file may have been corrupted.
  • Resolution

    As a test to localize and confirm the issue, doing the following will give you a clean User Files.

    Here are steps to get a clean User Files folder…
    1) Select Utilities | Copy User Settings.
    2) Select “Create a clean set of User Files from the base installation” and click OK.
    3) Toad will automatically restart. Once restarted, test issue.

    You will temporarily lose your connections settings.
    (If error no longer persist, with Toad for Oracle closed: The user can copy their connections.ini, connectionpwds.ini and savedsql.dat files from the 11.5_bak folder into their newly created User Files Folder.)

    Here are steps to get old settings back…
    1) Close Toad.
    2) Delete the 11.5 folder in the C:\Users\<User>\AppData\Roaming\Quest Software\Toad for Oracle directory.
    3) Rename the 11.5_bak folder, in the same directory, to 11.5.
    4) Launch Toad.

Toad: Objects within Package Body or Spec are not sorted alphabetically in Schema Browser

Toad For Oracle 11

  1. Double click a package in the Schema Browser
  2. Once the package has been opened, right click then Desktop | Navigator
  3. Right click in navigator and select "Sort and Group option
  4. Come back to the Schema Browser and refresh

Thursday, January 10, 2013

Check last PL/SQL package compile time

SELECT OWNER, OBJECT_NAME, LAST_DDL_TIME FROM ALL_OBJECTS WHERE OBJECT_TYPE='PACKAGE' AND OWNER LIKE '%_DB';

PL/SQL function: raise exceptions and fill in output variables

If we use "x_out_param OUT VARCHAR2", and an exception is raised in the function, the parameter won't be filled in.
The trick consists in using the NOCOPY keyword to pass variables by reference and not by copy.
PROCEDURE PROC(x_out_param OUT NOCOPY VARCHAR2) IS
BEGIN
    ...
    x_out_param := 'some value';
    RAISE MY_ERROR_EXCEPTION;
END PROC;

PROCEDURE MAIN(x_out_param OUT VARCHAR2) IS
BEGIN
    ...
    PROC(x_out_param);
EXCEPTION
    WHEN MY_ERROR_EXCEPTION THEN RETURN 1;
    WHEN OTHERS THEN RETURN 2;
END MAIN;