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

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.

  • Conditional display using Pl/SQL function body returning a boolean

    I am having issues with conditional display of a report.
    I have to select lists: p50_facility and p50_supervisor.
    I have entered the below pl/sql function body returning a boolean
    Begin
    if (:p50_facility is null or
    :p50_supervisor is null) THEN
    Return False;
    Else
    Return True;
    End if;
    End;
    No matter what values my items are set to (null, not null), the report shows.
    What am I doing wrong?

    Hi,
    The values for the lists will be null only until the first time the page is submitted. Thereafter, the value is likely to be '%null%'
    You will need to do something like:
    BEGIN
    IF (:P50_FACILITY IS NULL OR :P50_FACILITY = '%' || 'null%' OR :P50_SUPERVISOR IS NULL OR :P50_SUPERVISOR = '%' || 'null%') THEN
      RETURN FALSE;
    ELSE
      RETURN TRUE;
    END IF;
    END;Andy

  • Conditional display: PL/SQL Function Body Returning a Boolean

    Hi,
    can anyone give me an example how to create a PL/SQL Function Body Returning a Boolean in the Conditional Display Section of a Region?
    I have two Items on the Page and I want the region only be displayed when the two Items are not null....
    Thanks,
    tim

    Also, I have seen some "null"-values of Selectlists being stored as '%null%' instead..
    :P1_ITEM1 IS NOT NULL AND UPPER(:P1_ITEM1) != '%NULL%' AND :P1_ITEM2......
    ..might be helpful?
    Cheers,
    Vidar

  • 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

  • Complicated PL/SQL questions that involves function with in type parameter

    Hello,
    I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
    this is what I am thinking but I dont know if it's correct or not or what should I do next!
    create or replace function get_min_salary (i_job_id in varchar2)
    return number
    as
    min_sal jobs.min_salary%type;
    begin
    SELECT min_salary INTO min_sal
    FROM jobs
    where job_id = i_job_id;
    RETURN min_sal;
    end get_min_salary;if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
    create or replace procedure insert_error (i_error_code in number,
    i_error_message in varchar2)
    as
    begin
    insert into error_table (error_user, error_date, error_code, error_message)
    values (user,sysdate,i_error_code,i_error_message);
    end insert_error;This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
    Any ideas of how to do that?
    Thanks in advance

    >
    minimum salary of the job_id
    >
    may be
    SELECT min(min_salary) INTO min_sal
    FROM jobs
    where job_id = i_job_id;
    if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:why error?
    This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
    create or replace procedure insert_error (i_error_code in number,
    i_error_message in varchar2)
    as
    begin
    insert into error_table (error_user, error_date, error_code, error_message)
    values (user,sysdate,i_error_code,i_error_message);
    -- this
    dbms_out.put_line('this');
    end insert_error;

  • OracleDbType for function OBJECT return type

    Hi all,
    I inherited an oracle function that has an object as a return type:
    create or replace TYPE OBJECTPATH IS OBJECT (OBJECTID NUMBER);
    create or replace TYPE OBJECTPATH_TAB AS TABLE OF OBJECTPATH;
    create or replace FUNCTION GETOBJECTINPATH ( pobjectid in NUMBER, role1 varchar2, role2 varchar2 ) RETURN OBJECTPATH_TAB
    IS
    v_tmp_tab OBJECTPATH_TAB:=OBJECTPATH_TAB();
    parentid NUMBER;
    rowno INTEGER;
    BEGIN
    rowno:=0;
    parentid:=pobjectid;
    loop
    select objectid into parentid from dual left join (select ro2.objectid from relationshipobject ro1, relationshipobject ro2
    where ro1.role=role1 and ro2.role=role2 and ro1.relationshipid=ro2.relationshipid and ro1.objectid=parentid)
    on 1=1;
    if parentid is null then
    exit;
    end if;
    v_tmp_tab.extend;
    rowno:=rowno1;+
    v_tmp_tab(rowno) := OBJECTPATH(parentid);
    end loop;
    RETURN v_tmp_tab;
    END;
    On my application side, I am trying to run this function and retrieve the return value with ODP.NET as below. However, I am stumped when I need to supply an OracleDbType for the function return type.
    1. What is the OracleDbType I should use for the return type? I read that there used to be support for OracleDbType.Object, but it seems like it is now not supported. I am using ODP.NET 11g. Am I getting the situation correct?
    2. If retrieving an object return type is not as straightforward as setting the parameters (as what I have done below), what is the workaround to achieve it?
    OracleCommand runGetPObjectInPathCmd = new OracleCommand("GETOBJECTINPATH", conn);
    runGetPObjectInPathCmd.CommandType = CommandType.StoredProcedure;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("pobjectid", OracleDbType.Decimal)).Value = pobjectId;
    runGetPObjectInPathCmd.Parameters["pobjectid"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("role1", OracleDbType.Varchar2, 255)).Value = role1;
    runGetPObjectInPathCmd.Parameters["role1"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add(new OracleParameter("role2", OracleDbType.Varchar2, 255)).Value = role2;
    runGetPObjectInPathCmd.Parameters["role2"].Direction = ParameterDirection.Input;
    runGetPObjectInPathCmd.Parameters.Add("OBJECTPATH_TAB", OracleDbType.Decimal); // this is not correct as the return type is not a NUMBER
    runGetPObjectInPathCmd.Parameters["OBJECTPATH_TAB"].Direction = ParameterDirection.ReturnValue;
    runGetPObjectInPathCmd.ExecuteNonQuery();
    Thanks in advance for any help and would greatly appreciate it.

    Hi Greg,
    Thanks for your reply. I am not exactly sure whether I am using 11.1.0.6.21. The Oracle.DataAccess.dll I see under my \ODP.NET\bin\2.x directory is of Assembly/Product Version 2.111.6.0 - is this version 11.1.0.6.21? I also do not have the samples directory. Am I working on a wrong version? Thanks for your patience as I am really new to this and appreciate your guidance.

  • DatabaseProcedure with return type prefixed with schema name

    Hi (Paco)
    I have a question about the DatabaseProcedure class. We are using Oracle proxy users for our database connections.
    Everything is accessed via a database role that are granted to the logged on user. All our database objects, tables etc are protected with this database role.
    When I want to call a database function/procedure I need to add the schema name as a prefix to the custom database object that we uses for parameters/return types.
    So far so good. I can also define a parameter prefixed with schema name via the DatabaseProcedure.registerArrayType ...
    But when I try to define a function call that uses this parameter I get an error saying "Declaration is not valid".
    The problem is located to the PROCEDURE_DEFINITION regular pattern:
    private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL); The return type cannot be prefixed with the schema name.
    Any good suggestions or workarounds?!
    I actually did change the pattern runtime via reflection to make it work - but I really don't like this solution in the long run!
    /Torben
    Edited by: Zonic on 2013-05-07 10:52

    Hi Torben,
    I think I have a workaround for the issue that might work for you. If you look at the source of <font face="courier">DatabaseProcedure.registerArrayType</font> you find that it actually calls <font face="courier">DatabaseProcedure.registerCustomParamType</font>.
    public static void registerArrayType(String name)
      registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name);
    }As a workaround you could replace your calls to <font face="courier">DatabaseProcedure.registerArrayType</font> with calls to <font face="courier">DatabaseProcedure.registerCustomParamType</font> as follows.
    // Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call:
    DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here.
    DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)");
    DatabaseProcedure.ParamType type = dp.getParamDef(0).getType();
    System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTSThis way you don't have to use the "illegal" name in the DatabaseProcedure definition.
    Regards,
    Paco van der Linden

  • How to create a webservice with return type File

    Hi All,
    I have a class Letter and I am trying to expose viewReport as webservice.
    In Jdeveloper -> Business teir -> webservices -> Java web service and I have selected my method i.e. viewReport
    Now it throws error "The return type java.io.File of method viewReport can not be serialized into XML"
    I unserstood the issue but How can I achive this in JDeveloper
    public class Letter {
    public Letter() {
    super();
    public File viewReport(String name) {
    File folder = new File("C:\\APPS\\root\\pdf\\10052011");
    File[] listOfFiles = folder.listFiles();
    return listOfFiles[0];
    }

    You can't as File is nor serializable. It won't make sense as you would try to give a handle to a file on the server hosting the service to a remote system.
    Can you explain the use case in more detail?
    Timo

  • Is it possible to call dll-functions with records/types as arguments?

    or must I use the fixed preselection of types

    LabVIEW must call DLLs with data types it is compatible. Therefore, you must use the types available through LabVIEW.
    I have two pieces of advice on this matter:
    First, contact NI and get their advice on how to call your data type. They may be able to offer a very quick solution.
    Second, if you cannot call these data types, and you have a compiler, I would suggest "wrapping" the DLL inside another, and 'translate' the data type from something LabVIEW can handle, to the type needed by your DLL in this 'wrapper' DLL.

  • Error while creating function with record type as return type

    Hi i tried the following code to get the nth highest sal using record type and function.
    CREATE OR REPLACE PACKAGE pack_rec_cur AS
    TYPE rec_type IS RECORD (
    name EMP.ename%TYPE,
    sal EMP.sal%TYPE);
      END;The above package is created
    CREATE OR REPLACE
      FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
       rec pack_rec_cur.rec_type;
        CURSOR cur_rec IS
          SELECT ename,sal
            FROM emp
             WHERE sal is not null
              ORDER BY DESC;
    BEGIN
    OPEN cur_rec;
      FOR i IN 1..n LOOP
       FETCH cur_rec into rec;
       EXIT WHEN cur_rec%NOTFOUND;
      END LOOP;
    CLOSE cur_rec;
    RETURN rec;
    END;   The above function is giving errors
    LINE/COL ERROR
    4/7      PL/SQL: SQL Statement ignored
    7/16     PL/SQL: ORA-00936: missing expression
    SQL> Could you please correct me where i'm doing mistake
    Thanks.

    You are missing the column name in order by clauase. Is it ename desc?
    CREATE OR REPLACE
      FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
       rec pack_rec_cur.rec_type;
        CURSOR cur_rec IS
          SELECT ename,sal
            FROM emp
             WHERE sal is not null
              ORDER BY ENAME DESC; ---added ename
    BEGIN
    OPEN cur_rec;
      FOR i IN 1..n LOOP
       FETCH cur_rec into rec;
       EXIT WHEN cur_rec%NOTFOUND;
      END LOOP;
    CLOSE cur_rec;
    RETURN rec;
    END;  
    -OUTPUT
    SQL> SET SERVEROUT ON
    SQL>
    SQL> DECLARE
      2     rec            pack_rec_cur.rec_type;
      3  BEGIN
      4     rec         := fun_rec_cur (6); --you get the 6th record in order of ename desc
      5     DBMS_OUTPUT.put_line ('ename::' || rec.NAME || '  sal ::' || rec.sal);
      6  END;
      7  /
    ename::MARTIN  sal ::1250
    PL/SQL procedure successfully completed.
    SQL>

  • How to define a function with table type parameter

    Hello All,
    Here is the requirement ..
    cursor c is select first_name, last_name , ssn from employee ;
    TYPE employee_type IS TABLE OF c%rowtype;
    tbl_employee_type employee_type;
    I want to pass the parameter to a function the ssn -: tbl_employee_type(1).ssn
    how the formal parameter should be declared
    ===========================
    function chk_notnull_blank ( ? ) return boolean is
    BEGIN
    if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
    RETURN TRUE ;
    else
    RETURN FALSE ;
    end if;
    END chk_notnull_blank;
    ======================
    pls advice
    thanks/kumar

    You cannot define a generic argument in a function,
    but you can overload several funtions with the same name and different types of arguments in a package,
    in this way (not tested):
    create table employees as
    select employee_id ssn, first_name, last_name from hr.employees;
    create or replace
    PACKAGE chk
    IS
      cursor c is select first_name, last_name , ssn from employees ;
      TYPE employee_type IS TABLE OF c%rowtype;
      TYPE employee_ssn_type IS TABLE OF employees.ssn%TYPE;
      TYPE employee_num_type IS TABLE OF number;
      FUNCTION chk_notnull_blank ( colname  employees.ssn%TYPE) RETURN boolean;
      FUNCTION chk_notnull_blank ( colnames  employee_type) RETURN boolean;
      FUNCTION chk_notnull_blank ( colnames  employee_ssn_type) RETURN boolean;
      FUNCTION chk_notnull_blank ( colnames  employee_num_type) RETURN boolean;
    END chk;
    create or replace
    PACKAGE BODY chk
    IS
      FUNCTION chk_notnull_blank ( colname  employees.ssn%TYPE) RETURN boolean IS
      BEGIN
        if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
          RETURN TRUE ;
        else
          RETURN FALSE ;
        END IF;
      END chk_notnull_blank;
      FUNCTION chk_notnull_blank ( colnames  employee_type) RETURN boolean IS
      BEGIN
         FOR i IN colnames.FIRST .. colnames.LAST LOOP
            IF NOT chk_notnull_blank( colnames( i ).ssn )
            THEN
               RETURN FALSE;
            END IF;
         END LOOP;
         RETURN true;
      END chk_notnull_blank;
      FUNCTION chk_notnull_blank ( colnames  employee_ssn_type) RETURN boolean
      IS
      BEGIN
         FOR i IN colnames.FIRST .. colnames.LAST LOOP
            IF NOT chk_notnull_blank( colnames( i ) )
            THEN
               RETURN FALSE;
            END IF;
         END LOOP;
         RETURN TRUE;
      END chk_notnull_blank; 
      FUNCTION chk_notnull_blank ( colnames  employee_num_type) RETURN boolean
      IS
      BEGIN
         FOR i IN colnames.FIRST .. colnames.LAST LOOP
            IF NOT chk_notnull_blank( colnames( i ) )
            THEN
               RETURN FALSE;
            END IF;
         END LOOP;
         RETURN TRUE;
      END chk_notnull_blank; 
    END chk;I assumed in this example that if the argument of the function chk_notnull_blank is of the table (collection) type,
    then the function returns true if all table elements pass the check, otherwise it returns false.

  • Calling Java Function with Return as String []

    Hi,
    I have written the following code. It's not compiling OK.
    DECLARE
    TYPE Tokens_Type IS VARYING ARRAY(20) OF VARCHAR2(20);
    s1 Tokens_Type DEFAULT NULL;
    SQL_STR VARCHAR2(2000) DEFAULT NULL;
    BEGIN
    SQL_STR := 'CREATE OR REPLACE FUNCTION Schema1.SPLIT_STR (S2 VARCHAR2(20)) '           ||
    'RETURN s1 '               ||
    'AS LANGUAGE JAVA '          ||
    'NAME ''String_Mani.split_it (String) return java.lang.String []''';
    EXECUTE IMMEDIATE SQL_STR;
    END;
    What's the problem with this?

    Hi,
    I have written the following code. It's not compiling OK.
    DECLARE
    TYPE Tokens_Type IS VARYING ARRAY(20) OF VARCHAR2(20);
    s1 Tokens_Type DEFAULT NULL;
    SQL_STR VARCHAR2(2000) DEFAULT NULL;
    BEGIN
    SQL_STR := 'CREATE OR REPLACE FUNCTION Schema1.SPLIT_STR (S2 VARCHAR2(20)) ' ||
    'RETURN s1 ' ||
    'AS LANGUAGE JAVA ' ||
    'NAME ''String_Mani.split_it (String) return java.lang.String []''';
    EXECUTE IMMEDIATE SQL_STR;
    END;
    What's the problem with this?

  • Using PL/SQL Function with CLOB types and a Java Source

    Hi people.
    I have some problems trying to use a function in pl/sql with a CLOB parameter to a java source function.
    Here is the problem: I have to read a TXT file and return a CLOB with the data of the file. The reading is done with a java source function.
    The problem is how to read the file without messing the content and return it to the pl/sql function?
    Another problem: If I pass a CLOB as a parameter to a pl/sql function and have to write the content to a file, how to do it without screwing the EOL chars and so?
    My code is:
    /******** PLSQL FUNCTIONS ********/
    function fn_gravaconteudoarquivo( pv_caminho in varchar2
    , pv_nomearquivo in varchar2
    , pc_conteudo in clob ) return varchar2 as language java
    name 'Importacao.gravaConteudoArquivo(java.lang.String, java.lang.String, oracle.sql.CLOB) return varchar2';
    function fn_lerconteudoarquivoclob( pv_caminho in varchar2
    , pv_nomearquivo in varchar2 ) return clob as language java
    name 'Importacao.lerArquivoClob(java.lang.String, java.lang.String) return clob';
    /******** JAVA SOURCE FUNCTIONS *********/
    public static String gravaConteudoArquivo(String caminho, String nomeArquivo, CLOB conteudo) {
    File file = new File(caminho, nomeArquivo);
    PrintWriter pwFile;
    String mensagem = "";
    StringBuffer sb = new StringBuffer();
    try {
    pwFile = new PrintWriter(new BufferedWriter(new FileWriter(file,true)));
    for (int i=0;i<=(conteudo.length()/32000);i++) {
    sb.append(conteudo.getSubString(conteudo.getLength()+1,32000));
    pwFile.println(sb.substring(0));
    pwFile.close();
    } catch (Exception ex) {
    mensagem = "Erro: "+ex;
    return mensagem;
    public static CLOB lerArquivoClob(String caminho, String nomeArquivo) throws SQLException {
    File file = new File(caminho, nomeArquivo);
    Connection conn;
    CLOB clob = null;
    String lineSep = System.getProperty("line.separator");
    StringBuffer sb = new StringBuffer();
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:csdesv", "csestoque", "liberada");
    clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    BufferedReader brFile = new BufferedReader(new FileReader(file.getPath()));
    while (brFile.ready()) {
    sb.append(brFile.readLine());
    sb.append(lineSep);
    clob.open(CLOB.MODE_READWRITE);
    clob.setString(clob.getLength()+1, sb.toString());
    clob.close();
    } catch (Exception ex) {
    ex.printStackTrace();
    return clob;
    Ah, just remembered... This will work as a JOB.... >.< ... So the connection aparently is at localhost.
    Thanks.

    No one? I really need this....

  • Implementing Empty Versions of Interface Methods with Return Types

    Subject probably is probably a bit long but I was stumped for a brief way to summarize my question. Let's say I have the interface below:
    public interface DAO {
        ...snip...
        public Object get(int id);
        public Object[] get(String clause);
        ...snip...
    }From this I want to make two concrete classes, say ClassOne and ClassTwo. Given the type of data each one is fetching, ClassOne only needs (and should only) implement get(int id) and ClassTwo only needs (and should only) implement get(String clause). This is because the first class will always deal with only one record from table_a and the second class will always deal with one or more records from table_b. So my question is what is the correct way to provide empty implementations for the unnecessary methods?
    I've thought of using an adapter to implement empty methods but a) I'm not sure that makes sense and b) I still end up have to return something. Another option was maybe having multiple interfaces, one returning a single object and the other returning an array. Neither of those options felt right and looked a bit goofy when I prototyped them out. It seems to me that I wouldn't want the classes using the concrete DAO classes to be able to call the wrong method, but I don't know how to hide the unused method. Right now I just return an empty Object or Object[] for the unused method but that seems goofy too, and makes the class using ClassOne or ClassTwo know the innards of the implementations.
    Anyway, any tips appreciated.
    Thanks,
    Pablo

    It sounds as if the methods weren't meant to be together, and so I'm wondering if you aren't better off with two distinct interfaces, one for each method. Otherwise one solution would be to implement a method that throws an exception if it is not meant to be called.
    edit: D'oh! Just when you least expect them, Ninjas! They're everywhere!
    Edited by: Encephalopathic on Apr 30, 2009 1:41 PM

Maybe you are looking for

  • S110 menu button not working

    Hi,  We're on our honeymoon and been taking good pictures without any problems with Canon S110 until yesterday. The camera suddenly has the following problems: 1. turn on normally but then immediately taking one photo no matter what mode it's on.  2.

  • LR 5 exporting low res files

    Hi My LR5 is exporting low res files for some weird reason. I figure it has to do with the fact that I recently started using the smart preview  function. What made me almost 100% certain is has to do with this is the fact that I removed the hard dri

  • How do I make a side-by-side photo with my iphone 5c?

    I want to take two pictures and put them side-by-side to make one picture. Can you help?

  • I Need Help Whit Adobe After Efects CS6

    I have 32 bit operativ sistem and i really need adobe after efects cs6 case i wonna be film maker ! Now when i start my Adobe Download Assistent and login,select ae cs6,it says that i need to restart Adobe Download Assistent! I did that a 1000 times

  • Slipstreaming: Creating a WindowsXP Install CD with Service Pack 2

    Hi, Could someone who has done this using a Mac, and knows how, please give a step by step to making this CD? All the instructions online show how to do it from a PC running Windows. I have no clue how to do it on a Mac. Could someone please explain?