Reference value of an SQLPLUS variable in a PL/SQL anonymous block

All,
Is there a way of referencing an SQLPLUS variable within a PL/SQL anonymous block. See my example below........
sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
SET FEEDBACK OFF
SET PAGES 0
SET SERVEROUTPUT ON
WHENEVER SQLERROR EXIT SQL.SQLCODE
WHENEVER OSERROR EXIT 2
VARIABLE l_ret_sts NUMBER;
VARIABLE l_ret_msg VARCHAR2(300);
exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
begin
if :l_ret_sts > 0 then
dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
else
${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :l_ret_sts, p_ret_msg => :l_ret_msg);
dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
end if;
end;
exit
ENDOFSQL
I need to be able to reference :l_ret_sts in the begin block using the if statement "if :l_ret_sts > 0 then"
:l_ret_sts is populated in a procedure call beforehand.
However it seems as though the begin block cannot reference the value returned to :l_ret_sts.
Any ideas.
Ian.

Managed to solve this. I put my call to the package that the role enables via dynamic sql....
sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
SET FEEDBACK OFF
SET PAGES 0
SET SERVEROUTPUT ON
WHENEVER SQLERROR EXIT SQL.SQLCODE
WHENEVER OSERROR EXIT 2
VARIABLE l_ret_sts NUMBER;
VARIABLE l_ret_msg VARCHAR2(300);
exec dbms_application_info.set_client_info('CONTROL-M');
exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
declare
v_text varchar2(500);
begin
if :l_ret_sts > 0 then
dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
else
v_text := 'begin ${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :1, p_ret_msg => :2);end;';
execute immediate v_text using in out :l_ret_sts, in out :l_ret_msg;
dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
end if;
end;
exit
ENDOFSQL
Cheers
Ian.

Similar Messages

  • How come the item value does not come thru via PL/SQL anonymous block?

    Hi,
    It's a Form with 3 tables -
    1) ClinicianProfileTb (with about 40 columns, insert/update via DML),
    2) PeopleTb (with about 7 columns, insert/update via PL/SQL anonymous block) and
    3) ClinicianPracticeTb (with about 10 columns, insert/update via PL/SQL anonymous block) for after-submit-processes.
    So I have several After-Submit-Processes. For some reason, it appears that PeopleId which is supposed to come thru via the 2nd After-Submit-Process (ie: Insert/Update PeopleTb) does not do the way it's supposed to. And when I press "Create" button at the bottom, I got the following error msg:
    ORA-01400: cannot insert NULL into ("TEST_0712"."CLINICIANPRACTICETB"."PEOPLEID")
    I tried the "debug" mode (via edit page link), but to no avail. (I'm newbie, trying to learn and deliver at the same time :)).
    I uploaded the app to apex.oracle.com, if someone could kindly take a look and let me know what goes wrong, it'd be greatly appreciated.
    workspace: test_0712
    app: 43408 - TEST
    user: demo
    pswd: demoPswd
    Page#21 -> look at the After-Submit-Processes -> in "Insert/Update PeopleTb" it appears that PeopeId does not come thru; thus it cannot be updated to ClinicianProfileTb.PeopleId (allows null) -> and thus cannot be inserted into ClincianPracticeTb.PeopleId (which does NOT allow null). Basically my logic is that in order to create ANY row in ClinicianPracticeTb, BOTH PracticeId AND PeopleId must be present.
    Acutally I should have used the PeopeTb as DML (as the driving table) to enforce that PeopleId must be present in order to insert ClinicianProfileTb and ClinicianPracticeTb, but it'd be lots of codes to write to insert/update in ClinicianProfileTb (40 columns).
    In addition, does ApEx consider EVERY SINGLE after-submit-process are in ONE transaction for commit/rollback? It appears that it treats all PL/SQL anonymous blocks are in ONE transaction, while Automatic Row Processing (DML) is commited/rolled back on its own?
    Thanks much,
    Helen

    All blocks that do not commit in one of the ways I detailed (and which do not explicitly commit using a commit statement) are part of the transaction started with > the first DML statement issued in any of the page processes and continuing until a commit is issued.Say, there are the following processes in the After-Submit-Processes:
    1. Process1 -> Automatic Row Processing (DML)
    2. Process2 -> PL/SQL anonymous block
    3. Process3 -> PL/SQL anonymous block
    Based on what you describe, in the event that if there is no explicit "commit" issued in any of these processes, then an implicit "commit" will be issued at the end of Process3?
    Thanks, Scott.
    Doreen

  • Oracle BLOB value to a LC variable

    Hello,
    Is it possible in LC ES2 to coerce oracle blob value to some livecycle variable ?
    When mapping sql query result (column of type BLOB) to a LC variable (of type Document), we receive:
    com.adobe.workflow.datatype.InvalidCoercionException: Cannot coerce object: oracle.sql.BLOB@27e7d6 of type: oracle.sql.BLOB to type: com.adobe.idp.Document
    We have tried mapping to string, binary, Document (, we even desperately hardcoded sql.oracle.BLOB to process XML), but none of this works.
    Is it possible to solve this other way, then following ?
    http://groups.google.com/group/livecycle/browse_thread/thread/6c4b9156b52b71a7
    Thanks.

    My idea is to fetch the BLOB column data as UTF8 (base64) encoded string and then use getDocumentFromBase64 available in ES2.
    I am not sure what syntax is to fetch from ORACLE.
    I have used MySql database and the query is:
    SELECT CONVERT(Blob_Column USING UTF8) as MyBlobDataAsBase64Str FROM myTableName;
    Now using SetValue activity to look like:   myXMLvariable = getDocumentFromBase64(strVariableHoldingBase64Data)
    This case works perfectly without any issues.
    The problems is you should find out the appropriate syntax for ORACLE.
    I was searching about CONVERT() & UNISTR() functions. But i'm unable to evaluate.
    Try by yourself..
    Nith

  • Assigning a value to a substitute variable

    Hi, I would like to know if it is possible to assign a value to a substitute variable.
    This is what I'm doing:
    - Prompting user for input
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    (displayed list of options are numbers 0-5)
    - Based on input, open corresponding file
    (start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql)
    Problem:
    - Default selection is 0, meaning use the CURRENT UOM system (a number, 1-5)
    - That being said, &&uom must be assigned a 1-5 value in order to open the file that corresponds to the CURRENT UOM system
    Let me know if any additional information is needed.
    Thanks!

    I apologize for the format. I tried to make it more legible, but was not able to. FYI: It appears to be easier to read in "Edit" view.
    Thanks, I tried the &&uom := your_function(); suggestion, but I am getting an error. It looks like the "value" of &&uom is being read in the assignment statement, not the variable name.
    I have copied the piece of the code, for your reference.
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    DECLARE
    v_uom_sys_selection NUMBER;
    v_curr_uom_sys VARCHAR2 (50);
    v_uom_num NUMBER;
    BEGIN
    v_uom_sys_selection := to_number(&uom);
    v_curr_uom_sys := EG.GET_CURRENT_UOM();
    v_uom_num := eg.get_user_selected_uomnum(v_curr_uom_sys);
    &&uom := to_char(v_uom_num);
    dbms_output.put_line('v_uom_num = ' || v_uom_num);
    dbms_output.put_line('&&uom = ' || &&uom);
    END;
    --prompt "&&uom"
    start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql
    Below are the results I get when commenting out the &&uom := to_char(v_uom_num); line. NOTE: the "value" of &&uom = 0.
    v_uom_num = 1
    0 = 0
    If I leave that line in, I get the following error:
    PLS-00103: Encountered the symbol "0" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier> was inserted before "0" to continue.
    Message was edited by:
    user449676

  • No value found for Text Variable

    Hi All,
    I have 2 different variable created on 0VERSION. One for user entry and second one is text variable with replacement path as "text".
    I have 3 different columns in the report.
    One is Restricted KF, based on user entry variable. Heading of this column has to be Result (&ZVERTXT&), where ZVERTXT is my text varaible.
    Now, in second column I m using formula to calculate percentage. Heading of this column is &ZVERTXT& (%).
    Now, in third column i m again using formula using the same KF as in first column. But this time, in the heading this text variable thorws "no value found error"
    can anybody help me out in this issue.. ??

    Hi,
    This is the proble to get value for text variables with Replacement path ,in case system is getting 2 reference values .So it get confusion and says that <i>No value found for Text Variable </i> .
    So as a work around :
    Instead of a text variable with automatic substitution(replace ment path) from another characteristic value, you can also create a text variable that is filled by a customer exit.In the code you  assign the Text value by looking into TEXT table with the value you got from User entry variable( which is used in first Restricted KF).
    With rgds,
    Anil Kumar Sharma .P

  • Passing multiple single values in Customer Exit Variables

    Hi,
    I have one requirement to Pass multiple single values in Customer Exit Variable.
    If the user gives 2010 i need to get value previous fisacal year(2009),if its 2009, we need to get 2009.
    Just requirement is like how to pass multiple single values?
    Thanks.

    Hi..
    For this create a variable- Types of variable= Characteristics Value> Processing type as Customer Exit-->Reference Char as Fiscal year..
    Try this code..
        when 'xxxx'.
          DATA: lv_zp0003_month(2) TYPE n,
                  lv_zp0003_year(4) TYPE n.
          CLEAR: lv_zp0003_month, lv_zp0003_year.
          lv_zp0003_month = sy-datum+4(2).
          lv_zp0003_year = sy-datum(4).
    If the month is January the year is set to previous year
          IF lv_zp0003_month = '01'.
            lv_zp0003_year = lv_zp0003_year - 1.
           l_s_range-low = lv_zp0003_year.
    Else the year is set to actual
          ELSE.
            l_s_range-low = lv_zp0003_year.
          ENDIF.
          IF l_s_range-low = l_s_range-high.
            l_s_range-opt = 'EQ'.
          ELSEIF l_s_range-high IS INITIAL.
            l_s_range-opt = 'EQ'.
          ELSEIF l_s_range-low LT l_s_range-high.
            l_s_range-opt = 'BT'.
          ENDIF.
          l_s_range-sign = 'I'.
          APPEND l_s_range TO e_t_range.
    Hope this helps.
    Regards.
    AKG

  • Return a outparam value into a UNIX variable

    Hi all
    I have requirement wherein, i need to set the value of oracle stored procedure outparam into a unix variable,
    How can it be acheived?
    Thanks in advance
    Regards
    Deepak

    You can use the exit command of SQL*Plusm but this is restricted to numbers between 0 and 255:
    cat test.shecho "variable result number
    exec :result := 42
    exit :result" | sqlplus scott/tiger@oracle
    export UNIX_RESULT="$?"
    echo The unix result value is $UNIX_RESULT
    :/home/scott
    ./test.sh
    SQL*Plus: Release 9.2.0.8.0 - Production on Mi Okt 14 09:48:39 2009
    The unix result value is 42Hth, Urs

  • Assigning a Jython variable value to an ODI variable

    I have to implement database cursor functionality in ODI.
    For storing the returned values from database, I am using a Jython list.
    The next functionality that I have to implement is as follows:
    (i) For each value in the Jython list, I have to pass that value as a variable to an interface and then execute the interface
    (ii) Return back to the Jython list to get the next value in it
    (iii) Execute the interface for the new value from Jython list
    (iv) Have to execute the interface for as many values as in the list and stop when list is over.

    Hi,
    Thanks for your replies.
    I tried your method of using source as a query in procedure and using ODI startScen in the Target of the same procedure. But the scenario runs only once, and then stops even though the Source query returns 4 rows.
    Do we have to write Source and Target in separate steps of the procedure?
    Does ODI store the many records returned into some internal variables?
    I need to implement a cursor functionality so what is the best approach?
    Can i pass array variable value to some odi variables and do a loop?
    I used a workaround....it works but dont know if that's a good way of doing things:
    I retrieved all the different values that I need in a string by appending the values(this was done using Java loop).
    In my next step in the procedure I call a scenario(package which has some variables and my interface), which passes this long variable from Java as <@...@>
    Then in the package I use an iteration variable which is used to find out the SubString position so that I can extract the correct string to use for my Interface in the next step of the Package.
    It is working fine as of now.....but things could be made simpler if I could call the scenario in the Java loop, then I wouldn't need the iteration variable etc.

  • Assigning a node value from an XML variable to a String type  in Weblogic Process Integrator

    Hi,
    Is there any way to assign a node value from an XML variable to a String variable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

    Nerendra
    Are you talking about using Xpath on the XML document and assigning to a
    variable, it is unclear what you are asking
    Tony
    "Narendra" <[email protected]> wrote in message
    news:3bba1215$[email protected]..
    >
    Hi,
    Is there any way to assign a node value from an XML variable to a Stringvariable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

  • Assigning a javascript value to a JSP variable

    How do i assign a javascript value to a JSP variable?
    eg
    <%
    String JSPvar;
    %>
    <script language="JavaScript1.2">
    <!--
    var javascriptVar="hey"
    -->
    </script>
    <%
    JSPvar = javascriptVar ???
    %>

    You do know that the JSP runs on the server and generates HTML, including Javascript, that is executed on the client, don't you?

  • Can F4IF_INT_TABLE_VALUE_REQUEST FM return a value in a global variable?

    Hi everybody,
    I need to use F4IF_INT_TABLE_VALUE_REQUEST FM because I have to let users select an specific option before choosing another value. The point is that I need to save in a program global variable what the user selects, and decide something with it in the program.
    Is it possible that F4IF_INT_TABLE_VALUE_REQUEST FM returns the value in a sinple variable or it has to be paramter?
    I look in a lot of previous threads but I didn't find anything, and I don't know if it's possible.
    Thanks and kind regards,
    MMP.

    Hi,
    Sure you can. All you need to do is to store what the function returns in your global variable. It don't need to be returned back to screen field.
    DATA: BEGIN OF VALUES OCCURS 0,
             CARRID TYPE SPFLI-CARRID,
             CONNID TYPE SPFLI-CONNID,
           END OF VALUES.
    DATA: VALUES_TAB TYPE TABLE OF VALUES,
              G_VALUE TYPE SPFLI-CONNID.  "global variable to store what is returned
    "in PAI first populate your table
      SELECT  CARRID CONNID
        FROM  SPFLI
        INTO  CORRESPONDING FIELDS OF TABLE VALUES_TAB
        UP TO 10 ROWS.
    "then call the function but don't return the value to screen field
    "If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the useru2019s selection is
    "returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the
    "selection is returned into the table instead.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                RETFIELD         = 'CONNID'
                VALUE_ORG        = 'S'
           TABLES
                VALUE_TAB        = VALUES_TAB
                RETURN_TAB      = RETURN_TAB.
    "now simply read first row of return tab and store the value returned there in some global var
    READ RETURN_TAB INDEX 1.
    MOVE RETURN_TAB-FIELDVAL TO G_VALUE.
    Regards
    Marcin

  • How to use SYSDATE as a default value of a bind variable in a query report?

    Hi,
    I want to use SYSDATE as default value for a bind variable in Query based report.
    I don't see any way to do it, someone helps?
    Thanks a lot.
    Paulo.

    You can aslo use #sysdate directly.
    Hi,
    The way I'm doing in my report is, I have a database function (f_ret_sysdate) with the following code
    create function f_ret_sysdate return varchar2
    begin
    return to_char(sysdate,'mm/dd/yyyy');
    end;
    Now, in the 'Customization Form Display Options' section of the report I'm calling this function as #f_ret_sysdate in the default value field of corresponding bind variable to display SYSDATE with the format.
    Hope this helps!...
    -Krishnamurthy

  • How to Print the Value of a variable inside a PL/SQL package

    Hi Friends,
    Here is my Scenario
    I have a PL/SQL Package. Let us call it Baseline Package.
    This Package includes a dynamically built merge Statement.
    Execute Immediate v_merge_query.
    I have a procedure which replaces which few Keywords from the Package Text and Creates a new one depending on Inputs I provide. (This is something like a Code generator)
    Now while Creating the new package, I need to print the Value of v_merge_query.... I Need s Static Query to be Printed inside the new package and not a dynamic query.
    My Question is "Is there a way to print the value of the variable inside a different PL/SQL package?
    Thanks in Advance,
    Mohit

    Print where?
    That PL/SQL code is server-side code. It runs in an Oracle server process.
    That server process does not have a keyboard. Or a screen/monitor. Or display canvas. Or an attached printer.
    That server process is incapable of "printing" as that is not its job or responsibility and not part of its environment.
    What is can do is record data for the client to look at afterwards. This can be done using static PL/SQL session variables. Or a SQL table.
    The former is done by DBMS_OUTPUT - a very primitive interface for writing text into a static PL/SQL string array. That btw resides in expensive private process server memory. The client can query the array after a database call and render the contents.
    PS. Also keep in mind that bind variables are critical for performance and server robustness - especially when (ab)using dynamic SQL.

  • How to set a value to a Presentation Variable using GO URL?

    Hi All,
         I am working on a drill (GO URL) from Dashboard page1 to Dashboard page2.
         The problem I am facing is, I am not able to pass a value to the presentation variable through GO URL. (I have to pass "Customer Category" static
    value to The presentation variable present in Dashboard Page2 ).
         The Dashboard page2 is having a view select in which we are using presentation variable to select the report based on the value selected in
    View Select.
         For example: If the user selects "Customer Category" value in View select and clicks on GO button Customer Category report will show the out put.
         When i am drilling from Dashboard Page1 I have to pass a value to the presentation variable used in view select and also pass some filter condition in
         GO URL.
         Please let me know if it is feasible to pass a value to the presentation variable through GO URL in OBIEE 10.1.3.4.
         It will be greate if you can provide me with the syntax to set a value to the presentation variable of dashboard page2 through GO URL.
    Thanks and Regards,
    Sagar Vishwanathwar.

    1) You have to navigate to dashboard page, not to answer request = you have to use "Dashboard URL API" not GO URL API.
    2) On the target page, you have to place dashboard prompt, which sets required presentation variable.
    3) Refer to the target using Dashboard URL API and set filter on prompt column using URL parameters. Example: http://localhost:9704/analytics/saw.dll?Dashboard&PortalPath=%2Fusers%2Fadministrator%2F_portal&Page=page%201&Action=Navigate&P0=1&P1=eq&P2=D_TIME.YEAR_CODE&P3=%221996%22
    Do not forget to use Action=Navigate. The syntax for setting filters using url parameter is the same as for GO URL API described in Business Intelligence Presentation Services Administration Guide.
    This is the way, you can implement navigation to parametrized direct SQL reports including passing filter values...
    Regards K.

  • Adding a Variable Value to the cpQuizInfoPointsScored Variable

    I have a variable that I am using to track incorrect responses (clicking incorrect buttons while completing a process) and I want to add the value of the the variable to the value of cpQuizInfoScored. I can create an expression to add the two but I can't select cpQuizInfoePointsScored to receive the total.
    Any help would be appreciated.

    Jimmy.  This might be that you are misunderstanding how the Interactive Master widget works with partial scoring.  Basically you need to specify the score that will be allocated to a slave object using the Scoring section in the Master Widget properties interface.  That's the score that will be reported to the Quiz instead of the default score you've assigned to the interactive widget via the Properties > Report Score section in Captivate.
    Using the preference settings you select, the Master Widget is going to try and work out whether or not the Variable Slave is in a Success or Failure condition, and THEN it will report whatever score you've assigned for that circumstance.
    What you're trying to do is a little different.  You want to have ONE variable slave that can have a score anywhere between 60 to zero.  My suggestion is that you consider using setting up different user variables for each of the interactive objects on the slide that you are tracking and then add each of these variables into the Master widget as Variable Slaves, assigning each one a Success or Failure score in the Scoring screen. 
    For example, if you ahve a number of click boxes on a slide and you are tracking whether or not the user clicks the right ones, you need to set up a user variable with a default value of 0 for each click box and assign that variable a value of 1 if the click box gets clicked.
    The Master Widget will be able to determine for each of these slaves whether they are in a Success or Fail condition based on whether the variable is set to 0 or 1 and then add up the relevant scores allocated for each variable.  This aggregated score is what can be reported to the quiz score, over riding the default score assigned to the widget.

Maybe you are looking for

  • Cannot upgrade to 10.8.2 on 13" retina

    i just bought MBP 13" retina display and have been trying to update to 10.8.2 to no avail. it keeps giving message as per above. also i cannot upgrade the iphoto as well as it requires 10.8.2 and i have only 10.8.1 installed. it keeps bringing me to

  • Calling a web service using UTL_DBWS

    Hello, I am trying to call a web service froma PL/SQL procedure using UTL_DBWS. I've been able to use a different method to determine that the web service is working correctly, so I know my problem is somewhere within my UTL_DBWS call. It seems like

  • Visual attribute through get_item_property

    Hi People, I use forms 10g.While designing the form I wish to assign VISUAL ATTRIBUTE property for my TEXT_ITEM.So i tried wrinting the following code in WHEN-BUTTON-PRESSED of a push button.The code as follows, declare      vlbl varchar(20);      va

  • Want to downgrade xperia z1 into 4.3

    hi.. i m currently on android 4.4.2 but facing lots of bugs in it.. now i want to downgrade my phone into android 4.3.! can i downgrade my phone without root ? if yes then how ?? please suggest.

  • I need to display more than 5000 rows by JClient JUtableBinding

    I need to display more than 5000 rows by JClient JUtableBinding. is it possible not to get PassivationError and display it?