[#1065] Add OracleFactory.sysContext(String, String) to support Oracle's SYS_CONTEXT function
This commit is contained in:
parent
9e17af371c
commit
007eb1ac0c
@ -38,6 +38,7 @@ package org.jooq.test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static org.jooq.impl.Factory.currentUser;
|
||||
import static org.jooq.impl.Factory.falseCondition;
|
||||
import static org.jooq.impl.Factory.one;
|
||||
import static org.jooq.impl.Factory.substring;
|
||||
@ -69,6 +70,7 @@ import static org.jooq.util.oracle.OracleFactory.level;
|
||||
import static org.jooq.util.oracle.OracleFactory.prior;
|
||||
import static org.jooq.util.oracle.OracleFactory.rownum;
|
||||
import static org.jooq.util.oracle.OracleFactory.sysConnectByPath;
|
||||
import static org.jooq.util.oracle.OracleFactory.sysContext;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@ -998,4 +1000,13 @@ public class jOOQOracleTest extends jOOQAbstractTest<
|
||||
assertEquals(now, org.jooq.test.oracle2.generatedclasses.packages.Pkg_976.f_976(ora(), now));
|
||||
assertEquals(now, ora().select(org.jooq.test.oracle2.generatedclasses.packages.Pkg_976.f_976(now)).fetchOne(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOracleFunctions() {
|
||||
Record user = ora().select(
|
||||
sysContext("USERENV", "SESSION_USER"),
|
||||
currentUser()).fetchOne();
|
||||
|
||||
assertEquals(user.getValue(0), user.getValue(1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.SchemaMapping;
|
||||
import org.jooq.impl.CustomField;
|
||||
import org.jooq.impl.Factory;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
|
||||
/**
|
||||
* A {@link SQLDialect#ORACLE} specific factory
|
||||
@ -97,6 +98,24 @@ public class OracleFactory extends Factory {
|
||||
return field("rowid", String.class);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Oracle-specific functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The Oracle-specific <code>SYS_CONTEXT</code> function
|
||||
*/
|
||||
public static Field<String> sysContext(String namespace, String parameter) {
|
||||
return function("sys_context", SQLDataType.VARCHAR, val(namespace), val(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Oracle-specific <code>SYS_CONTEXT</code> function
|
||||
*/
|
||||
public static Field<String> sysContext(String namespace, String parameter, int length) {
|
||||
return function("sys_context", SQLDataType.VARCHAR, val(namespace), val(parameter), val(length));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Pseudo-and functions for use in the context of a CONNECT BY clause
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user