Executing plsql code (procedures, contexts) in APEX

Trying to create a context. Code is valid, works in PLSQL and TOAD. Can't create it in APEX and can't call it. Can't get any procedures to work for that matter.
create or replace context epsb_person_ctx using epsb_person_ctx_procedure
Then create the procedure...
create or replace procedure epsb_person_ctx_procedure
( i_user_name in varchar2 )
Then exec epsb_person_ctx_procedure('user_name')

It appears that APEX does not like to use contexts. So we have went another route. We have 2 issues we cannot seem to overcome. First, we are trying to create reports based on multiple criteria. To do this we have to build an sql string based on data returned from controls. Second, we need to perform an in statement in this sql to return data based on multiple cost centres.
I cannot figure out how build and sql string from a control and run it. I am having tremendous difficulty getting over this hump. Any help would be appreciated.

Similar Messages

  • How to execute plsql stored procedure with DbAccess

    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions

    I am also looking for the same.
    Did you get any info on this
    Thanks,
    jagan
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by chandra sekhar ([email protected]):
    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions<HR></BLOCKQUOTE>
    null

  • Execute procedure on oracle apex online

    Hi All
    CREATE OR REPLACE PROCEDURE TEST_PROC
    AS
    V_FNAME EMPLOYEES.FIRST_NAME%TYPE;
    BEGIN
    SELECT FIRST_NAME INTO V_FNAME FROM EMPLOYEES
    WHERE FIRST_NAME = 'JOHN';
    DBMS_OUT.PUT_LINE(V_FNAME);
    END;
    I have made this procedure on sql worksheet of http://apex.oracle.com/ on my account.
    when i gave EXECUTE TEST_PROC; and CALL TEST_PROC; command to exeute this procedure I'm getting following error ORA-00900: invalid SQL statement.
    please tell how can i run this procedure.
    thanks in advance.
    regards
    Neeraj

    Some basic concepts first. Apex is a suite of PL/SQL procedures and functions and packages and database tables. Apex runs totally inside the database as stored procedural code.
    What makes it unique and different is that the procedures are called by a web browser URL. This is received by Apache and passed to a module called mod_psql. This module processes the URL from the web browser, determines what database to connect to and what stored procedure call to make.
    Inside the PL/SQL environment there is a set of web packages - and a buffer area that can be used to create dynamic web pages. Apex PL/SQL code executes and creates a dynamic web page/web content in this buffer. The code terminates.
    The mod_plsql module in Apache then reads this buffer from the Oracle session and it streams the content to the web browser.
    DBMS_OUTPUT is not specifically supported by mod_plsql as it is another buffer area (quite primitive in use and interface). It supports a basic console output display for PL/SQL code - and is typically use by session-based clients like TOAD, SQL*Plus and SQL-Developer.
    So if you want a web-enabled PL/SQL procedure to display data on the web browser, your code needs to write to the web buffer in PL/SQL and not the DBMS_OUTPUT buffer. Writing to the web buffer can be done using the HTP.prn() call.
    Here's a very basic example of outputting data to a web browser using custom PL/SQL code. Create a Apex page. On this page create a text item called something like P1_FIRSTNAME. This enables the web user to supply a parameter value to your PL/SQL procedure.
    Create a dynamic PL/SQL region on the page, that calls your procedure:
    begin
      --// if the user supplied a firstname, we call the procedure to process the data
      if :P1_FIRSTNAME is not null then
        MyTestProc( firstName => :P1_FIRSTNAME );
      end if;
    end;The user procedure that receives and processes the data, and supplied web output, will look something like the following:
    create or replace procedure MyTestProc( firstName varchar2 ) is
      cnt integer;
    begin
      htp.prn( 'You have entered the search criteria: '||firstName||'<br> ');
      select count(*) into cnt from emp where first_name like firstName;
      htp.prn( 'Number of matching employees: '||to_char(cnt)||' row(s)<br> ');
    end;

  • Can i submit  a page and later execute a plsql code in some seperate page..

    I have a page.. this page has a button and the action for it is submit ..database action is insert activity..What i need is the moment
    i press the button .. after the submit activity has been done .. a plsql procedure which fires when i redirect to page.. 100 also be executed.
    Normally if my button action type is redirect to page .. Then this procedure gets executed...Since it is in redirected page.
    But If I change the action type... to submit this is not possible . ..Since the activity that occurs is the database insert activity..
    I also need the plsql code which is other page to be executed..
    Any information provided will be appreciated.

    i got it solved.. issue was..just
    needed to write a plsql code.. which will do a insert activity and then ..it does a redirect of page..I changed the button action from submit to link to page
    Issue is sorted
    Thanks

  • Publish a plsql code as webservice without using JDEVELOPER or APEX

    Hi All,
    I am looking into how can we publish a PLSQL code as web-service without using JDEV OR APEX.
    When I google for this one I can see only by using JDEV or APEX we can publish Code as a web-service.
    Is there any way in oracle, just by using simple PLSQL packages we can publish code as a webservice.
    Appreciate your response.
    Thanks,
    MK.

    Apex does not publish PL/SQL code as web services. It is a web run-time and development framework. Something totally different.
    To turn a PL/SQL function into a web service is simple. You use the orawsv servlet in XDB - without making a single code change to the function. It will not even know it is called as a web service.
    To use orawsv, two basic steps. Configure and enable the servlet (raw HTTP/HTTPS connections will be handled by the Listener). This also entails enabling shared server in the database, if not already enabled. The 2nd step is to allow the function to be executed (via a HTTP call) as a web service, via granting specific roles.
    orawsv handles the HTTP call. It provides the WSDL. It parses SOAP envelopes as input. It makes the call (as a standard PL/SQL call), to the function being used as a web service. It returns the results of the PL/SQL function call, as a SOAP envelope output.
    See Support Notes:
    How to Setup Native Oracle XML DB Web Services [Article ID 444191.1]
    Sample Framework for testing Native Oracle XML DB Web Services [Article ID 803794.1]
    How to Browse Native Oracle XML DB Web Services Example [Article ID 1324235.1]

  • Executing dynamic action JS then plsql code with checkbox.

    All,
    I have a checkbox which when clicked i want to run javascript expression then next plsql code in that sequence. But iam getting the first issue here when i put in JS an expression like document.getElementById("P111_CHECK1").value ... or even document.getElementById("P111_CHECK1").checked i always get undefined error. So how can i determine if the checkbox is checked or unchecked in DA? thanks in advance.

    Hi,
    still stuck here on how do i check/uncheck a single checkbox in Apex i tried via dynamic action JS expression like this but doesnt work ==> document.getElementById("P111_CHECKBOX1").checked = true/false; Any help on this pls?

  • Error ORA-04031 while executing a stored procedure from Pro C++ code

    I am getting the error ORA-04031(Unable to allocate 4096 bytes of shared memory("Shared Pool",.....)) while trying to execute a stored procedure from my pro*C application. This happens only after a few hours since the application has been running. I am closing the cursor after every database call.
    Does anyone know why it is happening and any possible solutions?
    TIA
    Srithaj.

    One thing that can be done is to flush the shared pool before starting the application.
    alter system flush shared pool;
    Another is to increase the shared pool size by setting the parameter shared_pool_size in init_sid.ora file.
    null

  • ORA-01403: no data found Error in PLSQL code raised during plug-in processing.

    Hello OTN community,
    We are having the access to APEX problem. a New user was setup to access the APEX application. When I test to login as a new user, I get the message "ORA-01403: no data found Error in PLSQL code raised during plug-in processing.". When click OK to the disply message, the application will take me out of the sstem. I need help to even understand what is happening. I didn't develop the application, there is no documentation for this application, I am just supporting the application whenever there is a problem and I am new to APEX. As you can see I need help to figure this thing out. Your help is dearly appreciated.
    Thank you OTN

    Try to check the query that is executed and check if there is data or not

  • Get CGI env variables in a database procedure using new APEX Listener

    I already posted this question in the Apex Listener forum and still no replies after one week. The original post is here:
    Get CGI environment from APEX Listener within database procedure
    So please forgive me for posting in this forum as well, but there is a lot more activity here.
    I'd like to know how I can get the CGI environment from the APEX Listener. For example, if I want to write a procedure that inserts into a table the originating IP Address of the client making the web request, how do I get it?
    I am familiar with the Oracle Http Server and mod_plsql, and I know how to call OWA_UTIL.GET_CGI_ENV to get this sort of information. How do I do it using the APEX Listener?
    In particular, how do I do this when calling a custom procedure (not in an Apex workspace)? When I try it now, I get an error from owa_util. The cgi env seems to be empty or not initiated (owa.num_cgi_vars is null or zero).
    Specific set-up:
    I have a web server running the latest JDK, Glassfish, and 1.1.4 Apex Listener. It connects to another server running the latest 11.2 database. Apex is installed and running, but I am not really developing a traditional Apex application in a workspace. I mainly use it like you would use mod_plsql. In other words, I have custom pl/sql packages that are called directly via URL. The requests are forwarded by the listener to the database, and the DB executes the procedure and returns output using htp.p to send text back to the browser. And it works just fine for this purpose. But if I want to call GET_CGI_ENV to get information like the IP Address, web browser making the request, etc. I can't seem to get it with the OWA packages.
    Can anyone shed some light on this? If Apex Listener is not designed to do this, is there some kind of workaround I can use to forward this sort of information to the database for each request?

    I have not tried owa_util.print_cgi_env from SQL Workshop yet, as I have not created an APEX workspace. I have had no need for a workspace because of the way I am using APEX as a method for calling custom packages and stored procedures. In other words, I am using APEX strictly for the mod_plsql functionality. I just use it to forward requests to the database to execute pl/sql code, but I don't develop anything in APEX. My application is a web service with no screens and no direct user interface, which is why I did not need to create APEX forms. The front end is a mobile app that makes calls to the web service.
    But I have tried calling owa_util.print_cgi_env in one of my stored procedures and it returns no data, even when calling it from the web front-end.
    So I am beginning to believe that if the OWA toolkit works with APEX, then it must only be enabled when invoked within a workspace. Stand-alone procedures can be called via APEX, but apparently doing so does not initiate the CGI env variables. This set-up used to work under the OHS with mod_plsql. The embedded pl/sql gateway also works this way.
    Is there a procedure call that APEX is making to set the environment before each SQL Workshop request?
    My security model currently blocks access to all packages and procedures except for my custom packages. I am using the APEX Listener configuration to allow only the packages listed by name in a white list. But I thought I allowed all access when I first tried calling the OWA packages. I'll have to try that again.

  • URGENT HELP: When some users submit, application carries empty fields from html components to plsql code

    Hi APEX users and developer, especially forum's active users, please get me rid of this problem because it is really very bad situation.
    I have a real trouble with application. It behaves unusual. Application is used by 60 users but only 3 of them have these problem and they can not use the application anymore.
    Application is
    http://apex.oracle.com/pls/apex/f?p=70547
    After fields are filled and some rows checked from tabular form in page, user submits the page. Process called newReyestr calls plsql procedure from package with inputs from page. But only same 3 users get empty fields in plsql code. I see it just after when the first line stepped in procedure.
    So, "what is the problem?"

    Hi NoGot,
    you know, I have not written big quote. The code was big. But it has no any meaning. Because problem is in first line. No need to understand it.
    There is no any difference between those users. They also tried it from different browser and even computers.
    BTW: I am not russian.

  • NLS issue in Java/PLSQL code [ using ROWID]

    I have NLS related question regarding the following scenario in Java/PLSQL code ::-
    OracleResultSet ors = (OracleResultSet) stmt.executeQuery("select rowId from t where t.col = 'XX'");
    // The above query could return multiple rowIds.
    String strVal1 = null;
    String strVal2 = null;
    if(ors.next())
    strVal1 = ors.getROWID(1).stringValue();
    if(ors.next())
    strVal2 = ors.getROWID(1).stringValue();
    ArrayList strList = new ArrayList();
    strList.add(strVal1);
    strList.add(strVal2);
    Now I need to pass a list of rowId's from Java to PLSQL function f().
    oracle.sql.ARRAY rowListArr = convertArrayListToRowPointerList(strList, conn) ;
    OracleCallableStatement cstmt = (OracleCallableStatement)
    cstmt.prepareCall("begin f(?); end;");
    cstmt.setObject(1, rowListArr);
    cstmt.execute();
    where:-
    static oracle.sql.ARRAY convertArrayListToRowPointerList(ArrayList arr, Connection conn)
    throws SQLException {
    oracle.sql.ArrayDescriptor stDesc = ArrayDescriptor.createDescriptor
    ("DBUSER.ROWPOINTERLIST", conn);
    oracle.sql.Datum[] keyVals= new oracle.sql.Datum[arr.size()];
    for(int i = 0; i < arr.size(); i++) {
    keyVals[i] = new oracle.sql.CHAR((String) arr.get(i),
    oracle.sql.CHAR.DEFAULT_CHARSET);
    oracle.sql.ARRAY keyArr = new oracle.sql.ARRAY(stDesc, conn, keyVals);
    return keyArr;
    and
    create or replace type DBUSER.ROWPOINTERLIST as table of varchar2(4000);
    Will there be NLS issues in the above code, where I pass the rowId content
    that I obtain from one query, as array of string bind variables to a subsequent PLSQL procedure? --- first approach
    Or
    do I need to pass the rowId list , as a array of oracle.sql.ROWID via bind variables? -- second approach
    The problem I have in second approach is that in the DB we cannot define a type as a table of ROWID's. So currently I have RowPointerList as a table of varchar2's (note the length of list of rowId is not predetermined in my case, so I user table instead of varray).
    However I was wondering if the first approach will have any NLS issues.
    Will appreciate your comments.
    Thanks

    ROWIDs are represented as either hex-encoded values or base64 encoded values. Both encodings use pure ASCII, so there should be no NLS issues.
    I am not very familiar with the oracle.sql.ARRAY type, but unless absolutely necessary, I would avoid the oracle.sql.CHAR datatype (assuming 10g drivers). Using java.lang.String is preferred.
    -- Sergiusz

  • Execute Custom code to do a warning message on SSHR Manager Appraisal form

    Hello - I do not know much about Java/OAF, but I'm really trying to learn! Here is my requirement,
    please help me in getting this done.
    Requirement : On Employee appraisal form, they will have their yearly objectives and their weight percentages.
    These objectives weight percentage is in per_appraisal table attribute1 field(DFF).
    The total weight percentage of an employess all objectives should be equal 100.
    When manager will login to give them a final rating, the total of all weights percentages should be equal to 100,
    if not I have to through a warning message on the Manager's appraisal form(CompFinalRatingsCO).
    To calculate the total weight, we can certainly write a small pl/sql function or a procedure.
    But how can I execute that code and show a warning message on SelfService HR Manager Appraisal form?
    Thanks in advance for your help.
    Thanks
    - Srini

    1) extend the CO attached to your page.
    2) Capture the Button in Processformrequest of your extended CO.
    3) Call a plsql function or procedure with OUT param which will return whether 100% weightage has been entered or not.
    If Not, then throw warning message.
    Here is the way to call Plsql proc with OUT param.
    String sql =
    "BEGIN bcr12_mapping_tool_procs_pkg.XXBCR12_HAS_MANDATORY(:1,:2); END;";
    OracleCallableStatement cs =
    (OracleCallableStatement)am.getOADBTransaction().createCallableStatement(sql,
    1);
    try {
    cs.registerOutParameter(2, 1, 0, 2000);
    cs.setString(1, int_name);
    cs.execute();
    String new_status = cs.getString(2);
    cs.close();
    if ("Y".equals(new_status.trim())) {
    throw new OAException("Please enter all mandatory column highlighted.",
    (byte)0);
    } catch (Exception ex) {
    throw new OAException(ex.getMessage());
    }

  • FILE NAMING IN RUNTIME in scheduler/plsql code in 102g. please help, thankU

    Hi,
    we have a scheduler job which calls/executes a stored procedure that generates a report file. however we need to give file name run at run time and need to copy it to shared folder. we do not want use any shell scripts here and like to complete this work with either PLSQL block or scheduler job. please suggest us how we can specify file name at each run time that differs hour wise.
    the procedure code for example is: failure: not getting file name correctly
    DECLARE
    dtime VARCHAR2(11):=to_Char(sysdate,'YYYYMMDD_HH24');
    F1 UTL_FILE.FILE_TYPE;
    BEGIN
    F1 := UTL_FILE.FOPEN('DIR_REPORTS','REP_''dtime''.txt','W',32767);
    UTL_FILE.PUT_LINE(F1,' Data');
    UTL_FILE.FFLUSH (F1);
    UTL_FILE.NEW_LINE(F1);
    end;
    please give us your help on nameing file at runtime .. filename_yyyymmdd_hh24.txt.
    thanks in advance.
    /mr

    F1 := UTL_FILE.FOPEN('DIR_REPORTS','REP_'||dtime||'.txt','W',32767);
    line giving
    ORA-29283: invalid file operation
    ORA-06512: at "SYS.UTL_FILE", line 475
    ORA-29283: invalid file operation
    ORA-06512: at line 5
    errors. earlier i was able to generate files earlier but not with suggested change.. anything to be done more???
    thank you .. please assist..

  • Easy ways of debugging the plsql code ??

    I have a dumb question, i am just curious to know what are the different ways you use to debug a thousands of lines of pl/sql code (procedure/function etc)...it is really scary sometimes going through different variables/code/sytnax/functionality with tight timelines...is it possible for debugging purpose to see the output of the execution like what we use in unix (set -x command)..is there any similar way in Oracle...appreciate your time it really helps me to speed up my learning though i know the basics of Oracle PL/SQL just want to know opinion from peers on how they do,Thank you.

    Ariean wrote:
    1. Can you please provide me an example on how to read the DBMS_OUPUT static array and mail it.You need to wrap DBMS_OUPUT into a package - so your code will call the package and not the DBMS_OUPUT directly. The package header may look as follows:
    create or replace package DebugOut is
      procedure Write( line varchar2 );
    ... other calls such as writing the call stack, error trace and so on
      (see DBMS_UTILITY for details)
    end;In the package implementation, you need to count the number of times that Write() is called via a counter. The counter needs to be a static package variable. When the counter reaches the ceiling (e.g. 10,000 lines), then you reset DBMS_OUPUT buffer calling DBMS_OUPUT..disable() and then DBMS_OUPUT.enable(). For example:
    create or replace package body DebugOut is
      MAX_LINES constant number := 10000;
      lineCnt number := 0;
      procedure ResetDbmsOutput is
      begin
            DBMS_OUTPUT.disable;
            lineCount := 0;
            DBMS_OUTPUT.enable( buffer_size => NULL );
      end;
      procedure Write( line varchar2 ) is
      begin
        lineCnt := lineCnt + 1;
        if lineCnt > MAX_LINES then
         ResetDbmsOutput;
        end if;
        DBMS_OUTPUT.put_line( line );
      end;
    end;
    2. API - does it stand for "Application programming Interface" in this context like toad ?? can you please explain more on this.Correct API means Application Programming Interface. See Wikipedia's article on API for a basic overview.
    In PL/SQL we have a bunch of APIs supplied by Oracle - these APIs are implemented as PL/SQL packages. UTL_SMTP is for example an API to communicate via Simple Mail Transfer Protocol with a mail server. DBMS_PIPE is an API for IPC (Inter Process Communication), allowing PL/SQL processes to communicate with one another and coordinate processing. DBMS_LOB is an API for dealing with Large Objects (LOBs). Etc.
    Likewise, a good development team will create their own APIs for services their application code often needs. For example, creating a Debug Logging API (as the very simplistic example above shows).
    3. What is instrumentation / instrumentation overhead ??? Instrumentation is explained via the link I've provided. Simplistically, it records what a code unit (e.g. procedure or function) does, what parameter it received, what assertions failed, what exceptions were raised and so on.
    Also have a look at Microsoft Dev Network's Introduction to Instrumentation and Tracing for additional details.
    As for the overheads - instrumentation means extra code that needs to be executed while your process is executed. This code will need to use resources like memory or disk space to store/record instrumentation data.
    For example, we use the above DebugOut API to record the start of a code unit and parameters passed as part of instrumenting our code. The DebugOut API consumes memory (it used the DBMS_OUTPUT buffer).
    So what we can do is add a debug boolean variable to the package header of the DebugOut package. In the Write() procedure of the package, we only write to DBMS_OUTPUT when debug is true.
    This now means that when debug is false, our instrumentation code does not record any data - and thus reduce resource usage. When the need arise, we can enable debug in DebugOut prior to executing our code - and now as our code executes, the instrumentation part happens and DebugOut record trace information to the DBMS_OUTPUT buffer. And we can display that trace data when our process completes in order to troubleshoot problems and process flow.

  • Run PLSQL code by click on button usin javascript

    Hi
    I want to run plsql code
    on click button using javascript
    javascript is ok but code of plsql is not run
    suggest me
    APEX 4.2.1
    Oracle !!XE
    Windows Server
    Firefox 17.0.1
    Theme Cloudy
    thanks in advance
    bUTTON CODE IN PLSQL CODE AND SEND_RMNDE IS PROCEDURE
    '<button type="button" name="button1" onclick="send_rmndr('
    ||NO_DUES_MASTER.CERT_ID
    ||');" value ='
    ||NO_DUES_MASTER.CERT_ID
    ||'> '
    ||'Remind'
    ||'</button>'
    JAVASCRIPT
    <script type="text/javascript">
    function send_rmndr(pThis)
    var params='x= '+pThis;
    var get=new htmldb_Get(null,null,null,&APP_PAGE_ID.,null,'send_reminder',params);
    gReturn = get.get();
    //alert(gReturn);
    alert ('inside script ' +params);
    //get=null;
    </script>
    Edited by: 969091 on Feb 1, 2013 9:13 PM

    send_reminder needs to be defined as an application process
    Alternatively, you can define a dynamic action and do this more declaratively.
    It's easy to define a DA that fires on click of a button that runs PL/SQL, and you can also define which page items are sent to and received from the plsql via session state.
    Scott
    blog: [url grassroots-oracle.com]grassroots-oracle.com
    twitter: [url twitter.com/swesley_perth]@swesley_perth
    -- please mark any useful posts as helpful or correct, in the end it helps us all

Maybe you are looking for