Block PL/SQL function call

Hello

A very simple question.

A have a function called "test1" in my database. This is where, I double undercover.

I want to call this function from a block:


DECLARE

BEGIN
TEST1 (1202);
END;


It gives me an error.
Why is this?

Hello

user610868 wrote:
OK, but why is - this?

For example:

Current_Row v_real_data % ROWTYPE;

SELECT * IN current_row r v_real_data where are.id_key = key;

I expect this to leave empty current_row rather than raise an error.

This is how it works inside a function.
Otherwise, it triggers NO_DATA_FOUND. If you find that inconsistent, then you have company, but of the tht like that.

T.PD wrote:
in PL/SQL, you need to assign the return value of the function to a variable (or pass it as a parameter to a som other PL/SQL code).

Or use it as an operand, for example:

IF  test1 (1202) > 0
THEN ...

The point is you need to do something with the value. A value in itself is not a valid statement of PL/SQL.

Tags: Database

Similar Questions

  • A c from pl/sql function call

    Hello

    I'm testing a simple case to call a C function from a pl/sql block.

    Here's my test case (came to :)

    TST.c:

    #include < ctype.h >

    #include < stdio.h >

    int upcase (char * istr, char * ostr)

    {

    int i = 0;

    While (ISTR)

    {

    OSTR [i] = toupper (istr [i]);

    i ++ ;

    }

    return 0;

    }

    // compile
    gcc -fPIC -c tst.c

    // create shared object

    ld -shared -o libtest.so tst.o

    file libtest.so

    libtest.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

    // wrapper library and function

    SQL> create or replace library libtest as '/home/oracle/libtest.so';
    /
    Library created.


    create or replace function upcase (instr in varchar2, outstr out varchar2) return directory is

    external

    libtest library

    name 'upcase '.

    C language

    call the standard C

    settings)

    string InStr,

    outStr string

    );

    /

    Listener.ora:

    LISTENER =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(Host = server1) (Port = 1521))

    (ADDRESS = (PROTOCOL = ipc) (KEY = EXTPROC))

    )

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (GLOBAL_DBNAME = PRD_DGMGRL)

    (ORACLE_HOME = home/app/product/11.2.0/jko)

    (SID_NAME = PRD)

    )

    (SID_DESC =

    (ORACLE_HOME = home/app/product/11.2.0/jko)

    (SID_NAME = PLSExtProc)

    (= Extproc PROGRAM)

    (ENVS = "EXTPROC_DLLS = ANY")

    )

    )

    LOG_DIRECTORY_LISTENER = / home/app/network/log

    CONNECT_TIMEOUT_LISTENER = 10

    TRACE_DIRECTORY_LISTENER = / home/app/network/trc

    STARTUP_WAIT_TIME_LISTENER = 0

    USE_PLUG_AND_PLAY_LISTENER = OFF

    ADMIN_RESTRICTIONS_LISTENER = WE

    LOG_FILE_LISTENER = listener.log

    TRACE_LEVEL_LISTENER = OFF

    tnsnames.ora:

    EXTPROC_CONNECTION_DATA =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = ipc) (KEY = EXTPROC))

    (CONNECT_DATA = (SID = plsextproc))

    )

    declare

    str1 varchar2 (20);

    VARCHAR2 (20) str2;

    Directory of RC;

    Start

    str1: = "Hello World";

    RC: = upcase (str1, str2);

    dbms_output.put_line (' rc ='|) RC: ' instr =' | str1 |' outstr =' | str2);

    end;

    /

    declare

    str1 varchar2 (20);

    VARCHAR2 (20) str2;

    Directory of RC;

    Start

    str1: = "Hello World";

    RC: = upcase (str1, str2);

    dbms_output.put_line (' rc ='|) RC: ' instr =' | str1 |' outstr =' | str2);

    end;

    /

    ERROR on line 1:

    ORA-28576: interruption of the RPC connection to the external procedure agent

    ORA-06512: at "SYS." UPCASE', line 1

    ORA-06512: at line 7

    How I did wrong?

    Thanks a lot for your help

    jko

    The error means generally that your external procedure (process c in this case), failed or crashed.

    The details of the Oracle error:

    28576, 00000, "loss of the RPC connection to the external procedure agent."
    * Cause: A fatal error occurred either a RPC network connection.
    agent extproc or the invoked 3GL after disclosure
    was created successfully.
    * Action: First check the 3GL code you are calling; the most likely
    This error is an abnormal termination of the
    called 'C' routine. If this is not the case, look for
    network problems. Correct the problem if you find. If all the
    components appear normal, but the problem persists, the
    problem could be an internal logic error in the transfer of the CPP
    code.  Contact your customer support representative.

    Probably the dynamic loader used by the kernel to resolve external dependencies than physical of the executable failed?

    Mike Board solves the problem? IMO, it should...

  • In PL/SQL function call

    Hi all

    I would like to know if there is in any case to call a user defined function in a SQL statement in an anonymous PL/SQL block without having created this function to the database.

    For example:

    I have a pl/sql block:

    DECLARE

    BEGIN

    UPDATE application SET map_No = nts_map_no (parm1, parm2, parm3) WHERE...

    END;

    I tried to declare the function within the declare block section as in:

    DECLARE

    FUNCTION nts_map_no
    :
    :
    End nts_map_no;

    BEGIN

    UPDATE application SET map_No = nts_map_no (parm1, parm2, parm3) WHERE...

    END;

    But Oracle would not allow me to use it in an Update statement.

    Thank you.

    Denis

    There are a few things you can do.

    Simpler, faster: define a function stored (either packed or not) separately from your anonymous block - as BlusShadow said

    Easy, slow: definition of the function in the anonymous block, read the data that you want to update in the memory of PL/SQL, update of your function:

    declare
       function nts_map (...)
    begin
       for r in (
          select rowid, pk, map, parm1, parm2. ...
          from target
          where ...
          )
       loop
          update current of r set map = nts_map_no(parm1, parm2, parm3);
    -- or
          update target set map= ... WHERE target.rowid = r.rowid
       end loop;
    

    This treatment of line will be much slower than a single UPDATE sets. Of course the use of operations BLOCK helps - but still slow.

    Complex: If you really need to define the function in the same anonymous block, use EXECUTE IMMEDIATE - but we must be aware of dependencies (don't let not the creation of the function cancel something the rest of the anonymous block depends on...).

    SQL> r
      1  declare
      2     li_result integer;
      3  begin
      4
      5     execute immediate 'create or replace function f(p in varchar2) return integer is begin return sqrt(to_number(p)); end;';
      6
      7     select f('36') into li_result from dual;
      8
      9     dbms_output.put_line('Result='||li_result);
     10* end;
    Result=6
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    Note that the two options (1) and (3) need you to the CREATE FUNCTION - if (1) privilege is much easier and safer in most cases.

    Nigel cordially

  • PL/SQL function call

    Weird. There was text in the box when I pressed send...

    I'll call a PL/SQL javascript function. I've done this process several times, but for some reason, it does not work with this application. Our company just the Apex 3.2.0.00.27 version, so I don't know if it's related or not, since this is the first time I am trying this feature in the new version. This is a test function, I'm running, but full function, I am running for my application does the same thing.

    Here's the javascript code:
    function submitForm() {}

    get var = new htmldb_Get (null, $x ('pFlowId') .value, 'APPLICATION PROCESS = PROC_TEST', 0);
    Alert (Get.get ());
    return;

    }

    PL/SQL is located in a level with an option on request application process.
    DECLARE varTest varchar (12): = NULL;
    BEGIN

    SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD') IN the varTest FROM DUAL;
    HTP.p (varTest);

    END;

    The javascript is called from a HTML button:
    < input type = "button" id = "button1" value = "Submit Request" tabIndex = "25" onclick = "submitForm (); "/ >

    I used alerts to check the JavaScript starts, runs and completes successfully. I've also intentionally added errors for the PL/SQL to try to get the reactions of the application. The alert function returns only the message "process not found.

    I hope that the eyes of certain fees can see what I've been unable to.

    Thank you
    Chris

    get var = new htmldb_Get (null, $x ('pFlowId') .value, 'APPLICATION PROCESS = PROC_TEST', 0);

    I think that there is a typing error - there should be underscore between APPLICATION and PROCESS. But if your code contains not this error then make sure that the name of the process is PROC_TEST and not proc_test. the name is case-sensitive.

    Scott

  • What is the best way to optimize a SQL query: call a function or doing a join?

    Hi, I want to know what is the best way to optimize a SQL query, call a function inside the SELECT statement, or make a simple join?

    It depends on.  Could be a.  Could be the other.  Could be no difference.  You would need to compare with your tables in your environment with your settings.

    If you put a gun to my head, I was given no other information and required that I answered the question, I would tend to wait that the join would be more effective.  In general, if you can do something in pure SQL, it will be more effective than if you call PL/SQL.

    Justin

  • BEEP 10 g call a PL SQL function

    Hello..
    It's really breaking the feet... googled a lot but always back to square start.
    ... Well guys want to help me...

    I need to call a function from PL SQL BI editor passing 3 parameters.

    that means this feature is... it feeds a table.
    And the editor of BI report is read from the populated table...

    Kindly help me out here... How can I start...

    PL SQL function is a stand-alone... It is not under any procedure/package...

    If you could give me some small excerpts of what to write in the style of data... that would be great... and Yes, indeed, this is the old version of the BEEP... 30%

    >
    Total Questions: 11 (10 open)
    >
    Why can't anyone help you?

    >

    He throws me an error
    Variable binding does not exist

    any work arounds guy?
    >
    so

    
    

    and in z_report_sys_op_test_pkg.z_report_sys_op_test get the necessary value
    >
    substr (: Store, 0, InStr(:Store,'-') - 1).

  • How to call PL/SQL function processRequest

    Hello

    I'm trying to run a function called xxhr_trg_evaluation_pkg.xx_get_class_desc (1);

    How can I run the above inside the processRequest function and pass the value returned in a variable string.

    Thanks in advance

    Kind regards... Ashraf

    Ashraf,

    The following code will help you how to call the function or procedure in processRequest.

    processRequest Code:

    {} public processRequest Sub (pageContext OAPageContext, OAWebBean webBean)

    Oaam = pageContext.getApplicationModule (webBean) OAApplicationModule;
    OADBTransaction dbtrans;
    TXN OADBTransaction = (OADBTransaction) oaam.getOADBTransaction ();

    statement that even execute the statement as pl/sql in Toad
    = Txn.createCallableStatement cs CallableStatement ("start: 1: = xxhr_trg_evaluation_pkg.xx_get_class_desc (: 2); end;", 0);

    variable will contain the return value
    String outputVal ="";

    pass the value of the entry to the callable statement
    try {}
    cs.setString(2,1+"");

    }
    catch (Exception e) {}
    }

    try {}
    CS. Execute();
    outputVal = cs.getString (1);
    }
    catch (Exception e) {}
    }

    try {}
    CS. Close();
    }
    catch (Exception e) {}
    }
    Did all the insert/update/etc means do validation of here too but you did not engage in the service by using the following syntax
    dbtrans.Commit ();

    }

    Thank you
    SAN

  • How to call the pl/sql function in application of the ADF

    Hi Experts,

    I need to call the pl/sql function in application of ADF, I have logic written in my AM

    Method:

    public String reportStoredProcedure (locationID customerID, number,
    String tailNum) {}

    CallableStatement st = null;
    String v_sanctioned = null;
    If (locationID! = null & & customerID! = null & & tailNum! = null) {}
    System.out.println (locationID + "" + customerID + "" + tailNum);
    Tail string = "TAIL";
    String result = "N";

    try {}
    String stmt =
    "start XXWFS_SANCTIONS_PKG. CHECK_SANCTION(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11); end; « ;
    St = getDBTransaction () .createCallableStatement (stmt, 0);
    st.setNull (1, Types.VARCHAR);
    st.setNull (2, Types.NUMERIC);
    st.setObject (3, customerID);
    st.setNull (4, Types.NUMERIC);
    st.setNull (5, Types.NUMERIC);
    st.setObject (6, locationID);
    st.setNull (7, Types.NUMERIC);
    st.setNull (8, Types.NUMERIC);
    st.setObject (9, tail);
    st.setObject (10, tailNum);
    st.setObject (11, result);
    St.Execute ();
    System.out.println ("v_sanctioned in AM:" + v_sanctioned);
    } catch (Exception e) {}
    e.printStackTrace ();
    return "N";
    } {Finally
    If (st! = null)
    try {}
    St.Close ();
    } catch (Exception e1) {}
    E1. PrintStackTrace();
    return "N";
    }
    }
    } else {}
    System.out.println ("v_sanctioned is null");
    v_sanctioned = "N";
    }
    Return v_sanctioned;
    }


    Error:

    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in the call to 'CHECK_SANCTION '.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:191)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:950)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1224)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3487)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:3858)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
    at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:99)
    at model.view.CardAMImpl.reportStoredProcedure(CardAMImpl.java:182)
    at com.emboss.bean.ReadyToPrint.invokeVSanctioned(ReadyToPrint.java:485)
    at com.emboss.bean.ReadyToPrint.PrintingCards(ReadyToPrint.java:434)
    at com.emboss.bean.ReadyToPrint.printCards(ReadyToPrint.java:204)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1259)
    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
    at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:97)
    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:90)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:94)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:91)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:812)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:292)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97)
    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:420)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:420)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:94)
    at java.security.AccessController.doPrivileged (Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:414)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:138)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.doIt (WebAppServletContext.java:3684)
    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3650)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Can someone help me how to call...

    Call it in function, not as a procedure you do

    try {
    String stmt =
    "begin :1 := XXWFS_SANCTIONS_PKG.CHECK_SANCTION(:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12); end;";
    st = getDBTransaction().createCallableStatement(stmt, 0);
    st.registerOutParameter(1, Types.VARCHAR);
    st.setNull(2, Types.VARCHAR);
    st.setNull(3, Types.NUMERIC);
    st.setObject(4, customerID);
    st.setNull(5, Types.NUMERIC);
    st.setNull(6, Types.NUMERIC);
    st.setObject(7, locationID);
    st.setNull(8, Types.NUMERIC);
    st.setNull(9, Types.NUMERIC);
    st.setObject(10, tail);
    st.setObject(11, tailNum);
    st.setObject(12, result);
    st.execute();
     = st.getString(1);
    
  • call the XMLQuery pl sql function

    Hi all.
    Is anyone know how to call the function sql pl by XMLQuery query?

    For example:

    I pl sql function "test()".

    And the desire to write this way:

    Select XMLQuery (' let $t = test()' returning content);

    How to change to work?

    Thanks for all the answers.
    Kind regards
    Anton.

    following should give you an idea:

    SQL> select xmlquery(('if (2*2 = ' || power(2,2) || ') then 1 else ()') returning content) x from dual
    
    X
    -----
    1
    1 row selected.
    
  • Calling a SQL function to send all page

    In an APEX application, is it possible to call a SQL function so that the application be submitted instead of 'action SQL INSERT'. This function takes 2 parameters user entering the page of the application.

    Send page has essentially two text fields and a "submit" button
    Version and Patch Info

    The SQl function has 2 parameters like this, start_new_env (oracleversion IN VARCHAR2, opatchinfo IN CLOB)

    Any help will be much appreciated.

    Thank you

    Published by: Rajesh on November 17, 2009 08:49

    Please mark it as answered and mark it as correct...
    Thank you

  • Process: a function call

    Hello

    I wonder what are 'best practices' to call a pl/sql function in the 'processing of the page"->"after submit' events?

    Example:

    I have a plSql function that returns a 'boolean' as the indicator of success/failure of the call. I wonder how I would incorporate the value of (this function) return in "after submit' logic?

    My line of thought is:

    press a button 'create', which calls a function. Now, I guess I need to validate the return value and depending on the result, either display an error message or a success message.

    I have to write my own wrapper in this situation:

    Start

    If the value returned by the function is! Ok then

    raise the error() application;

    end;

    or is there a better way?

    Hi AZZ.

    First you must get rid of your C-like habbits you have a function and (usually) returns 0 if called successfully, otherwise returns something else, and then test the return value and do other things depending on what is returned. In APEX, a process is a block of code that is executed successfully (for example, without exception) or fails and generates an exception. Also note that although it is quite right to put this code in a process

    begin
         null;
    end;
    

    slightly modified code

    begin
         return 0;
    end;
    

    produces a lot of exceptions. This process of page are supposed to simply not to return something but it doesn't matter - fortunately we have a feature how to manage success and error messages. There is a success Message text box where you can place a few generic message or if you want have more personalized it, you can for example create an item hidden on your page like PX_SUCCESS_MSG and set its value somewhere in the process (like: PX_SUCCESS_MSG: = "Bravo, all records deleted") and then use it in your message of success (you should have in your success message window something like "My message success: & PX_SUCCESS_MSG. without quotation marks"). Note that it must be before ampersand and point after the name of the element.

    The same thing with an error message - you can use a generic a handset with the Oracle error message (put there "error: #SQLERRM #") or if you want to have a custom error message, use the API APEX_ERROR https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_error.htm#AEAPI2217 in your process.

    Kind regards

    Pavel

  • Dynamic action to execute PL/SQL that calls a JavaScript alert - does not

    Greetings,

    I'm stuck!  I use the Apex Version 4.2.2.  I have a requirement that, when the user fills Field1, I check the database to see if the value of field1 has already been used.  If it was used, I have to inform the user, but the user is allowed to reuse the value - that is to say, duplicates are allowed.  My thought is to use a dynamic action to check the onchange of value running pl/sql to check (via a function in the database) and if it returns true, use a javascript alert to inform my user value is used.  They can then close the alert and change (or not change) the duplicate value

    I did the following:

    1 wrote a PL/SQL function in my utility package in the database - we'll call it apps.my_utils.check_value_use (p_my_val in varchar2) return Boolean - it works.

    2. created a dynamic Action with the following properties for P1_FIELD1:

    Event: change

    Selection type: item (s)

    Product (s): P1_FIELD1

    Condition: is not null

    3. the dynamic Action has an action - real Action

    Action: Execute the PL/SQL Code

    Page items to submit: P1_FIELD1

    PL/SQL code:

    BEGIN

    IF apps.my_utils.check_value_use(:P1_FIELD1) = TRUE THEN

    HTP.p ("< script type =" text/javascript "> '");

    HTP.p ("alert (" this value is used ""); ")

    ');

    HTP.p ("< /script >" ");

    END IF;

    END;

    When I run the page and fill in Field1 with a value that I know is in use, I get the following error:

    Error: parsererror - SyntaxError: JSON.parse: unexpected character

    Help, please.  I already spent too much time on this apparently simple requirement.

    Thank you

    J.

    BEGIN

    IF apps.my_utils.check_value_use(:P1_FIELD1) = TRUE THEN

    HTP.p(' ');

    END IF;

    END;

    Avoid doing this. Try the following method:

    (1) create a dummy hidden element to store the result of your validation of PL/SQL. Lets call it P1_DA_ERR

    (2) in your PL/SQL block put this point hidden in the field "Page point back.

    (3) in your PL/SQL block placed the result of your validation in this element hidden as

    DECLARE
    l_err PLS_INTEGER := 0;
    BEGIN
    -- An example
    IF 1=1 THEN
    l_err := 0;
    ELSE
    l_err := 1;
    end if;
    :P1_DA_ERR := l_err;
    END;
    

    (4) add a true other "Run Javascript code" type action. The could should look like:

    if(parseFloat($v('P1_DA_ERR'))==1)
    {
    alert('Error occurred');
    }
    
  • Reg: Count function call-

    Hi Experts,

    I am tracking my processing batch every night and find a particular function called many times.

    Is it possible that I can find how many times it was performed in a given period of time?

    AWR? Or, any dynamic view v$ _?

    Please notify.

    Thank you and best regards,

    -Nordine

    (on Oracle 10.2.0.4.0)

    Asked me the same question to the company less than a month ago so I can shed some light on this particular situation (not too much).

    Some (say seven) years ago our thinkers came up with the idea of VAE and apparently I was the only one who objected to the approach (https://www.simple-talk.com/opinion/opinion-pieces/bad-carma/ and articles in several Tom Kyte has had no effect he was only harmful for me - no promotion,...).

    Therefore, the number of attributes is greatly increased and the situation becomes more and more unbearable.

    As it is mandatory to call for attribute values, it is not just online treatment, plans sql also suffer (calling functions for each line) that the same functions are called from sql too.

    Verification of AWR reports it turns out that some functions that provide attribute values are called more than a hundead million times a day, and as we call them around there is little use querrying dependencies without taking into account the volumes of data (if only someone knew how).

    So something like WHO_CALLED_ME is required to identify the heaviest appellants and (much more than that), it is a problem of how silently (as much as possible) reduce the number of attributes where nobody is now willing to admit the decision was wrong or (not even in my dreams) that I was right.

    As far as I KNOW two attributes have been removed these time and proclaimed a spectacular feat of tuning.

    Chi lives, vedra that lets say our Italian neighbours.

    Concerning

    Etbin

  • PL/SQL functions as LOV to use in another display object

    Hello

    We had a custom search to extract data from a display object and the data displayed as a Table of ADF. Now, there are few requests for searches on this report. Go see criteria and Panel request if we allow saved search. But the fields used in the research are going through a lot of logic and thus the PL/SQL functions are implemented. We used to call these functions and lists separated by commas and then divided the list into individual elements and put in the component "select options".

    The value (String) returned by the pl/sql function is something like - APAC, EMEA, NORTH AMERICA, FDA

    I am creating a LOV based on SQL-query "Select getRegions() from dual;

    Now, I want the list separated by commas to divide so that I could use this LOV in an another view and try the display criteria and saved searches.

    I tried to assign as LOV just to check and the criteria drop-down view for region displays same value as single element - "APAC, EMEA, NORTH AMERICA, LAD."

    I want it to be 4 separate - elements

    APAC

    EMEA

    NORTH AMERICA

    DVL

    Is there anyway to achieve this?

    Or better is at - it another way to do this (maybe I'm wrong)

    Thank you.

    JDev: 11.1.2.4

    Instead of a programmatic VO of PL/SQL, I found sometimes easier to write PL/SQL functions that return a table - need to CREATE a TYPE for the data items to be returned and a TYPE of TABLE IMBRIQUE tabular form of the first kind.  The function returns the type of table, and can even be a PIPElined table function.  Then I create a VO with the following text:

    SELECT * from TABLE (my_function_returning_table)

    The function can even take parameters, which you fill with variable BIND your VO.

  • ORA-06503: PL/SQL: function returned no value ORA-06512:

    Hi all

    SQL > set serveroutput on

    SQL > CREATE OR replace FUNCTION qty_value (p_item_id number)

    2 RETURN NUMBER

    3 EAST

    4 v_qty_arrival NUMBER;

    5 BEGIN

    6. SELECT THE CASE SENSITIVE OPTION

    7. WHAT (SUM (b.quantity) - SUM (b.quantity_received)) < = 0 THEN 0

    8 ELSE (SUM (b.quantity) - SUM (b.quantity_received))

    9 END Qty_Arrival

    10 INTO v_qty_arrival

    Po_lines_all 11 a,

    po_line_locations_all 12 b

    13 WHERE a.po_line_id = b.po_line_id

    14 AND a.item_id = p_item_id;

    15 EXCEPTION

    16 THEN THAN OTHERS THEN

    17 v_qty_arrival: = NULL;

    18 RETURN v_qty_arrival;

    19 END qty_value;

    20.

    The function is created.

    SQL >

    SQL > select xxc_qty_arrivale (214960) double

    2.

    Select xxc_qty_arrivale (214960) double

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at the 'APPS '. XXC_QTY_ARRIVALE', line 19

    Back AFTER using the exception block is fine as long as your code actually REACHED the exception block.

    When there are no errors, then your code will not enter the exception block, but you still NEED to return a value, since it is what functions a function wants to return a value, that's what the functions are made for.

    Spot the differences between the following 3 functions. Understand how they work.

    The first function has only a return in the exception block but runs correctly. Result: error, because the back is missing in the code block.

    The second function has a return in the exception block and one in the block of code and runs correctly. Result: no error, because the return is not missing in the code block.

    The third function has a return in the exception block and one in the block of code and is forced into an error. Result: no error, because the return of the exception handler is used (instead of retriggering of the error, which you would normally do).

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7 exception

    8 then than others

    9. can

    10 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    11      --

    12 return 0;

    13      --

    14 end;

    15.

    The function is created.

    SQL > select double myfunc;

    Select double myfunc

    *

    ERROR on line 1:

    ORA-06503: PL/SQL: function returned no value

    ORA-06512: at "GHPLUS. MYFUNC", line 14

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    4 start

    5 dbms_output.put_line ('in the section of code');

    6 null;

    7    --

    8 return 1;

    9    --

    10 exceptional

    11 so that others

    12. can

    13 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    14      --

    15 return 0;

    16      --

    end 17;

    18.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    1

    1 selected line.

    In the section of code

    SQL > create or replace function myfunc

    2 return number

    3 as

    n number 4;

    5. start

    6 dbms_output.put_line ('in the section of code');

    7 n: = 1/0; -force an error (zero divisor) to join the exception handler

    8    --

    9 return 1;

    10-

    exception 11

    12 so that others

    13. can

    14 dbms_output.put_line (' in the exception handler ' |) SQLERRM);

    15      --

    16 return 0;

    17      --

    18 end;

    19.

    The function is created.

    SQL > select double myfunc;

    MYFUNC

    ----------

    0

    1 selected line.

    In the section of code

    In the handler for exception ORA-01476: divisor is equal to zero

    SQL >

Maybe you are looking for

  • IPhone stolen 4S free find my iPhone

    My iPhone 4S on iOS9 was stolen from me as I was getting on a bus the other day, but it didn't find my iPhone installed so I can't remove my data. The device has a password, but it is relatively easy to guess. Is there a possibility that the thief co

  • A6210 is malfunctioning simultaneous dual band

    Hi all I just got this card. I installed the latest drivers from netgear and I can see the connection is established at 866 Mhz. However, it does not connect in simultaneous dual band at all (the main reason I bought this card given). The router is a

  • Jealousy 5540: Problem load A4 photo paper in Envy 5540

    I don't see how to load A4 photo paper in the printer. There is a photo of the top tray, but it's only for smaller papers. If I put photo paper in the main tray, I get a message out-ot-paper when I try to print. All advice appreciated.

  • in windows, xp:shirtcut keys are missing and attach files are missing. How can I fix?

    I use windowx xp family and after uninstalling a program, suddenly atleaste the half of my Desktop Icons (shortcuts) are displayed with a generic icon and lack the key shortcut. When I try to open a program, an error message comes up saying Windows c

  • window mail contact restoration of system backup and restore files

    I backed up my system on a portable hard drive, he said, he would return to the top of my window vista email contacts and emails, but when I tried to restore themn he wasn't able to find it can help any one?