четверг, 30 января 2014 г.

Pagination для Oracle

/**
* Создание запроса с разбиением по страницам (pagination) для Oracle
*/
protected String preparePaginatedQueryOracle(String originalQuery) {
        StringBuilder query = new StringBuilder();
        query.append("select * from (");
        query.append("select a.*, ROWNUM rnum from (");
        query.append(originalQuery);
        query.append(") a");
        query.append(" where ROWNUM <= ? )");
        query.append(" where rnum  >= ?");
        return query.toString();
    }

воскресенье, 26 января 2014 г.

Конфигурация для запуска JUnit с кастомным commons-logging.properties


-ea -Djava.util.logging.config.file=C:\workspace\ARGO\fssp-adapter\src\test\resources\commons-logging.properties

среда, 22 января 2014 г.

Удаление table, view, procedure, sequence из Oracle по маске

set serveroutput on size 1000000

BEGIN
FOR r IN(

  select TABLE_NAME
    from USER_TABLES
      where TABLE_NAME like 'NF\_%' escape '\')

LOOP

  execute immediate 'drop table ' || r.table_name || ' cascade constraints';

END LOOP;

FOR r IN (

  select SEQUENCE_NAME
    from USER_SEQUENCES
      where SEQUENCE_NAME like 'NF\_%' escape '\')

LOOP

  execute immediate 'drop sequence ' || r.SEQUENCE_NAME;

END LOOP;

FOR r IN (

  select VIEW_NAME
    from USER_VIEWS
   where VIEW_NAME like 'NF\_%' escape '\')

LOOP

  execute immediate 'drop view ' || r.VIEW_NAME;

END LOOP;

FOR r IN (

  select OBJECT_NAME
    from USER_PROCEDURES
      where OBJECT_NAME like 'NF\_%' escape '\')

LOOP

  execute immediate 'drop procedure ' || r.OBJECT_NAME;

END LOOP;

exception when others then
   dbms_output.put_line(sqlerrm);
END;
/