output with bind variable to sqlplus and then echo $?

Hello world.

I don't know why they are different between: v_num and the value of "echo $?"

Thank you.
------------------------------------------------------------------------------------
SANOWT: oratest: / data3, oratest, oratest, hgjung > cat t.sql
Select count (*) in object;

Number of the v_num variable.
Start
Select count (*) in: v_num object;

exception
When no_data_found then
: v_num: = 1403;

end;
/

output *: v_num *.
SANOWT: oratest: / data3, oratest, oratest, hgjung > scott \sqlplus / * @t

SQL * more: release 10.2.0.3.0 - Production 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 - 64 bit Production
With partitioning, OLAP and Data Mining options


COUNT (*)
----------
* 50497 *.


PL/SQL procedure successfully completed.

Disconnected from the database to Oracle 10 g Enterprise Edition Release 10.2.0.3.0 - 64 bit Production
With 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 of the program. In most * NIX versions I know, it is limited to values between 0 and 255 (i.e. a byte), so the value is truncated.  The hexadecimal value of 50497 is C541 or two bytes, so the $? variable is only to get the last byte of 0x41, which is decimal 65.

John

Tags: Database

Similar Questions

  • EO base extension VO with bind variables and display - How To link

    Hello

    I extended an APInvDistAllVO view object by adding two fields which are functions. Basically, in the invoice approval screen, I want to add two fields where the distribution of the invoice is shown.

    The SQL contained in jdeveloper when you extend the VO object is different from the query, what I see in the invoice approval page by clicking on the APInvDistAllVO link. There are two bind variable: 1 = invoice_id and: 2 = line_number being added dynamically. After the extension of the view object, the invoice distribution line is displayed as no record found.

    In my opinion, it is due to not having bind variables does not correct parameters being passed, and under this point of view object is an object depending on the invoice header record. There is a link to the original View object as well. Will be very grateful if someone can provide the way forward in dealing with this situation.

    Rgds Fahad

    Hi AJ

    He worked after changing the style of bind.

    Thank you very much.

    Rgds

    Fahad

  • Insert with bind variables

    I will execute bind_test.sql with the following parameters to sql-plus. The script runs without error. However, it does not insert a row in the table.


    bind_test. 20100912 1 1001 SQL;


    bind_test. SQL
    ----------------------------------------------------------
    Set serveroutput on

    declare

    X VARCHAR2 (31);
    NUMBER OF Y;
    NUMBER OF Z;

    Start

    dbms_output. Enable (10000);
    X: = "& 1";
    Y: = & 2;
    Z: = & 3;

    Insert in the test
    values (TO_DATE (X, 'YYYYMMDD'), Y, Z, null, null, null);


    commit;


    dbms_output.put_line ('var1 = "|") X | "var2 =" | THERE | "var3 = ' |" (Z);

    end;
    /

    ----------------------------------
    Output:
    10 old: X: = "& 1";
    10 new: X: = '20100912';
    old 11: Y: = & 2;
    11 new: Y: = 1;
    12 old: Z: = & 3;
    12 News: Z: = 1001;
    var1 = 20100912 var2 = 1 var3 = 1001

    PL/SQL procedure successfully completed.
    ---------------------------------------

    Select * from test;

    no selected line


    Why it is not insert a line? What could be the reason?

    Thanks in advance.
    Amit

    user5922214 wrote:

    I have a big script with multiple INSERT and DELETE statements. I have been asked by DBA to use bind variables rather than direct assignment parameter values in which the condition.

    Impossible.

    Use of variable bind from a client means:
    (1) customer create a unique SQL cursor with bind variable, for example INSERT INTO FOOTABLE VALUES (: 1,: 2: 3)
    (2) customer from a loop of data read
    2.1) reading the customer data (from file, network, device, whatever)
    customer liaison variables 2.2) cursor (assigning values to 1 to 3 SQL cursor variables)
    2.3) client running the cursor
    line insertions 2.4) database
    loop repetitions of 2.5) client for all data
    (3) customer closed the SQL cursor

    This can be done using a SQL script - as a SQL script is not a loop where a single insertion cursor is used. It's a unique script with 100 or 1000 of SQL insert statements. Where each insert statement will result in a cursor SQL must be created.

    SQL * also does not support the approach of customer liaison above variable. It is a command line interface very PRIMITIVE and unsuitable for running scripts from loading/data entry.

    In your case - the right approach would be to have the data into a CSV file, and then load this file using SQL * Loader... where this software will use customer approach above (in fact he still does better because it uses in bulk link and link not row as described above).

  • R12 Extension with bind variables-how VO EO

    Hello

    I extended an APInvDistAllVO view object by adding two fields which are functions. Basically, in the invoice approval screen, I want to add two fields where the distribution of the invoice is shown.

    the SQL contained in jdeveloper when you extend the VO object is different from the query, what I see in the invoice approval page by clicking on the APInvDistAllVO link. There are two bind variable: 1 = invoice_id and: 2 = line_number being added dynamically.

    After the extension of the view object, the invoice distribution line is displayed as no record found. In my opinion, it is due to not having bind variables does not correct parameters being passed, and under this point of view object is an object depending on the invoice header record.

    Will be very grateful if someone can provide the way forward in dealing with this situation.

    Rgds

    Fahad

    User, please ask your question in the forum OA Framework .

    Timo

  • problem with bind variables in the SQL query view object

    Hi all

    I use JDev 11.1.2.4.0.

    I have a problem with bind variables in the SQL query view object.

    This is my original SQL

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE t.nctuser_id = '20022' 
          AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929')
    group by t.legertype_id
    

    In my view .xml object query tab, I am writing this

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE   t.nctuser_id = '20022'
        AND to_char(t.insertdate,'YYYYMMDD') in :dddd
    group by t.legertype_id
    

    Davis here is a variable of Type liaison: String, updatable and necessary.

    I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.

    But failed. The view object retrieves 0 line after that I run.

    Why?

    Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')

    A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.

    Timo

  • Problems with Bind Variables

    SELECT co.ref_num, co.forename, co.surname, co.dob, a.address, a.postcode,
           co.ni_num
      FROM address a, contact co
     WHERE co.ref_num = a.ref_num
       AND (:1 IS NULL OR co.forename = :2)
       AND (:3 IS NULL OR co.surname = :4)
       AND (:5 IS NULL OR a.postcode = :6)
       AND (:7 IS NULL OR a.address = :8)
       AND (:9 IS NULL OR co.dob = :10)
       AND (:11 IS NULL OR co.ni_num = :12)
    With a jdbc connection, we use a web front end for a new management system. The SQL above runs since a search screen. We meet a few serious problems with bind variable and execution plans. When the above query is sent by the database 'AND' clauses could evaluate as follows:
    AND ('Tim' IS NULL OR co.forename = 'Tim')
       AND ('Clarke' IS NULL OR co.surname = 'Clarke')
       AND ('' IS NULL OR a.postcode = '')
       AND ('' IS NULL OR a.address = '')
       AND ('25051981' IS NULL OR co.dob = '25051981')
       AND ('' IS NULL OR co.ni_num = '')
    We cannot dynamically assign 'AND' conditions so they are sent through to the database. This translates FTS 99% of the time as the execution plan never prescribed any of the available indices.

    Someone has suggestions on how to better 'control' bind variables?

    Hello

    Don't you think that 'OR' Conditions are necessary to check for Null, where the binding variable is NULL or not.

    I think that rather than running the query from the front to FB, try to convey the values of some MS and run this query in the procedure, the extraction from the point of view Design coding application. Never fire the query of the frontal part.

    To come to the problem.

    SELECT co.ref_num, co.forename, co.surname, co.dob, a.address, a.postcode,
    Co.ni_num
    ADDRESS, contact co
    WHERE co.ref_num = a.ref_num
    AND (: 1 co.forename IS NULL or =: 2)
    AND (: 3 co.surname IS NULL or =: 4)
    AND (: 5 a.postcode IS NULL or =: 6)
    AND (: 7 a.address IS NULL or =: 8)
    AND (: 9 co.dob IS NULL or =: 10)
    AND (: 11 co.ni_num IS NULL or =: 12)

    Use the procedure.

    Fact exits of the indexes on the tables and stats are updated...?
    Try to predict explain it. ??

    -Pavan Kumar N

  • I have an Acer computer I want to do a total restore. It came with windows 7 starter edition, and then I bought Microsoft word for it. If Microsoft word will lose if I do the restoration?

    I have an Acer computer I want to do a total restore. It came with windows 7 starter edition, and then I bought Microsoft word for it. If Microsoft word will lose if I do the restoration?

    If you purchased Word on CD, it's no big deal; just reinstall it after the factory restore. If it was bought online, copy the file downloaded to a CD and then reinstall it later.

    Is there a particular reason, why you want to do a restore complete? Have you problems? If so, you can try asking here on how to fix them and do not have to do a restore, reinstall all your programs and all of the updates and service pack 1.

    SC Tom

  • Problem with Bind variable cannot be changed.

    Hi all
    I use Jdev 11.1.2.3.0. In my VO, I created a Bind Variable and set it NOT UPDATABLE. Then, I created a display with some other Variables Bind criterion.
    I use this criterion to display on a search page, but when running, I see also an inpunt for the defined variable NOT UPDATABLE text and I can't change its value.
    Of course, if I try to change the value, and I do research, I get an error.

    It is the source of the VO:

    < variable
    Name = "UlssVar".
    Type = "where".
    Type = "Java.lang.String"
    IsUpdateable = "false" >
    < TransientExpression > <! [CDATA [adf.context.current.sessionScope.get ('ulss')]] > < / TransientExpression >
    < / variable >

    Is this a bug of the ADF?
    I thank in advance.

    Hello

    try selecting the variable binding and open the property inspector, under the guidance of the user interface, set the flag of 'view' to hide. This should hide it (no bug for this reason)

    Frank

  • JDev 11.1.2.1 method Execute (with bind variable) before the page is displayed

    Hi all

    I have a view object with a query that uses a variable binding. I drag the data on my .jsf page control to create a table. I create a query method on a bean in sight. The query method uses the content of one of the attributes of the bean to set the link for the query variable:

    vo.setNamedWhereClauseParam ("CraIdBindVar", sessionBean.getCraId ());

    I put a button on the page that calls the method of the request and it fills the table. That's fine, but I don't want the user to have to click the "query" button when browsing this page. I found forums dealing with create an AMImpl.jave method, create a link on the page, create an executable file for the link. It works that the method is executed until the page appears. However, the AMImpl method cannot call sessionBean.getCraid () to obtain the data required to complete the binding variable.

    Is it possible to run my method of view range bean before the page is displayed? Or maybe a way for the AMImpl.java method to access the range of view variable?

    Thank you, Steve

    Steve,
    You can drag a call method on the workflow activity. Select the new method call activity, and open the property inspector. Here you choose your bean method in the method property. Now, first of all, you go to this activity of method call, then the page.

    Timo

  • Query report back "No data found" with bind variables

    I put a simple query in the report query:

    Select "bluefish". 'name' as 'name',
    "bluefish". "" primary_flag "as"primary_flag. "
    "bluefish". "" status "than"status. "
    "bluefish". ' ' ID ' as 'ID' of "bluefish" "bluefish" where "bluefish". "" ID "=: P3_XPRINTID

    When I test the query, the data is returned. However, when I try to run the query using the "Test report" button, I get an error 01403 no data found. If I replace the link with an explicit value variable, the report runs.

    Anyone have any ideas as to what is causing this problem? I use the generic report layout, with different types of output. I'M editting the query and set the binding variable before test report (otherwise, the query is not executed).

    Charles

    In fact the report would go - unlike other products of Oracle who complain about a missing binding variable, Apex is not complaining but interprets as a null value. So if you hurt typed the name of your variable, you are never alerted to it.

    Check the Session window to make sure that it is a value - the most common questions are that you named the wrong variable in the query or your item has no value in session state again.

  • Need help with Bind variable in AF LOV query

    Hello

    I have a problem with the binding variable, if I use bind variable in the VO LOV query then my result does not come, if he has do not bind variable it works fine and if I use the variable binding in the LOV search option then it works fine but if I hide the bind variable and set the value in the prepareSesstion AM method the LOV does not return any value. I try to return the values that also all values are also coming, but these values are not the attribute query AF setting.

    Query is:

    Select substr(d.description,0,40) description
    cm_system_users has
    b cm_user_responsibilities,
    cm_responsibility_processes c,
    cm_processes d
    where a.nt_login =: B_NT_LOGIN
    and a.user_id = b.user_id
    and trunc (sysdate) between b.eff_date and nvl (b.exp_date, sysdate + 1)
    and b.RESPONSIBILITY_ID = c.RESPONSIBILITY_ID
    and c.process_type = d.process_type
    and d.enabled_flag = 'Y' order of d.arguments_flag

    FOLLOW the method:

    CmProcessViewImpl vo = getCmProcessView();
    String nt_login = getUserPrincipalName();
    vo.setNamedWhereClauseParam ("B_NT_LOGIN", nt_login.toUpperCase ());
    vo.executeQuery ();

    Can someone help me with this. It is urgent for me.

    It's a bit underdescribed. IIUC, the purpose of the notice is used as a target for a correct view accessor? (Otherwise, you will have to be more explicit about what you mean by "LOV query".

    If I'm right, there are two possibilities:

    (1) you use an instance of VO in a module shared application instance. If so, make sure that your code is in the prepareSession() for the class of application that module if it is dependent on session (as seems to be below), you must make sure that the module of the application instance is shared in the session scope.
    (2) you have based the view accessor directly on the definition of the VO. This creates an anonymous instance of VO; I don't think there is a way to use prepareSession() to set a variable of liaison on such a forum (which will not be created until the accessor is first used). Pourriez be able to shoot with to put a similar code in the view object create() method class, but I've not tested this.

    If your code is in your module class application primary (as opposed to the class for a shared of AOS instance), the problem here is that getCmProcessView() returns the instance of VO data module of this application instance design-time model, which is never used by accessors of the view.

    Also, why do you need to do this in prepareSession() rather than at the level of the accessor to view? I believe you can get the user name (for the view accessor) with the groovy expression

    viewObject.DBTransaction.session.userPrincipalName

    or maybe just

    DBTransaction.session.userPrincipalName

    (despite this DBTransaction involving, it returns the username web app, not the DB user name).

    It is a declarative 100% solution, if you don't count the Groovy expression as not declarative.

    If you are afraid of a user who is running the LOV (somehow) before the value of the bind variable is preparing, just make sure that the binding variable is marked "required."

  • Estimates of cardinality for index range scan with bind variables

    Oracle 11.2.0.4

    I am struggling to explain that the cardinality estimates for a scan of the index systematic range when using the bind variable.

    Consider the following query:

    SELECT /*+ INDEX(t1) */ *
    FROM   t1
    WHERE  source_id <= ?;
    
    

    Cardinalities for the INDEX RANGE SCAN and ACCESS of the TABLE are the same for different literal predicates, for example, source_id < = 5:

    ------------------------------------------------------------------------------------
    | Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |      |    50 |   350 |    12   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T1   |    50 |   350 |    12   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IX1  |    50 |       |     2   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("SOURCE_ID"<=5)
    
    

    If a variable binding is used instead of a literal, the overall selectivity is 5%. However, why the optimizer based on CSSTidy gives a cardinality estimated 11 for the scan of the index systematic range? As with the predicates literal, surely the cardinalities of the index range scan and access table should be the same?

    ------------------------------------------------------------------------------------
    | Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |      |    50 |   350 |     5   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T1   |    50 |   350 |     5   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IX1  |    11 |       |     2   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("SOURCE_ID"<=TO_NUMBER(:A))
    
    

    Unit test code:

    CREATE TABLE t1
    ( id NUMBER
    , source_id NUMBER
    );
    
    CREATE INDEX ix1 ON t1 (source_id);
    
    INSERT INTO t1
    SELECT level
         , ora_hash(level,99)+1
    FROM   dual
    CONNECT BY level <= 1000;
    
    exec DBMS_STATS.GATHER_TABLE_STATS(user,'T1')
    
    EXPLAIN PLAN FOR
    SELECT /*+ INDEX(t1) */ *
    FROM   t1
    WHERE  source_id <= 5;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    EXPLAIN PLAN FOR
    SELECT /*+ INDEX(t1) */ *
    FROM   t1
    WHERE  source_id <= :a;
    SELECT * FROM TABLE(dbms_xplan.display);
    
    

    There are various places where the optimizer uses an assumption, and lie unpeekable (and of Villa "unknowable value") introduced guess.

    For unpeekable binds the conjecture for column<= {unknown}="" is="" 5%="" for="" table="" access="" (hence="" 50="" rows="" out="" of="" 1,000),="" but="" it's="" 0.009="" for="" index_column=""><= {unknown},="" which="" means="" i="" was="" expecting="" to="" see="" 9="" as="" the="" row="" estimate="" on="" the="" index="" range="">

    I just ran some quick tests, and EXPLAIN the PLAN seems to just use 0.011 selectivity in this case (in different versions of Oracle) although if we do the bind variable unpeekable at run time (and sample dynamic block etc.) optimization for execution is 0.009%.

    Concerning

    Jonathan Lewis

    Update: and this is a very old reference to the 0.009 (and 0.0045 for ' between the ' when it is applied to a clue: cost based Oracle - access Chapter 4 single B-tree )

  • Create the collection of query with bind variable

    Apex 4.0.2

    By Joel Re: Collection with variable binding the apex_collection.create_collection_from_query_b supports queries containing references to the bind variables (: P1_X) but I don't know how to use this feature, the documentation is not an example, just the API signature for the overloaded version has changed.

    If the query contains 2 bind session state variable references (: P1_X and: P1_Y), can someone please show an example of what to spend for the parameters p_names and p_values to the API?

    Thank you
    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)
        ;

    HELEN wrote:
    Apex 4.0.2

    By Joel Re: Collection with variable binding the apex_collection.create_collection_from_query_b supports queries containing references to the bind variables (: P1_X) but I don't know how to use this feature, the documentation is not an example, just the API signature for the overloaded version has changed.

    If the query contains 2 bind session state variable references (: P1_X and: P1_Y), can someone please show an example of what to spend for the parameters p_names and p_values to the API?

    Not tried, but guess 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')))
    
  • VO with bind variable defined in SQL is not updated correctly

    Hi Experts,

    I have a simple question here, could you please help answer? Thank you very much!

    I have 2 pages, the first page displays an employee table, the second page shows a few details to the selected employee. When to choose a single employee and click the details button I can be naviaged to the second page and see the details for the selected employee. The vo used on the second page uses a connection variable called "empId" thing for a 'adf.context.pageFlowScope.empId' pageFlowScope value, and this value pageFlowScope will be filled to the empId selected detail button actionListener during execution).

    The question is, now first navigation is ok, the details of the page can display the correct information for the employee selected on the page of the employee, but when browsing back and choosing another employee, and then again click the details button, the details of the page is NOT updated, it still shows the initial information for the selected employee. I debug the actionListener in support bean and the second selected empId passed to pageFlowScope.empId, the link in the t variable should get the new value, right? But why the second page gets no updates (request using the new value of the bind variable)?

    Thank you!

    Published by: user774592 on July 20, 2011 23:13

    Published by: user774592 on July 20, 2011 23:15

    Published by: user774592 on July 20, 2011 23:15

    In theory, if you expose specific objects of customer to your business (for example pageflowscope) service layer, you may miss 1. test driven development assistance (case of unit test can fail) 2. Customer service of independent business etc... :)
    To respond to your request try to call TargetPagesVO.execute () before the second page (by program or activity method)

  • IN construction in the clause WHERE of VO with bind variable

    Hello
    With the help of JDev 11.1.1.3.0.
    I have a SQL according to VO following where clause ' WHERE some_nbr IN: inSomeNbrStr'
    -l' some_nbr attribute is of type oracle.jbo.domain.Number.
    -variable binding inSomeNbrStr is of type String.
    I'm assuming that this variable linking parameter to for example. "101, 102' or '(101, 102) ' before the execution of the query might work.
    "However, I get ' ORA-01722: invalid number." Other than the substitution of executeQueryForCollection() and manipulate by program the
    query is - anyone know a more declarative way to achieve this?
    Thank you
    Kenneth

    Hello

    You "MOUNT" the binding variable to get the values separated by commas.

    See this article (Search Using Comma-Separated bind string for the Variable in the list) on how to achieve this.

    It has been developed over 10g. But I think it will hold good for 11g as well.

    Arun-

Maybe you are looking for