Return type Boolean From Oracle Function

1. How do I get a return type of Boolean from Oracle function in Java?
2. I have a function fx overloaded in Oracle (8 variances) and I have trouble getting the right one in Java. Is 8 too high a figure or Java does not support calling overloaded functions or what?
Thanks for any help.

I am facing a similar situation, where I have defined an overloaded function in one package (2 variants) which both return a type BOOLAN value.
I am having trouble to setting up an CallableStatemnt to call one of this functions from Java. Whenever I set the parameter with a BIT or NUMBER data type, I get an exception with java.lang.boolean during my
callablestatement.setobject( indez, parameter, OracleTypes.BIT );
or
callablestatement.setobject( indez, parameter, OracleTypes.NUMBER );
I have no problem calling the function from SQLPlus, but doing so from Java raises the exception. I have found no exact match in OracleTypes or java.sql.Types for a BOOLEAN data type.
In your response do you mean to modify the Function to return a NUMBER instead of a BOOLEAN, or do you mean to set the parameter as Types.NUMBER in the calling java code?
Thanks,
Fedro

Similar Messages

  • Problem when calling a return type BOOLEAN SQL Function in a package

    Hi All,
    I am having problem when trying to call a SQL function in a package with return type BOOLEAN
    The SQL function signature is as follows
    CREATE OR REPLACE PACKAGE RMSOWNER.ORDER_ATTRIB_SQL ****
    FUNCTION GET_PO_TYPE_DESC(O_error_message IN OUT VARCHAR2,
    I_PO_TYPE       IN     VARCHAR2,
    O_PO_TYPE_DESC  IN OUT VARCHAR2)
    RETURN BOOLEAN;
    Following is my java code
    +CallableStatement cs3 = conn.prepareCall("{?=call ORDER_ATTRIB_SQL.GET_PO_TYPE_DESC(?,?,?)}");+
    +cs3.registerOutParameter(1, java.sql.Types.BOOLEAN);+
    +cs3.registerOutParameter(2, java.sql.Types.VARCHAR);+
    +cs3.registerOutParameter(4, java.sql.Types.VARCHAR);+
    +cs3.setString(2, "");+
    +cs3.setString(3, "ST");+
    +cs3.setString(4, "");+
    +ResultSet rs3 = cs3.executeQuery();+
    I get the following exception, i tried changing the sql type(registerOutParameter) from boolean to bit but i still getting this exception.
    But when i call any other functions with return type other than boolean they work perfectly fine.
    Please can anyone help me fix this issue, i am not sure if its anything to do with vendor JDBC classes?
    +java.sql.SQLException: ORA-06550: line 1, column 13:+
    +PLS-00382: expression is of wrong type+
    +ORA-06550: line 1, column 7:+
    +PL/SQL: Statement ignored+
    +     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)+
    +     at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)+
    +     at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)+
    +     at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:954)+
    +     at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3422)+
    +     at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394)+
    #####

    Hello People!
    There is another workaround!!
    See the example below:
    private String callBooleanAPi(String tableName,String apikey,String dtInicio,String dtFim,String comando) throws SQLException {
                   CallableStatement cs = null;
                   String call = "";
                   String retorno = null;
                   try {
                        if(comando.equalsIgnoreCase("INSERT")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x :=PKG.INSERT(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("UPDATE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.UPDATE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("DELETE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.DELETE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        cs = conn.prepareCall(call);
                        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                        SimpleDateFormat sdfToSqlDate = new SimpleDateFormat("yyyy-MM-dd");
                        java.util.Date dataInicialVigencia =null;
                        java.util.Date dataFinalVigencia = null;
                        Date dtInicialFormatada =null;
                        Date dtFinalFormatada = null;
                        if(dtInicio != null && !dtInicio.equals("")){
                             dataInicialVigencia = sdf.parse(dtInicio);
                             dtInicio =sdfToSqlDate.format(dataInicialVigencia);
                             dtInicialFormatada = Date.valueOf(dtInicio);
                        if(dtFim != null && !dtFim.equals("")){
                             dataFinalVigencia = sdf.parse(dtFim);
                             dtFim =sdfToSqlDate.format(dataFinalVigencia);
                             dtFinalFormatada = Date.valueOf(dtFim);
                        cs.setString(1, tableName);
    cs.setString(2, apikey);
    cs.setDate(3, dtInicialFormatada );
    cs.setDate(4, dtFinalFormatada );
    cs.registerOutParameter(5, java.sql.Types.VARCHAR);
    cs.registerOutParameter(6, java.sql.Types.VARCHAR );
    cs.execute();
                        retorno = cs.getString(6);
                        System.out.println( cs.getString(5));
                   } catch(SQLException e){
                   throw new SQLException("An SQL error ocurred while calling the API COR_VIGENCIA: " + e);
                   } catch(Exception e){
                   Debug.logger.error( "Error calculating order: " + id, e );
                   } finally {
                   if (cs != null) {
                   cs.close();
                   cs = null;
                   return retorno;
    As you can see the CallableStatement class acepts PL/SQl blocks.
    Best Regards.

  • Function with return type boolean

    I have created a function with return type boolean as:
    CREATE OR REPLACE FUNCTION fn RETURN BOOLEAN
    AS
    exp EXCEPTION;
    BEGIN
    return TRUE;
    EXCEPTION
    when OTHERS then RAISE exp;
    END;
    FUNCTION fn compiledThen I was trying to call this function into dbms_output.put_line procedure, I got this error:
    EXECUTE DBMS_OUTPUT.PUT_LINE(fn);
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'Can someone please help me understand, why this happened?
    Is this because of boolean return type?

    952040 wrote:
    I have created a function with return type boolean as:
    Then I was trying to call this function into dbms_output.put_line procedure, I got this error:
    EXECUTE DBMS_OUTPUT.PUT_LINE(fn);
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    What is the parameter signature for DBMS_OUTPUT.put_line() ?
    Is is string - as detailed in Oracle® Database PL/SQL Packages and Types Reference guide.
    So how can you pass a boolean data type as parameter value, when the parameter's data type is string?
    PL/SQL supports implicit data conversion. So you can for example pass a number or date value to DBMS_OUTPUT.put_line() - and the PL/SQL engine automatically (and implicitly) converts that (using the TO_CHAR() functions) to a string.
    However, the TO_CHAR() parameter signature supports number and date - not boolean. It cannot convert a boolean value into a string.
    So passing a boolean value means the implicit conversion fails - and results in the above error.
    To make it work, you need to perform an explicit conversion. As as a data type conversion function from boolean to string is not available, you need to write a user defined function. E.g.
    SQL> create or replace function BoolToChar( b boolean ) return varchar2 is
      2  begin
      3    case
      4       when b then return( 'TRUE' );
      5       when not b then return( 'FALSE' );
      6    else
      7      return( null );
      8    end case;
      9  end;
    10  /
    Function created.
    SQL>
    SQL> exec DBMS_OUTPUT.put_line( 'Flag is '||BoolToChar(true) );
    Flag is TRUE
    PL/SQL procedure successfully completed

  • XML Error while calling webservice from oracle function.

    I am getting an error while I am trying to call webservice from oracle function. Any ideas? Thanks.
    select get_new_string ('proxy:80', 'http://xxx/PatternVariations/SourceTest/WebMethods','Scott') from dual
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00225: end-element tag "H4" does not match start-element tag "P"
    Error at line 9
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at "DORSBP00.DEMO_SOAP", line 82
    ORA-06512: at "DORSBP00.GET_NEW_STRING", line 11

    The error message implies that the web service is returning something that is not well formed xml. Can you verify what is being returned by the web service call

  • Set attribute to a Jfield to return type number from Lov

    in my lov , i need to return type number and put it in the Jfield . after doin some search , i found the method to set the attribute on that field. PLease and need to send me any URL of doing that method if there is one. (returning type number from LOV)
    i have tried this method but it didn't work!!!
    Return object from List of values page:
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application app = fctx.getApplication();
    ValueBinding vb = app.createValueBinding("#{bindings}");
    DCBindingContainer dc = (DCBindingContainer) vb.getValue(fctx);
    DCIteratorBinding dciter = (DCIteratorBinding)dc.get("PrcPartiesLawer1Iterator");
    id = (Number)dciter.getCurrentRow().getAttribute("Id");
    Name = (String)dciter.getCurrentRow().getAttribute("FullNameN");
    setId(id);
    setName(Name); AdfFacesContext.getCurrentInstance().returnFromDialog(this,null);
    return listener to assign value to Number field:
    LawyerReturnOject b = (LawyerReturnOject)returnEvent.getReturnValue();
    if(b==null)return;
    Number i = b.getId();
    getIii().setSubmittedValue(null);
    getIii().setValue(i);
    String f = b.getName();
    getInputText1().setSubmittedValue(null);
    getInputText1().setValue(f);
    AdfFacesContext af = AdfFacesContext.getCurrentInstance();
    af.addPartialTarget(getLawyerLov());
    af.addPartialTarget(getInputText1());
    and the number type is oracle.jbo.domain.number

    Hi,
    its easier to set the returned value on the ADF binding then on the component directly (at least this is less error prone)
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application app = fctx.getApplication();
    ValueBinding vb = app.createValueBinding("#{bindings}");
    DCBindingContainer dc = (DCBindingContainer) vb.getValue(fctx);
    FacesCtrlAttrsBinding the_attribute = (FacesCtrlAttrsBinding ) dc.get("nameOfAttributeToUpdate");
    the_attribute.set...
    Frank

  • Error when calling webservice from oracle function.

    Hi,
    I am getting following error when i am trying to call webserivce from oracle function. Please can anyone suggest the required solution. Below is the error obtained.
    Thanks.
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00225: end-element tag "UL" does not match start-element tag "P"
    Error at line 15
    ORA-06512: at "SYS.XMLTYPE", line 54
    ORA-06512: at "SCOTT.DEMO_SOAP", line 87
    ORA-06512: at "SCOTT.WEB_SERVICE", line 17

    The error message implies that the web service is returning something that is not well formed xml. Can you verify what is being returned by the web service call

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • How to get BOOLEAN from STORED FUNCTION

    We are calling legacy PLSQL stored procedures and functions via named queries. This has worked fine so far, but there are some functions which return the type 'BOOLEAN'. e.g.
    FUNCTION some_function( some_argument IN NUMBER) RETURN BOOLEAN;
    Where the return type is BOOLEAN calling the named query fails with
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    A couple of threads have hinted that what we are trying to do is not possible:
    How to get BOOLEAN from STORED PROCEDURES
    Re: Creating Named Query: from OracleCallableStatement
    This would possibly be due to 'restriction in the OCI layer'. Can anyone help? Is there really now way to call a valid PLSQL stored function via a named query when the return type is BOOLEAN?
    thanks

    I can't comment on possible issues you might have with the driver, but if it can be done in JDBC, it should be possible in TopLink.
    TopLink has the StoredFunctionCall which extends the StoredProcedureCall but adds an unnamed ouput parameter in the first spot of its parameter list. You will need to get the databasefield and set its type to BOOLEAN ie:
      DatabaseField returnField = (DatabaseField)yourStoredFunctionCall.getParameters().firstElement();
            returnField.setName(name);
            returnField.setSqlType(Type.BOOLEAN);Be sure not to use the setType() method, as I believe TopLink will try to use the Type.BIT when a boolean class is used as the classtype.
    Best Regards,
    Chris

  • Retrieve a single row from Oracle function

    Hi!
    I have an Oracle function created as follow:
    CREATE OR REPLACE FUNCTION user_data(userId IN users.user_id%TYPE)
    RETURN users%ROWTYPE AS
    userData users%ROWTYPE;
    BEGIN
    SELECT * INTO userData
    FROM users
    WHERE user_id = userId;
    RETURN userData;
    END user_data;
    This function returns a single row from 'users' table.
    I tried to retrieve that single row by mean of:
    CallableStatement statement = connection
    prepareCall("{ call ? := get_data(?) }");
    statement.*registerOutParameter(1, OracleTypes.OTHER)*;
    statement.setInt(2, 103);
    statement.execute();
    ResultSet rs = (ResultSet) statement.getObject(1);*
    String value = rs.getString(2);
    System.out.println(value);
    But this code doesn't work.
    I tried other OracleTypes, also. (I don't know what OracleType I receive when the Oracle function return a ROWTYPE.)
    Can somebody tell me how to retrieve that single row?
    What is the type of out parameter (registerOutParameter()) when the Oracle function return a ROWTYPE?
    Notes: No cursor can be added. No database change is allowed.
    Thank you in advance.
    [Adrián E. Córdoba]
    Edited by: aecordoba on Mar 18, 2011 3:58 PM

    aecordoba wrote:
    I beg your pardon for my bad English. (It isn't my original language.)
    It's not a language problem. It's that you didn't provide any details about what went wrong.
    That just is my problem:
    I know the retrieved result is not a result set: It's a single row.Doesn't matter if it's a single row. You have a ResultSet object. You have to call ResultSet's next() method to get to the first row, even if it's the only row.
    1- Which is the Oracle type I receive in Java when the Oracle function returns a ROWTYPE?I don't know.
    2- How can I get each column value when I receive a single row in Java?The same way as when there are multiple rows: For each row, call ResultSet.next() to advance to the next row, then call the appropriate ResultSet.getXxx() methods to get each column's value. Again: If you have a ResultSet, you must call next() to get to the first row, even if there is only one row. "First row out of 1 total row" is no different than "first row out of 100 total rows."
    EDIT: Okay, I didn't notice before that you're using a CallableStatement with "out" parameters. I've never used one of those before, so I'm not familiar with the details. I really don't know if casting to a ResultSet is appropriate here. Do you actually have documentation that says you can do that, or are you just guessing and trying to find something that works.
    Edited by: jverd on Mar 18, 2011 11:26 AM

  • How do I execute a returned sql string from a function on the command line?

    Hi,
    I have written a pl/sql function that will dynamically create a sql select statement. I need to be able to execute this statement from the command line. e.g from sqlplus
    Say my function is called "sql_create" and it returns "select * from customer"
    How do I execute the returned value from the command line?" Is it possible?
    SQL> select sql_create from dual;
    SQL_CREATE
    select * from customer
    SQL>
    So I try:
    SQL> exec execute immediate 'select sql_create from dual';
    SQL>
    I don't get an error but I don't get the result set either.
    Is there a command I can use instead of execute immediate?
    thanks,
    Susan
    Edited by: Susan123456 on Jul 2, 2009 1:21 AM

    depends on the frontend. Most frontends (like Java and .Net) know how to handle REF CURSORS. Instead of returing a "string" which represents a query, return a ref cursor
    SQL> ed
    Wrote file afiedt.buf
      1  create function sql_q return sys_refcursor
      2  is
      3     rc sys_refcursor;
      4  begin
      5     open rc for select * from emp;
      6     return rc;
      7* end;
    SQL> /
    Function created.
    SQL> var r refcursor
    SQL>
    SQL> exec :r := sql_q
    PL/SQL procedure successfully completed.
    SQL> print r
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        900                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1700        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1350        500         30
          7566 JONES      MANAGER         7839 02-APR-81       3075                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1350       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2950                    30
          7782 CLARK      MANAGER         7934 09-JUN-81       2551                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3100                    20
          7839 KING       PRESIDENT            17-NOV-81       5100                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1600          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1200                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81       1050                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3100                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1400                    10

  • Union  dataset from oracle function with dataset from a postgres function

    I retrieve two sets of data,
    one from an oracle database using  Command_1    select * from  table(functionname(param1, param2))
    one from postgres database using  Command_2     select * from  functionname(param1, param2)
    i can join  the two tables (Command_1 and Command_2) with database expert > links
    I would like to know if it is possible to UNION the two sets

    Don't think so.
    I have only done that by linking from Oracle to the other database and forming the union in Oracle.
    Ian

  • Recursing through table / complex return types in Java Stored Functions

    I have a table representing a tree with arbitrary depth, of the form:
    ID NUMBER(10) PRIMARY KEY,
    NAME VARCHAR2(20),
    PARENT NUMBER(10)
    with PARENT being a foreign key for ID, so that top-level nodes in the tree have a NULL PARENT, and other nodes have the ID of their parent node in the PARENT field.
    I want a good way to get a row representing a node as well as all its ancestor nodes recursively up to the top level. I do this a lot in my Java application, and right now it works by just getting each row, checking if PARENT is null, and recursing again until I get the top-level node. Since this recursion is in Java and I do multiple queries it's rather slow, and I'd rather perform this operation in the database (using a Java Stored Function/Procedure or PL/SQL).
    I'm no good at PL/SQL so don't have a clue how to go about doing this sort of thing, and although I can write a Java Stored Function that does the same recursion I do in the application, I don't know how to return the results. I can't return a REF CURSOR type since the results are from multiple queries, and I can't find any documentation about how to return structured types from a JSF.
    If anyone could give me a near-complete PL/SQL listing that does this or (better) help me to complete my Java Stored Function by returning the results in a structured type.

    You are my own personal God (for the day). Thanks, exactly what I needed, and all in one query with no procedural.

  • How to return a integer from Userdefined function????

    Hi All,
    I have an Userdefined funtion which is getting  an integer value from a RFC call. Now I want to pass this int value to a target field of type int. The problem I am facing is Userdefined function can only return String value and I have tried the Container also, but no result.
    Any views on how to handles this issue
    Regards,
    Raks

    Raks,
    just return the integer as a string. There should be no problem. Use:
    return String.valueOf(a);
    Regards,
    Henrique.

  • Returning multiple values from a function

    Hello everyone,
    I am pretty new to actionscript and flex and one thing i am not entirly sure it is done is how to get the value in actionscript when returning multple values.
    for example i have the following function:
    public function sayhello():string
         var hello:String="hello World";
         return hello
    var myvalue:String=sayhello();
    trace(myvalue);
    How do go about getting the values of two returns:
    public function sayhello():string
         var strhello:String="hello";
          var strWorld:String="World";
         return strhello,strWorld;
    var myvalue1:String=?????
    var myvalue2:String=???

    To solve this problem you must use a object for storing complex return value.
    You can do it using inline anonymous object:
    public function sayhello():Object
         return {strHello: "hello";strWorld: "World"}
    and accesing result as:
    var obj:Object = sayhello();
    var strHello:String = obj.strHello;
    You may also create a custom class
    class HelloWorldResult{
         public var strHello:String;
         public var strWorld:String;
    and return a new instance of this class from your method:
    public function sayhello():HelloWorldResult
         var hwr:HelloWorldResult = new HelloWorldResult();
         hwr.strHello = "Hello";
         hwr.strWorld = "World";
         return hwr;

  • Return multiple values from a function to a SELECT statement

    I hope I've provided enough information here. If not, just let me know what I'm missing.
    I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
    Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
    For instance, right now, I have:
    Table1:
    sequence_number NUMBER(10),
    name VARCHAR(30),
    Table2:
    Table1_seq NUMBER(10),
    action_seq NUMBER(10),
    action_date DATE,
    action_office VARCHAR(3),
    action_value VARCHAR(60),
    I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
    The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    rp.action_date(sequence_number) action_date,
    rp.action_office(sequence_number) action_office,
    rp.action_value(sequence_number) action_value
    FROM table1
    Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
    Any suggestions?
    Thanks so much!

    Hi,
    What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
    WITH     got_rnum     AS
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;As written, this will return (at most) one row.
    I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
    In that case, add a PARTITION BY clause to the ROW_NUMBER function.
    If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
    Since I don't have your tables, I'll show you using tables in the scott schema.
    Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    SELECT     *
    FROM     senior_emp
    ;Output:
    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81 
    By the way, one of the conditions in the query you posted was
    action_office     LIKE 'E'which is equivalent to
    action_office     = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
    Did you mean to say that, or did you mean something like this:
    action_office     LIKE 'E%'instead?

Maybe you are looking for

  • Do I have to register my new replacement iPod?

    I just got my replacement iPod touch today because my other iPod was broken. So i plugged it in to my computer and opened up iTunes. It said for me to register my iPod and make an account. Should I do this?

  • Roles & authorizations

    hi all, am a BI consultant. in my project CRM part there is a need for creating new users and for that roles & authorizations has to be assigned. i want to do it. in this business same role will be having diff autherizations as per the location. exam

  • Wi-fi on iPhone 4s permanently greyed out even after restart?

    For several days now I have been unable to turn on my Wi-fi because it is always greyed out in the Settings. I've googled suggestions and have tried turning it off and on again (several times) and also resetting the network settings. Neither of these

  • Cannot see Time Capsule in Finder

    Greetings. I purchased a brand new Time Capsule. I set it up, and it would appear to be synced with Time Machine and working (steady green light) but I am wondering why I am unable to locate "Time Capsule" in my Finder? Thanks for your help. chris

  • Get Better Internet Speed

    I'm 14,000ft. from the sub-station with old small gauge wire so I can only get three mbps down and .7 mbps up slow speeds. Friends in Los Alamitos got FIOS five years ago.  In Naples, Long Beach four years ago.  We are directly inland ten miles from