Oracle PL/SQL functions

Hi guys,.

When creating procedures and functions in PL/SQL please can someone explain the difference by using key words IS and YOU.

Best regards
Shaz

You can use either 'AS' or 'ARE' as you prefer.

See the PL/SQL language reference - http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#CHDBEJGF

There are a number of examples and uses these two. In here is a that uses IS

Example 8-3 Creating Nested Subprograms that Invoke Each Other

DECLARE
  -- Declare proc1 (forward declaration):
  PROCEDURE proc1(number1 NUMBER);

  -- Declare and define proc 2:
  PROCEDURE proc2(number2 NUMBER) IS
  BEGIN
    proc1(number2);
  END;

But this one uses AS

Example 8-17 Invoking an IR Instance Methods

-- OE creates a procedure that invokes change_job
CREATE PROCEDURE reassign
  (p IN OUT NOCOPY hr.person_typ, new_job VARCHAR2) AS
BEGIN
   p.change_job(new_job); -- executes with the privileges of oe
END;
/
-- OE grants EXECUTE to HR on procedure reassign
GRANT EXECUTE ON reassign to HR;

-- HR passes a person_typ object to the procedure reassign
DECLARE
   p1 person_typ;
BEGIN
   p1 := person_typ(1004,  'June Washburn', 'SALES');
   oe.reassign(p1, 'CLERK'); -- current user is oe, not hr
END;
/

Tags: Database

Similar Questions

  • No support for oracle sql functions

    Hi all

    Please can someone explain why the B-tree indexes are not capable of supporting SQL queries using the built-in functions of Oracle.

    We have indexes of tree b on account_no column.

    Select * from test_table where account_no = 11005208

    the above query use the index on account_no

    Select * from test_table where superior (account_no) = 11005208

    But this query does not use the index on the account_no, going for the full table scan.

    My question here is account_no is the numeric data type.
    Then, there is no difference between the data in the columns account_no and upper (account_no) column data, so why he does not use index when using sql functions in an sql query?

    Hello

    If you apply the upper function, Oracle implicitly converts its argument to a string, so your query is actually upper (to_char (account_no)).
    There is none HAVE fully functional in the optimizer and you do not expect to know everything and do all the conclusions that a human being can do. Why should Oracle re - write this type of query analysis the data type of the columns and features when it seems more natural programmer write a correct query (without capital letters in this example) or, if necessary, create an index based on a function?

  • Anonymous performer of Oracle PL/SQL in the Production environment leave a residue?

    Hello

    In my project, we have a large PL/SQL in Prod-Replica Envt to generate scripts. However, to reproduce Prod for this Prod-Replica lasts long and is causing a delay to respond to change requests.

    We have READ ONLY access to Prod DB, but we cannot deploy the PL/SQL Package it. We plan to convert the PLSQL in an anonymous block PLSQL and running it in PROD DB to get real data. Alternatively, we can run it directly or via Java and then read the DBMS output later. as mentioned here-> the use of cursors and results in Oracle PL/SQL, Java/JDBC - Stack Overflow

    , However, is not an expert in PL/SQL, I wanted to know, if it leaves residues in PROD outside the additional load a temporary server for read queries. We only select queries in this PL/SQL and so I donot believe we leave triggers or change the DB somehow.

    Can you please let me know the possible consequences of it.

    -Thanks & Regads

    -Scott

    There will be an impact on the server, the conversion of code unit of PL/SQL (procedures and functions) must be encapsulated in a single code PL/SQL anonymous block.

    This anonymous PL/SQL code block needs to be parsed and compiled - burn a lot of CPU (that oppose the use of unit code already compiled PL/SQL).

    This anonymous PL/SQL block is likely to be very large because it contains too many units of PL/SQL source code. This needs memory to the server as the whole code block will be stored in the shared pool (for analysis).

    Another impact on performance would be wise to network. It requires more bandwidth to transfer this big block of code (created by the customer) to the Oracle server. This increases latency. And is not an evolutionary approach.

    So no, there is no "residue" of the code inside the actual physical database code is never stored in the database. However, this approach and the code will affect negatively network and server resources.

    You should consider the problem and determine if this solution you have in mind, justifies this impact.

  • Call to Web Service of Oracle PL/SQL not to call the Web service in SOA Server

    Hello

    Try to call the Web service to oralce pl/sql function

    created a function

    Unable to invoke the web service from the server of the SOA.

    CREATE or REPLACE FUNCTION HelloWorld_WebServices(S_STRING Varchar2) RETURN VARCHAR2 as

    Server sys.utl_dbws. SERVICE;

    APPEL_ sys.utl_dbws. CALL;

    service_qname sys.utl_dbws. QNAME;

    port_qname sys.utl_dbws. QNAME;

    response sys. XMLTYPE;

    application sys. XMLTYPE;

    BEGIN

    sys.utl_dbws.set_http_proxy ("hostname: Port'");

    service_qname: = sys.utl_dbws.to_qname ("ns1", "process");

    Server: = sys.utl_dbws.create_service (service_qname);

    APPEL_: = sys.utl_dbws.create_call (server);

    sys.utl_dbws.set_target_endpoint_address (APPEL_, ' http:/host name: port/soa-infra/services/OFS/HelloWorld/helloworld_client_ep ');

    sys.utl_dbws.set_property (APPEL_, 'OPERATION_STYLE', 'process');

    asks: = sys. XMLTYPE ("< ns1:process xmlns:ns1 ="http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld"> < ns1:input > < / ns1:input > < / ns1:process > '"); 

    answer: = sys.utl_dbws.invoke (APPEL_, request);

    return response.extract('//HelloWorld/child::text() ','http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld'). getstringval(); 

    DBMS_OUTPUT. Put_line ("values of the OutputsVariables8");

    -Of return ';

    END;

    Run - the code below:

    Select HelloWorld_WebServices ('Hi') to double;

    Error:

    ORA-29532: Java call terminated by eception Java exception: java.lang.NoClassDefFoundError

    ORA-06512: at "SYS." UTL_DBWS', line 403

    ORA-06512: at "SYS." UTL_DBWS', line 400

    ORA-06512: at the 'APPS '. HELLOWORLD_WEBSERVICES', line 74

    29532 00000 - "Java call terminated by eception Java exception: %s."

    * Cause: A mistake or a Java exception has been reported and could not be

    solved by Java code.

    * Action: Modify Java code, if this behavior is not expected.

    Hello

    Fixed the error

    After loading once again of DBA and network provided access files JAR/JVM firewall

    and the correction on the threshold

    Return response.extract (' / result/child::text () ','xmlns = "http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld" '). getstringval();

  • XQuery SQL function

    Hello

    In a query XQuery is posssible to call a function or procedure SQL (PL / SQL)?
    Here is an example of what I had accomplished:


    SELECT THE PRD. XMLCOLUMN of
    XMLTABLE (' for $i in ora: view("P_iXXX")/LINE)
    $j in ora: view("P_jXXX")/LINE.
    where
    ($i / NSU_xxx = $j/NSU_xxx)
    return
    (
    < NCL >
    {
    $i / NSU_xxx,
    H3. CALL the SQL function? as sql_xxx
    for $k in ora: view("P_kxxx")/ROW
    ($vk/COD_RMP_VPM = "PRD")
    Return()
    }
    < / NCL >
    () "PATH of XMLType 'XMLCOLUMN' COLUMNS 'resultsqlfunction' INTEGER PATH 'xsql_xxx' INTEGER ACCESS to 'NSU_xxx' path 'NSU_xxx', '.') as the PRD;

    Thanks in advance for your answers
    François

    Who today replaces "ora: see?

    On 11.2, ora expansion feature: view() is deprecated in favor of the fn:collection("oradb:/") method:

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb_xquery.htm#BABECFFD

    My DBA database have installed Oracle XML DB to use the XMLType and XMLTable, I thought that these features among other things speed up the creation of XML.

    What are the benefits of using XQuery and XMLTable and XMLQUERY functions?

    Which version of the database you use?

    Please read: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ

    Is there another method to expedite the creation of XML?

    Publication of SQL/XML functions are probably the best way to create custom relational data XML documents.

    The basic functionality of XQuery is not to the RDBMS query tables or views, although Oracle provides extensions to do.
    Most of the time, I use XQuery (via XMLTable and XMLQuery) to do exactly the opposite, i.e. to extract XML data in a relational form, or the transformation of XML fragments.

    If your actual requests are slow - even if you need to define what that means and that you are pregnant - then maybe the SQL/XML functions are not the real problem.

    In a "Where clause" as I turn, I have several "outer join". Here is an example.

    where
    PPM. NSU_PPM = w.NSU_PPM and FRNS. NSU_FRN (+) IS FCO. NSU_FRN and FCO. NSU_FCO (+) IS PPM. NSU_FCO
    and T2O. NSQ_T2O (+) IS PPM. NSQ_T2O
    and T51. NSQ_T51 (+) IS PPM. NSQ_T51
    and TWU. NSU_STT (+) IS PPM. NSU_STT
    and T01. NSQ_T01 (+) IS PPM. NSQ_T01
    and vpm.cod_rmp_vpm (+) = "PRA".
    and vpm.num_vsn_vpm (+) = PPM.vsn_sup
    and w.nsu_ppm = A.nsu_ppm (+)
    and W.NSU_SOO = A_HEADER. NSU_SOO and A_HEADER. NOR_SOM = 0

    Yes, it's exactly what I was talking about.
    Transposing the logic for XQuery 1.0 is not the approach more simple (to say the least), because there is no direct support OUTER JOIN.
    XQuery 3.0 provides the functionality, but it is not yet here in the database.

    My suggestion would be to stick to the publication of SQL/XML functions.
    If you have a specific question about the performance, we (as the members of the forum) will be happy to help you.
    Provides the steps necessary to reproduce the problem, including some examples of data.

    Kind regards

    Marc.

  • Pass a list of values to a pl/sql function

    I would like to pass a list of values to a pl/sql function where the list will be used in an IN clause. Ideally, I would like to do the following:

    CREATE or REPLACE FUNCTION (dept_list in varchar2)
    Start
    Select... where dept in (dept_list);

    use: process_list ('7730,7735,7740,7745');

    I can't find an example to do based on pl/sql, but it seems feasible.
    Is there a way to do this?

    user12088323 wrote:

    I would like to pass a list of values to a pl/sql function where the list will be used in an IN clause.

    use: process_list ('7730,7735,7740,7745');

    The first thing is that you need an appropriate data type for storing a list of numbers. A unique value that look you like a list of numbers, is not actually a list of numbers but a single character value.

    This example uses the built in odcinumberlist data type in a procedure, you can do the same in function

    Re: Pass an array to an Oracle stored procedure

    If you have an older version of the database, you may need to create your own type with the same definition of odcinumberlist.

  • Unlike char in ORACLE and SQL SERVER

    Hello gurus,

    I tried to querying data from Oracle to sql server through linked server, but get me an error! set length corresponds to the error! I know there are CHAR data type in sql server and thus as in oracle.

    But when I use the CAST FUNCTION with CHAR it works fine
    -- error code 
    
      select * from openquery( linkoracle11 
               select  col1, col2, col3 from test_table )
    
    
    -- say col3 char(1)   -- data type
    ---

    -- working code 
    
      select * from openquery ( linkoracle 11 
               select  col1, col2, cast (col3 as char(1)) as col_3 from test_table )
    I was wondering, what is the difference between oracle and sql server for the CHAR data type?

    The gurus of the idea?

    Thank you

    What is the error you get?

    What is the characters in database and NLS_LENGTH_SEMANTICS game on your Oracle system?

    SELECT *
      FROM v$nls_parameters
     WHERE name LIKE '%CHARACTERSET';
    
    SQL> SHOW PARAMETER nls_length_semantics;
    

    What is the character set of data in SQL Server?

    If your local database is a variable length character set (like UTF8) and NLS_LENGTH_SEMANTICS is set to (default) BYTES, a char (1) allocate 1 byte of storage which may not be sufficient for a single character. The receiving application may need to allocate a buffer with 3 times more many bytes as there are characters in order to ensure that it will be able to process the result. I don't know why add an implicit CAST that would change, but since we are several levels removed from the code to figure out how large a buffer to allocate, it is not very surprising.

    Justin

  • 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);
    
  • Allowing access only through a PL/SQL function

    What is the technique of letting a user to do something by a PL/SQL function that would normally not have the privilege to do so, without granting the possibility to do outside the PL/SQL function?

    I have a need to allow a user to change the global_name of the database, in the resolution of ORA-02082 errors. In short, the product using Oracle (we can not change code) loopback database links, and the only way to drop them (according to the Oracle support) is to temporarily change the global_name, drop the link and change the global_name return.

    This happens on a semi-regular basis, so rather than having to involve a DBA, I favor.

    My thought was to create a PL/SQL procedure that performs the Rename/move/rename. I don't want the user to be able to change the global_name of DB to what he wants, but I want him to have the possibility to change through the PL/SQL procedure at will.

    My question is, how to do this without allowing the user to update on sys.global_name?

    Let's see:

    (1) create a role (say LOOPBACK_DBLINK_DROPPER)
    (2) create a procedure (say LOOPBACK_DBLINK_DROP) makes the Rename/move/rename
    (3) grant and then execute the procedure to the role
    (4) ??? .. .the I need to give an update on sys.global_name for the role. But if I then assign the role to a user, is not that means he can also update sys.global_name on its own without using the procedure, because it would have the sys.global_name privilege update?

    Create the schema belonged procedure that has the necessary privileges.
    GRANT EXECUTE on LOOPBACK_DBLINK_DROP to NON_PRIV_USER

    That's all!

  • APEX shortcuts using the source of the body of the PL/SQL function

    Hi all

    Recently, I came across the feature of "Shortcuts" in the "Shared components" section of the APEX and thought great, somewhere to set the common/standard items once, then use these several times in different pages of my application.

    This seemed to work correctly when you use the 'Source' of "HTML Text" or "HTML text with special characters escaped", but then I wanted to explore the use of the "Body of the PL/SQL function" option to create a more dynamic shortcut/variable on the base.

    This is where I came across a particular problem in the APEX (Version 3.2.1.00.10 on GR 11, 2 on Oracle Enterprise Linux). When I set my shortcut, and then perform a reference to my shortcut (using "MY_SHORTCUT") in an area of a page, the value of shortcut is back, but is added with the reference variable (ie. the 'MY_SHORTCUT' chain).

    For simplicity, my example looks like this (of course, my real world example is a bit more complicated, but this example produces the same error):
    (a) I define my shortcut called "MY_SHORTCUT" and using the body of the PL/SQL function under "Source Type", define my procedure as "htp.p(:USER)."
    (b) I then create a new page (basic HTML page), and a new region of the 'type'-> 'HTML Text (with shortcuts).
    (c) in the "Source region", I define my shortcut like - "MY_SHORTCUT".
    (d) I apply changes and then run the page.

    I'll be back will be name of the current user with "MY_SHORTCUT" appended/added immediately after the user name - for example. the string:-' BRAD «MY_SHORTCUT»»

    Question is - how to stop the shortcut/reference text "MY_SHORTCUT" to be added to the variable you want to see the and thereafter on your page? I am just wanting the variable, NOT the reference for the shortcut.  I do something wrong using the HTP package, and if yes, what should I use?

    If "MY_SHORTCUT" is defined as "HTML text with special characters escaped" (where I can refer to elements of application using the syntax '& USER.') so that everything works correctly. My reason for using the PL/SQL is to generate a more dynamic output variable, based on elements of application throughout the entire application - and of course the use of shortcuts to minimize coding and duplication.


    Thanks in advance,
    Brad

    Hello

    The body of the PL/SQL function must RETURN a value.

    Try:

    RETURN :APP_USER;
    

    Andy

  • Replace the trivial calculation with PL/SQL function?

    I have several queries that are full day based on a date field differences Oracle - for example, something along the line of computing:

    Select
    Customer
    , trunc (current_date) - trunc (payment_date)
    Of
    (select 'Fred', to_date ('2009-06-01 07:05 ',' yyyy-mm-dd hh24:mi:ss') as payment_date of all the double union)
    Select 'Barney', to_date ('01-07-2009 15:15:15 ',' yyyy-mm-dd hh24:mi:ss') of double
    )
    -- ------------------------------------
    --
    -Customer Account_Age
    -- --------- -----------
    -Fred 49
    -Barney 19

    I'm a developer who is now Advisor we use a user defined PL/SQL function rather than the difference of these functions TRUNC. Who goes against the grain for me. In MS SQL Server Transact SQL forums, I would recommend almost never replace something trivial with a user defined function because the UDF is called for each row returned by the query and adds overhead to the application.

    The same kind of logic applies to the UDF Oracle? Is it a good idea to replace trivial calculations like this with the UDF?


    Kent Waldrop

    If you can do it in sql, avoid any need for a function.

    SS

  • Possible bug - PLS-00372 creating BODY calculation of the PL/SQL FUNCTION

    3.2 on Oracle APEX: 10 x e

    I was creating a calculation for a page element by using the type 'BODY of the PL/SQL FUNCTION '. Step by step in the wizard when I entered my code block, I received the error PLS-00372. Here is the code:

    DECLARE
    l_return person_v.full_name%TYPE: = 'UNKNOWN ';
    BEGIN

    SELECT full_name
    IN l_return
    OF person_v
    WHERE party_id =: P230_CONTACTED_PARTY_ID;

    RETURN l_return;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    RETURN l_return;
    END;

    If I change my name of the variable to another thing that l_return the error disappears. Later, I can't change the name of the variable in l_return and I do not get the error if it seems to be the validation happening on just this page of the wizard.

    Greg - it's because of a quirk in the validation, like imagine you. Workaround is to put a space between return characters and the terminal semi-colon, for example:

    RETURN l_return;

    Scott

  • Filling point with the body of the pl/sql function

    Hello

    I want to fill an item "Show as text (saves the State)" in contrast to the other 2 points.

    The source of my question is:
    -Only when the current...
    -Body of PL/SQL function
    -Term source:
    DECLARE
    v_diff NUMBER;
    BEGIN
    v_diff: =: P1_AUFWAND_TOTAL -: P1_AUFWAND_BERECHNET;
    Return v_diff;
    END;

    Now I get this error:

    ORA-06502: PL/SQL: taking oder Wertefehler: Fehler beim zu if indication Zahl von
    Error ERR-1904 unable to calculate the default item: type = body of the function...

    I tried to find the problem with the conversion to_number:
    v_diff: = to_number(':P1_AUFWAND_BERECHNET'); or
    v_diff: = to_number (': P1_AUFWAND_BERECHNET', '999G999D00');

    What's not here? It's as if I'm making a simple mistake...

    Thanks for any help,
    Roger

    If the following code does not work for you, then one of the two elements are not the numbers:

    DECLARE
       v_diff   NUMBER;
    BEGIN
       v_diff := TO_NUMBER (:p1_aufwand_total)
                 - TO_NUMBER (:p1_aufwand_berechnet);
       RETURN v_diff;
    EXCEPTION
       WHEN OTHERS
       THEN
          RETURN SQLERRM;
    END;
    

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • Chain replication using a sql function...

    Hello
    Is there a sql function that reproduces a string given so many times that appears in a parameter...?
    For example: String-> test

    Select < sql_function > ('test', 3) double

    -> testtesttest

    Note: I use Oracle10g v.2

    Thank you
    SIM

    What about a SQL?

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    Elapsed: 00:00:00.08
    satyaki>
    satyaki>
    satyaki>select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connect
     by rownum<='||&num).EXTRACT('//text()') res
      2  from dual;
    Enter value for str: satyaki
    Enter value for num: 1
    old   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec
    new   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con
    
    RES
    ----------------------------------------------------------------------------------------------------
    satyaki
    
    Elapsed: 00:00:00.07
    satyaki>/
    Enter value for str: satyaki
    Enter value for num: 2
    old   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec
    new   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con
    
    RES
    ----------------------------------------------------------------------------------------------------
    satyakisatyaki
    
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>/
    Enter value for str: satyaki
    Enter value for num: 3
    old   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec
    new   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con
    
    RES
    ----------------------------------------------------------------------------------------------------
    satyakisatyakisatyaki
    
    Elapsed: 00:00:00.02
    satyaki>
    satyaki>/
    Enter value for str: satyaki
    Enter value for num: 5
    old   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'&str'||chr(39)||' cola FROM dual connec
    new   1: select DBMS_XMLGEN.getxmltype ('SELECT '||chr(39)||'satyaki'||chr(39)||' cola FROM dual con
    
    RES
    ----------------------------------------------------------------------------------------------------
    satyakisatyakisatyakisatyakisatyaki
    
    Elapsed: 00:00:00.14
    

    Kind regards.

    LOULOU

    Published by: Satyaki_De on September 27, 2008 14:10

  • What is this new SQL Beta - 1z1 - 071 - 2 SQL - Oracle Database SQL 12 c

    Hello

    It's confusing.

    This looks like a 2nd review SQL for Oracle 12 c.

    What is this new SQL Beta - 1z1 - 071 - 2 SQL - Oracle Database SQL 12 c

    Can someone explain.

    Roger

    OK - I guess I should have held off a few hours before my previous answer.  I just got an email in the Certification of Oracle program manager. Now, I have inside information.

    1Z0-071 is a SQL new test and the role it plays is between that of the review of databases SQL and SQL Expert.  Specifically, unlike review of databases SQL, passing it will give proof of the OCA for people who spend. I don't know more than that yet.  The review details page is not available and if the subjects are currently a grey area for me.  I'll probably create a blog on the review, if I can get a few details about it.

Maybe you are looking for