Exit with bind variable from sqlplus and then echo $?

Hello world.
I don't know why they are different between :v_num and the value of "echo $?"
thanks.
SANOWT:oratest:/data3/oratest/oratest/hgjung> cat t.sql
select count(*) from all_objects;
variable v_num number;
begin
select count(*) into :v_num from all_objects ;
exception
when no_data_found then
:v_num := 1403;
end;
exit *:v_num*
SANOWT:oratest:/data3/oratest/oratest/hgjung> \sqlplus scott/***** @t
SQL*Plus: Release 10.2.0.3.0 - Production on Wed Feb 17 10:11:59 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
COUNT(*)
*50497*
PL/SQL procedure successfully completed.
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SANOWT:oratest:/data3/oratest/oratest/hgjung> echo $?
*65*
SANOWT:oratest:/data3/oratest/oratest/hgjung>

The $? variable in UNIX is the exit code for the program. In most *NIX versions that I am aware of, it is limited to values between 0 and 255 (i.e. one byte), so the value is truncated.  The hex value of 50497 is C541, or two bytes, so the $? variable is only getting the last byte 0X41 which is decimal 65.
John

Similar Messages

  • Combo box with bind variable from popup

    Hi.
    I had two comboboxes on a form, one having a bind variable. It works great, with the first one as bind field.
    But i want to have the first LOV to be a POPUP. So, the second LOV (combo box) needs to be refreshed when a user has picked a value from the popup list. When i do that, the second LOV is not refresehed...
    Is there a way to do this?
    (3.0.9.8.3.A)

    Hi,
    This was a bug and is fixed in 30984.
    Thanks,
    Sharmila

  • Sqlplus exit with bind variable gives error

    Hi,
    I want to return the ID-value from an insert-statement back to the OS, but I can't catch it properly in a variable to exit that variabel. here's the script:
    variable logid NUMBER;
    select id_seq.nextval into :logid from dual;
    -- insert into Tab_A .....
    ---values :logid..... -> nothing to do with the problem
    exit :logid;
    I get this:
    SP2-0670: Internal number conversion failed
    To make a minimum test, I do:
    variable logid NUMBER;
    select 5 into :logid from dual;
    exit :logid;
    but I still get that error !
    what am I doing worng here ?
    it is a number isn't it ?
    why do i get a conversion-error than ?
    how do I fill and return a variable correctly ?
    thanks for any help, Lao De

    Your problem is with your select statement. SELECT...INTO is PL/SQL, not SQL, and can not be used to set a variable. Alternatives:
    $ sqlplus scott/tiger
    SQL*Plus: Release 9.2.0.3.0 - Production on Fri Dec 9 13:52:19 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Release 9.2.0.3.0 - Production
    JServer Release 9.2.0.3.0 - Production
    SQL> variable logid number
    SQL> exec :logid := 5
    PL/SQL procedure successfully completed.
    SQL> exit :logid
    Disconnected from Oracle9i Release 9.2.0.3.0 - Production
    JServer Release 9.2.0.3.0 - Production
    $ echo $?
    5
    $ sqlplus scott/tiger
    SQL*Plus: Release 9.2.0.3.0 - Production on Fri Dec 9 13:53:39 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Release 9.2.0.3.0 - Production
    JServer Release 9.2.0.3.0 - Production
    SQL> variable logid number
    SQL> begin
      2  select 6 into :logid from dual;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> exit :logid
    Disconnected from Oracle9i Release 9.2.0.3.0 - Production
    JServer Release 9.2.0.3.0 - Production
    $ echo $?
    6Note that, on a unix platform, your return value must be a positive integer <= 255.

  • Report Performance with Bind Variable

    Getting some very odd behaviour with a report in APEX v 3.2.1.00.10
    I have a complex query that takes 5 seconds to return via TOAD, but takes from 5 to 10 minutes in an APEX report.
    I've narrowed it down to one particular bind. If I hard code the date in it returns in 6 seconds, but if I let the date be passed in from a parameter it takes 5+ minutes again.
    Relevant part of the query (an inline view) is:
    ,(select rglr_lect lect
    ,sum(tpm) mtr_tpm
    ,sum(enrols) mtr_enrols
    from ops_dash_meetings_report
    where meet_ev_date between to_date(:P35_END_DATE,'DD/MM/YYYY') - 363 and to_date(:P35_END_DATE,'DD/MM/YYYY')
    group by rglr_lect) RPV
    I've tried replacing the "to_date(:P35_END_DATE,'DD/MM/YYYY') - 363" with another item which is populated with the date required (and verified by checking session state). If I replace the :P35_END_DATE with an actual date the performance is fine again.
    The weird thing is that a trace file shows me exactly the same Explain Plan as the TOAD Explain where it runs in 5 seconds.
    Another odd thing is that another page in my application has the same inline view and doesn't hit the performance problem.
    The trace file did show some control characters (circumflex M) after each line of this report's query where these weren't anywhere else on the trace queries. I wondered if there was some sort of corruption in the source?
    No problems due to pagination as the result set is only 31 records and all being displayed.
    Really stumped here. Any advice or pointers would be most welcome.
    Jon.

    Don't worry about the Time column, the cost and cardinality are more important to see whther the CBO is making different decisions for whatever reason.
    Remember that the explain plan shows the expected execution plan and a trace shows the actual execution plan. So what you want to do is compare the query with bind variables from an APEX page trace to a trace from TOAD (or sqlplus or whatever). You can do this outside APEX like this...
    ALTER SESSION SET EVENTS '10046 trace name context forever, level 1';Enter and run your SQL statement...;
    ALTER SESSION SET sql_trace=FALSE;This will create a a trace file in the directory returned by...
    SELECT value FROM v$parameter WHERE name = 'user_dump_dest' Which you can use tkprof to format.
    I am assuming that your not going over DB links or anything else slightly unusual?
    Cheers
    Ben

  • Create collection from query with bind variable

    Apex 4.0.2
    Per Joel Re: Collection with bind variable the apex_collection.create_collection_from_query_b supports queries containing bind variable references (:P1_X) but I am not sure how to use this feature, the documentation doesn't have an example, just the API signature for the overloaded version has changed.
    If the query contains 2 bind variable references to session state (:P1_X and :P1_Y), can someone please show an example of what to pass in for the p_names and p_values parameters to the API?
    Thanks
    procedure create_collection_from_query_b(
        -- Create a named collection from the supplied query using bulk operations.  The query will
        -- be parsed as the application owner.  If a collection exists with the same name for the current
        -- user in the same session for the current Flow ID, an application error will be raised.
        -- This procedure uses bulk dynamic SQL to perform the fetch and insert operations into the named
        -- collection.  Two limitations are imposed by this procedure:
        --   1) The MD5 checksum for the member data will not be computed
        --   2) No column value in query p_query can exceed 2,000 bytes
        -- Arguments:
        --     p_collection_name   =  Name of collection.  Maximum length can be
        --                            255 bytes.  Note that collection_names are case-insensitive,
        --                            as the collection name will be converted to upper case
        --     p_query             =  Query to be executed which will populate the members of the
        --                            collection.  If p_query is numeric, it is assumed to be
        --                            a DBMS_SQL cursor.
        -- example(s):
        --     l_query := 'select make, model, caliber from firearms';
        --     apex_collection.create_collection_from_query_b( p_collection_name => 'Firearm', p_query => l_query );
        p_collection_name in varchar2,
        p_query           in varchar2,
        p_names           in wwv_flow_global.vc_arr2,
        p_values          in wwv_flow_global.vc_arr2,
        p_max_row_count   in number default null)
        ;

    VANJ wrote:
    Apex 4.0.2
    Per Joel Re: Collection with bind variable the apex_collection.create_collection_from_query_b supports queries containing bind variable references (:P1_X) but I am not sure how to use this feature, the documentation doesn't have an example, just the API signature for the overloaded version has changed.
    If the query contains 2 bind variable references to session state (:P1_X and :P1_Y), can someone please show an example of what to pass in for the p_names and p_values parameters to the API?Not tried it, but guessing something like
    apex_collection.create_collection_from_query_b(
        p_collection_name => 'foobar'
      , p_query => 'select f.foo_id, b.bar_id, b.baz from foo f, bar b where f.foo_id = b.foo_id and f.x = to_number(:p1_x) and b.y = :p1_y'
      , p_names => apex_util.string_to_table('p1_x:p1_y')
      , p_values => apex_util.string_to_table(v('p1_x') || ':' || v('p1_y')))

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • Af:query with bind variables and Saved Search

    I have a VO and view criteria(VC).
    VC has a criteria item ObsoleteDate with range specified as bindVariables "dateFrm" and "dateTo" I dragged & dropped the named criteria as af:Query with table. Table toolbar has 2 buttons in which I set & clear the bind variables. Data is fetched as per as expected based on the VC & bind variables.
    The problem is,
    If I save my search with bind variables set and swap between the saved searches , all works fine. But the moment I clear bind variables & swap between searches.. "dateFrm" is populated and "dateTo" is null and I get an Exception oracle.jbo.AttrValException: JBO-27035: Attribute Obsolete Date: is required.
    Why is this happening?? Saved search is supposed to save the VC with all the bind values set while saving and clearing bind variables shouldn't affect the saved search, right?? Or I have understood it wrong?
    I am using JDeveloper 11.1.2.3.0
    Thanks

    Try
    like ? || '%'

  • RESTful service and BLOB with bind variable

    Hi,
    Has anyone successfully created a RESTful service with bind variable to retrieve a BLOB field and render it in an Apex app? I can create RESTful web service and render BLOB field for a record with no bind variable (single row). As soon as I add bind variable my RESTful service fails -- I get 404 Error. Without bind variable it renders both in TEST tool of Workspace and direct URL. As soon as I add a bind variable it fails either way. I have reported this in an SR to Oracle support, but thought I would post here too.
    I would also like to retrieve the photo into an Apex application. Any hints would be appreciated.
    Thanks,
    Pat

    Hi Fateh -
    Good question. You would identify the source type as a Media Resource, and use an SQL statement with the primary key and the BLOB column. When you use Media Resource, you are essentially telling your Database Cloud Service not to marshall the data, just to send it - which is exactly what you are looking for.
    With this implementation, you would have to have a separate SQL call for each BLOB retrieval. However, you might be able to use a PL/SQL block as the end point for the RESTful Service and take care of multiple BLOB processing in the block.
    Hope this helps.
    - Rick Greenwald

  • I am switching from an iphone 4s to a 5s. When I try to restore from icloud and then choose a backup, it tells me "No iCloud backups are compatible with the version of iOS on this iphone." How can get into my new phone to update?

    I am switching from an iphone 4s to a 5s. When I try to restore from icloud and then choose a backup, it tells me "No iCloud backups are compatible with the version of iOS on this iphone." How can get into my new phone to update?

    UUpdate the new iphone to iOS 8.3 before you try to restore the backup.

  • HT201342 My email is not arriving on my computer.  The icon from get mail just keeps swirling.  Yesterday I had many messages on the account.  Today there is only one from yesterday and then there is a jump in time back to April 16 with no messages inbetw

    I cannot get me.com mail on my computer today.  The icon just keeps swirling.  I have one message from yesterday and then it drops all read messages back to April 16.  I have restarted the mail program several times. 

    Hello carouselmusic,
    It sounds like you cannot get your iCloud email to download to the Mail app on your Mac. I would use the following troubleshooting to help resolve that from the article named:
    iCloud: Troubleshooting iCloud Mail
    chttp://support.apple.com/kb/ts4002
    If you can't receive mail in OS X Mail
    Locate the name of your iCloud account on the left side of the main Mail window. If your iCloud account name is dimmed and has a lightning-bolt symbol next to it, your account is offline. To bring your account online, make sure that your computer is connected to the Internet, then choose Mailbox > Take All Accounts Online. If that doesn't resolve the issue, follow these steps:
    Choose Preferences from the Mail menu.
    Click Accounts in the Preferences window.
    Select your iCloud account from the list of accounts.
    Click the Advanced tab and verify these settings:
    Port: 993
    Use SSL: (selected)
    Authentication: either "Password" or "Apple Token"
    If this does not resolve the issue, then use the following to remove, and then re add the account:
    To remove an email account in Mail:
    Open Mail (click it on the Dock or open it from the Applications folder).
    From the Mail menu, choose Preferences..., or press Command-, (the Command and comma keys).
    Click the "Accounts" icon.
    Select the account you wish to remove.
    Click the "-" (minus) icon. You will be alerted that "The account's setup information, mailboxes, messages, notes, and to do's will be deleted permanently from your computer."
    If you are sure you want to remove the account and email messages from your computer, click "Remove" to complete this process.
    And
    Open Mail.
    Choose Add Account from the File menu. If this is the first time you've opened Mail, you will be automatically prompted to add an account.
    Enter your Full Name, email address, and password. See Mac 101: Mail article for more information.
    From: Configuring Mail for your email account
              http://support.apple.com/kb/ht1277
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • Query with bind variable, how can use it in managed bean ?

    Hi
    I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
    Thanks

    Put the query in a VO and execute it the usual way.
    If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page.

  • Slow Query over Database Link with Bind Variable

    I have a query over a DB link, with all tables on the remote database.
    If I use a bind variable (from Toad), the query takes 4 minutes. If I replace the bind variable with a constant or substitution variable, it takes 1 second.
    The query runs fine when run directly on the remote database using bind variable.
    9.2.0.7

    Look up "Bind variable peeking"
    What's happened is you have an execution plan that differs from the one with the constant. Why? My bet is that Oracle "peeked" at the bind variable to help it decide which execution plan to build. It then cached it. It probably cached an execution with an index when it should be doing a full table scan or a hash join instead of a nested loop. It's hard to say specifically what it is.
    Try this, flush your shared pool and rerun the query with the bind and let us know if it takes 1 second or 4 minutes. If it takes 1 second, then that was probably it.
    Read part 2 of Tom Kyte's blog post on what it is and it's behavior.
    http://tkyte.blogspot.com/2007/09/sqltracetrue-part-two.html

  • How to use ApplicationModuleImpl.createViewObject for VO with bind variable

    I need to implement a AM method to create VO instance from a generic VODef with bind variables.
    The createViewObject() will trigger the executeQuery of the VO before I can set up the bind variables for the query.
    What is the proper way to create view object instance with bind variables?

    I am using JDeveloper 11.1.1.2.
    I have a ViewObjectA declared with some bind variables which determine what business data to be retrieved at runtime via a service method of the ApplicationModule.
    As the ViewObjectA is only referenced internally within ApplicationModule and I need more than one instance of the ViewObjectA for different conditions at runtime,
    I use ApplicationModuleImpl.createViewObject() to create an instance of ViewObjectA instead of adding ViewObjectA to the data model of the ApplicationModule.
    Currently, when the ViewObjectA is instantiated, it also trigger an executeQuery() which will not retrieve correct data until I set up the bind variables.
    However, the createViewObject() method doesn't let me pass in the values of the binding variables.
    Currenlty, I just call the createViewObject() and then set the binding variables values and call executeQuery() again.
    Just checking if there is a better way to do so...

  • A little bit of help with Bind variables please

    Hi,
    I am having a bit of trouble with bind variables I have been looking at the Dev guide and the forum to try and achieve this and it is still not happening for me, could anybody please help or point me in the right direction:
    I have created a simple PersonVO with the basic query:
    Select distinct full_name from xxml_people where person_id = :1
    In the PersonVOImpl.java I have added the method:
    public void initQuery(String personId)
    Number person = null;
    try
    person = new Number(personId);
    catch
    (Exception e){}
    setWhereClauseParam(1,person);
    executeQuery();
    Then in the PersonAM I have added the method:
    public void initPersonQuery(String personId)
    getPersonVO1().initQuery(personId);
    I then call this method in my processRequest section of my page controller:
    PersonAMImpl am = (PersonAMImpl) pageContext.getRootApplicationModule();
    String personId = "581";
    am.initPersonQuery(personId);
    When I try and run this I get the error:
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT distinct full_name from xxml_absence_calendar where person_id = :1
    java.sql.SQLException: ORA-01006: bind variable does not exist
    Am I binding the variables correctly? Or am I making some stupid mistake?
    I am ultimately looking to create a messageChoice where the logged in user will see a list of all organisations underneath him and the one level above. I plan to do this by passing the User’s Organisation name into a VO query using the organisation as a Bind Variable. I think once I have worked out how to bind variables this should be straight forward.
    Many Thanks

    Even though the parameter binding values may be same, you should never use the positional param more than once. So always go for the format
    select distinct full_name from xxml_people where supervisor_id = :1
    UNION
    select distinct full_name from xxml_people where person_id = :2
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem with Bind Variable in 11.2

    Hi
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3
    Thank you

    904062 wrote:
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3This specific scenario is very much an exception to the rule - and you need to back your statement up with execution plans of the SQL with bind variables and with literals, and run stats that show the difference between these two execution plans.
    See the {message:id=9360003} from the {forum:id=75} forum's FAQ for details on how to post a SQL performance tuning question.

Maybe you are looking for

  • How to insert a picture into excel file using ALE AUTOMATION

    Hi every body, I have to write report that export data from abap to exel the data contain a logo but I don't know how to insert picture to excel using ALE AUTOMATION. Please help me! Thank you!

  • My Macbook Pro (mid 2012) will not go to sleep

    Hi - looking forward to your help! My Macbook Pro simply will not go to sleep - not by shutting the lid or pressing the sleep button in the Apple dropdown. There are no random apps that are preventing it from sleeping - I have checked after looking a

  • Use of 'sequence-next-val' in JDEV

    All, As part of my ESB project, I'm integration an appln. with Oracle EBS. My requirement is to populate a field with a sequence value. I found there is a db function in Jdev. As per the note, I used the 'sequence-next-val' function to generate seque

  • Processing time in NWBC

    We are seeing real delays in the processing time in NWBC compared to regular SAP, is there anything we can do to improve this performance? Vickie

  • Mac mail: Use SSL on SMTP Server turning on

    I recently received and set up a new macbook pro (OSX 10.8.3) and I use it in both a wireless and wired network state. I set up some POP accounts in my mac mail, and everything works great.  But it seems that whenever I switch between networks, the "