Output problem with write() function.

Hi there
This program produced the output only when i add "System.out.write('\n')",
WHY?
import java.io.*;
class WriteBytes
public static void main(String[] args) throws IOException
byte[] b = {'T','e','s','t'};
for(int i = 0; i < b.length; i++)
System.out.write(b);
System.out.write('\n'); // Why if i comment this line then, don't get the output.

Your program is finishing before the buffer has a chance to flush. The newline character is forcing a flush to the print output. You could use System.out.println() to force the newline or System.out.flush() would work as well.

Similar Messages

  • Error thread java : problem with the function "resume 0x***"  (forum sun)

    One problem with the function of jdb occured when I tried to use it to
    pilot the processor with differents threads. In fact, I use a simple example with 2 threads.
    I stop the two threads with two breakpoint, and I want to resume one or the other (with the function "resume 0x****"), the one wich I resumed stop again on the breackpoint and I decide again to resume one or the other. All of that to obtain a tree of execution.
    I give you the code of the class and the code of jdb.
    CLASS: (it's just a object Room with a variable degre that I increment and decrement with two threads increase and decrease)
    public class Test{
         public static void main(String[] args){
              Room r = new Room();
              decrease de = new decrease(r);
              increase in = new increase(r);
              de.start();
              in.start();
    class Room {
         private volatile int degre=20;
         public void more(){
         degre += 4;
         public void less(){      
         degre -= 3;
    class decrease extends Thread{
    private Room room;
    public decrease(Room r){
              room =r;
    public void run(){
    try{ 
         while (!interrupted()){ 
              room.less();
    catch(InterruptedException e) {}
    class increase extends Thread{
    private Room room;
    public increase(Room r){
         room =r;
    public void run(){ 
         try{ 
              while (!interrupted()){
                   room.more();
    catch(InterruptedException e) {}
    JDB:
    Initializing jdb ...
    stop at Test:7Deferring breakpoint Test:7.
    It will be set after the class is loaded.
    runrun Test
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >
    VM Started: Set deferred breakpoint Test:7
    Breakpoint hit: "thread=main", Test.main(), line=7 bci=30
    7 in.start();
    main[1] stop at room:16
    Set breakpoint room:16
    main[1] stop at room:20
    Set breakpoint room:20
    main[1] resume
    All threads resumed.
    >
    Breakpoint hit: "thread=Thread-0", room.less(), line=20 bci=0
    20 degre -= 3;
    Thread-0[1] threads
    Group system:
    (java.lang.ref.Reference$ReferenceHandler)0x10d Reference Handler cond. waiting
    (java.lang.ref.Finalizer$FinalizerThread)0x10c Finalizer cond. waiting
    (java.lang.Thread)0x10b Signal Dispatcher running
    Group main:
    (decrease)0x146 Thread-0 running (at breakpoint)
    (increase)0x147 Thread-1 running (at breakpoint)
    (java.lang.Thread)0x148 DestroyJavaVM running
    Thread-0[1] resume 0x147
    Thread-0[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] resume 0x147
    Thread-1[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] print degre
    degre = 24
    Thread-1[1] resume 0x146 //It's here the problem, thread 0x146 have to stop on the //next breakpoint of decrease but nothing happen
    Thread-1[1] resume 0x147
    Thread-1[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] clear
    Breakpoints set:
    breakpoint Test:7
    breakpoint room:16
    breakpoint room:20
    PS: I tried many other examples with other class and other kind of breakpoints, but, in any cases, on thread doesn't manage to resume. When I try with general resume (no specification of the thread), It works but it isn't interresting for me because I want to decide wich thread continue his execution.

    Hi,
    I have read the FAQ of the JMF.
    The problem was the jar files of the JMF were not in the JRE\BIN\EXT
    folder of the Java runtime!
    now it works!
    thanks
    Reg

  • Problem with 'GetType' Function calling in MSVC++

    Hello
    I have problem with the function in TestStand API .
    When I call the function " GetType " with the following statements in
    a DLL called from TestStand (NI) implemented in MS VC ++
    , it does not work and this exception is caught by the ONLY ' try catch ' block
    to catch exceptions in TestStand API giving the error message
    " Unexpected operating system error".
    VARIANT_BOOL ok;
    VARIANT_BOOL hi;
    BSTR Name;
    PropertyObject *property = (*step_)->AsPropertyObject();
    ( *step_ is a STEP Object of type Step* *step_ )
    property = property->GetPropertyObject( "TS.SData", 0);
    enum TS:ropertyValueTypes i = property->GetType( "" , 0 , &hi , &ok
    , &Name);//Problem
    Please solve my problem.
    You can email me at [email protected]
    Thankyou very much.
    Best regards
    Fahad Ejaz

    Hello,
    The problem is that the Name is not initialized (the BSTR is defined as OLECHAR*). Thus, replace the
    BSTR Name;
    declaration with the following lines:
    char buf[1024];
    BSTR Name = _bstr_t(buf);
    This should solve the problem.
    Best Regards,
    Silvius
    Silvius Iancu

  • Problem with CONTAINS function

    Hi all!!
    i got a problem with contains function. i'm running oracle 11g.
    if i execute this query:
    SELECT x.lid as id,  x.sztitular as titular, e.szname as proName, x.szresumen  as resumen, b.sztitle  as catName,
    f.szname  as secName, d.szname  as cliName, x.datecreation as datecreation
    FROM CPR_PRACTICAL_CASE x,ctg_category b, CPR_CLIENT d, pro_product e, CAT_SECTOR f, CPR_PCASE_PRODUCT g, CPR_PCASE_SECTOR h,
    PRO_PRODUCTCATEGORY i WHERE  x.lid = g.lpcaseid and e.lid = g.lproductid and x.lid = h.lpcaseid
    and f.lid = h.lsectorid and x.lclientid = d.lid and i.lproductid = e.lid and  b.lid = i.lcategoryid
    AND x.szlocale = 'es-ES' AND  x.bavailable = '1'i get 1 row as result with the column sztitular = "rodillos de medidas"
    if i only add one more sentece to that query:
    AND CONTAINS( x.sztitular, 'rodillos',1) >0the query returns an empty set.. i really don't understand why because the term "rodillos" is present in the row's column called "sztitular"...
    i've put an index on that column:
    create index ITXT_TITULAR on CPR_PRACTICAL_CASE(sztitular) INDEXTYPE IS CTXSYS.CONTEXT;any help?
    many thanks!!!!
    Edited by: ElMazzaX on May 21, 2012 5:51 PM
    Edited by: ElMazzaX on May 21, 2012 5:53 PM

    How are you synchronising the index?
    http://docs.oracle.com/cd/E11882_01/text.112/e24435/ind.htm#i1008452
    Also see the Oracle Text forum:
    Text

  • Performance problem with OLE_FLUSH_CALL function module

    Hello Everyone,
    I am facing problem with OLE_FLUSH_CALL function module (execution is taking long time which is going to be dump error).
    Could you please help me in knowing solution for this problem?
    Thanking you in advance.
    Srinivas

    Hi Srinivas,
    the OLE_FLUSH_CALL does an RFC from ABAP backend to frontend UI. So high execution time could result from high network time, for example latency between UI and backend server.
    How many UI interaction steps did you measure for the trace above? Ideally, there should only be one OLE_FLUSH_CALL per user interaction step. If its more, the application is not written in an optimized way.
    Best Regards, Randolf

  • For users having problems with Mail functionality...

    Hello! I have been having problems with Mail functionality as well, so, I took a few steps to see if I could solve the problem on my own.
    My problems were:
    Mail would freeze when sending mail, or, when I pressed quit, it would freeze.
    If I toggled between inboxes too much it would freeze up.
    Even after trying the many techniques others offered on this board, Mail still froze up. So.. here's what I did:
    1.) Turn off the auto-retrieve mail function in the preferences/general menu. Set it to a manual check. Just check it yourself every once in awhile. It may not be as convenient, but it works, trust me.
    2.) Under the fonts and colors menu, set all three fonts to the SAME font (mines Century Schoolbook, but anything works) and turn off fixed-width font. Sometimes mail has a tough time decoding and working with texts, and causes it to freeze.
    3.) Clean our your main inbox! Place the emails that you want to keep, but don't need to be in your inbox in a new folder on your inbox bar (mines aptly named 'Saved Messages.' That way, when you open up Mail to your default account, it doesn't have 1,000+ messages to index. Also, try to keep the inboxes from having more than 100-200 messages per. It seems to frown on any more than that.
    After trying these three easy, steps, restart mail and see if things run smoother. I have had no problems since these changes, and mail runs a ton better. Plus you don't have to worry about deleting your library/mail folder anymore. Let me know if things work out so I can see if my theory is a universally proven thing. Thanks and good luck!
    iMac G5 20"   Mac OS X (10.4.5)  

    Good question. I have worked very little with IMAP other than as a testing device, so, on a daily routine I cannot say how it would function. However, I can only expect that by having the option to download all emails for offline viewing selected, you are right in it being a lag creator. Another suggestion would be, if you are running a single-computer setup, to have the account delete emails from the server after recieving them on your computer. Thus, you reduce the risk of repeat downloads or unnecessary build-up on the server end. DO NOT select this option if you run multiple computer set ups on one AppleMail account system or you will cause some discrepancies and/or data loss from system to system. Or, if you have emails redirected from a seperate server to Mail (i.e. I redirect mail from my university email account into Mail so that I don't have to go to the web-mail site to check it--> just like Gmail or Yahoo etc etc) you won't be able to check them from the web-based email system if you have the system delete them. Ok that sounded confusing. Solution: have the system remove emails from the server after a week (or any period of time, just not immediately) so that, in the off-chance you need to use the online system, you will have access, and will give you a chance to check the emails on other systems without a threat of data corruption (by corruption i mean that frustrating feeling you get when you can't find that super important email that was in your inbox just 10 seconds ago on your desktop etc.)
    I will see if I can learn anything more about IMAP Ernie. Its definitley the biggest problem source for Mail, POP and .Mac being simple and functional as long as you don't play with the settings too much. As far as the issue of Offline viewing goes, try turning it off and seeing how Mail functions.
    BEFORE you turn it off, however, I recommend saving all of your emails in your inbox as a text file or something so, in case the server burps and has a brain flatuence, you don't lose anything. Been there, done that, thrown the books against the wall in a frustrated rage.
    My only reserve about the Offline Viewing is whether or not Mail will, when you click "recieve mail," have to re-download the emails from the server each time. If so, then it may end up taking longer and lagging more. The issue here is obviously minimizing the amount of activity between Mail and the email server without jeapordizing information on the server or multiple Mail programs on the same account. When we can find that balance, I think Mail's potential will be realized. Keep the questions coming.

  • Problem with BAPI_SALESORDER_CHANGE function module

    I know lot of posts have been done about problems with this function module. However I was not able to find the answer to my problem. Hence posting a new thread
    I have the following code which changes the reason rejection (if required to 'ZF') and also updates the sales order quantity.
    The code works absolutely fine as long as the PGI date of the order item is either today or in the future. However if the PGI date of the order item is in the past. I get an error in the t_return table with error type 'E' saying 'PGI date is in the past hence could not update the item'.
    If I try to update the same order quantity in VA02 for the item with PGI date in the past it does so without any problem.
    Can someone please suggest what the problem might be. Or if there is some other way I can update the quantity. (I dont want to use BDC)
    FORM change_sales_order_item USING value(r_rtb_posnrs) TYPE zpsd_ztsdrtb_ro_track
                                 CHANGING r_return TYPE type_t_bapiret2.
      DATA: v_order_header_in TYPE bapisdh1,
      v_order_header_inx TYPE bapisdh1x,
      t_schedule_lines TYPE bapischdl OCCURS 0 WITH HEADER LINE,
      t_schedule_linesx TYPE bapischdlx OCCURS 0 WITH HEADER LINE,
      v_temp_rtb_vbeln TYPE vbeln,
      v_temp_rtb_posnr TYPE posnr,
      wa_old_rtb_posnrs TYPE ztsdrtb_ro_track,
      t_item_in TYPE bapisditm OCCURS 0 WITH HEADER LINE,
      t_item_inx TYPE bapisditmx OCCURS 0 WITH HEADER LINE,
      v_rtb_old_vbeln TYPE zrtbvbeln,
      v_rtb_old_posnr TYPE zrtbposnr,
      v_ro_old_vbeln TYPE zrovbeln,
      v_ro_old_posnr TYPE zroposnr,
      v_rtb_count TYPE i,
      v_next_row_index TYPE i,
      v_update_order_flg TYPE char1, "Update the sales order flag
      v_rtb_record_counter TYPE i,
      v_original_vbeln TYPE vbeln,
      t_bapiret TYPE STANDARD TABLE OF bapiret2.
      FIELD-SYMBOLS: <wa_r_rtb_posnrs> TYPE ztsdrtb_ro_track,
                     <wa_r_rtb_posnr_next> TYPE ztsdrtb_ro_track.
      CONSTANTS: c_updateflag TYPE bapisditmx-updateflag VALUE 'U'.
      v_order_header_inx-updateflag = 'U'.
    Get rid of the duplicate records for the same RTB order. Just use
    the last record quantity in the internal table
      LOOP AT r_rtb_posnrs ASSIGNING <wa_r_rtb_posnrs>.
        v_rtb_record_counter = v_rtb_record_counter + 1.
        <wa_r_rtb_posnrs>-seqnr = v_rtb_record_counter.
      ENDLOOP.
      SORT r_rtb_posnrs DESCENDING BY zrtbvbeln zrtbposnr seqnr zrtbconsumedflg.
      DELETE ADJACENT DUPLICATES FROM r_rtb_posnrs COMPARING zrtbvbeln zrtbposnr.
      DESCRIBE TABLE r_rtb_posnrs LINES v_rtb_count.
      v_rtb_record_counter = 0.
      v_update_order_flg = space.
      LOOP AT r_rtb_posnrs ASSIGNING <wa_r_rtb_posnrs>.
        v_rtb_record_counter = v_rtb_record_counter + 1.
        v_update_order_flg = space.
    Popluate the item quantity update flags for schedule lines
        t_schedule_linesx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
        t_schedule_linesx-sched_line = '0001'.
        t_schedule_linesx-updateflag = c_updateflag.
        t_schedule_linesx-req_qty = 'X'.
        APPEND t_schedule_linesx.
        CLEAR t_schedule_linesx.
    *Item (Order QQuantity Field to be changed "KWMENG")
        t_schedule_lines-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
        t_schedule_lines-sched_line = '0001'.
        t_schedule_lines-req_qty = <wa_r_rtb_posnrs>-zrtbchgqty.
        APPEND t_schedule_lines.
        CLEAR t_schedule_lines.
    If fully consumed then set the rejection flag
        IF <wa_r_rtb_posnrs>-zrtbconsumedflg = 'X'.
          t_item_inx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_inx-updateflag = 'X'.
          t_item_inx-reason_rej = 'X'.
          APPEND t_item_inx.
          CLEAR t_item_inx.
          t_item_in-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_in-reason_rej = 'ZF'.
          APPEND t_item_in.
          CLEAR t_item_in.
        ELSE.
          t_item_inx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_inx-updateflag = 'X'.
          t_item_inx-reason_rej = 'X'.
          APPEND t_item_inx.
          CLEAR t_item_inx.
          t_item_in-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_in-reason_rej = ' '.
          APPEND t_item_in.
          CLEAR t_item_in.
        ENDIF.
    If you have reached the last line of the RTB intern table update the sales order
    *Index pointing to the next row
        v_next_row_index = v_rtb_record_counter + 1.
        IF v_rtb_record_counter = v_rtb_count.
          v_update_order_flg = 'X'.
        ELSEIF v_rtb_record_counter < v_rtb_count.
    Get the next row data
          READ TABLE r_rtb_posnrs INDEX v_next_row_index ASSIGNING <wa_r_rtb_posnr_next>.
          IF sy-subrc = 0.
            IF <wa_r_rtb_posnrs>-zrtbvbeln <> <wa_r_rtb_posnr_next>-zrtbvbeln.
              v_update_order_flg = 'X'.
            ENDIF.
          ENDIF.
        ELSE.
          v_update_order_flg = space.
        ENDIF.
    update the rtb orders with quantities and the rejection flag (if required)
        IF v_update_order_flg = 'X'.
          CALL FUNCTION 'BAPI_SALESORDER_CHANGE' STARTING NEW TASK 'SOUPDATE'
            PERFORMING callbk_bapi_salesorder_change ON END OF TASK
            EXPORTING
              salesdocument    = <wa_r_rtb_posnrs>-zrtbvbeln
              order_header_in  = v_order_header_in
              order_header_inx = v_order_header_inx
            TABLES
              return           = t_return
              schedule_lines   = t_schedule_lines
              schedule_linesx  = t_schedule_linesx
              order_item_in    = t_item_in
              order_item_inx   = t_item_inx.
          WAIT UNTIL t_return[] IS NOT INITIAL.
          READ TABLE t_return INTO wa_return WITH KEY type = 'E'.
          IF sy-subrc <> 0.
          ELSE.
            r_return[] = t_return[].
            MESSAGE ID 'ZSD' TYPE 'E' NUMBER 613.
           RAISE errorinorderupdate.
          ENDIF.
          REFRESH t_schedule_linesx.
          REFRESH t_schedule_lines.
          REFRESH t_item_in.
          REFRESH t_item_inx.
          REFRESH t_return.
        ENDIF.
      ENDLOOP.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       IMPORTING
         return = t_bapiret.
    ENDFORM.                    "Change_Sales_Order

    see the following example and try to do this:
    i_hdrx-updateflag = 'U'.
    *" Fill required SCHEDULE_LINES data.
    i_sched-itm_number = p_posnr.
    i_sched-sched_line = p_etenr.
    i_sched-req_qty = p_reqqty.
    i_schedx-updateflag = 'U'.
    i_schedx-itm_number = p_posnr.
    i_schedx-sched_line = p_etenr.
    i_schedx-req_qty = 'X'.
    APPEND i_sched.
    APPEND i_schedx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_vbeln
    order_header_in = i_hdr
    order_header_inx = i_hdrx
    TABLES
    return = i_ret
    schedule_lines = i_sched
    schedule_linesx = i_schedx.

  • Is anybody else having a problem with Bluetooth functionality after iOS 7? I have lg tone Bluetooth headset that I use while working out, cutting the grass, etc. Before the update I could press the "next track", but anymore.... Help?! Please!!!!!!

    Is anybody else having a problem with Bluetooth functionality after iOS 7? I have lg tone Bluetooth headset that I use while working out, cutting the grass, etc. Before the update I could press the "next track", but anymore.... Help?! Please!!!!!!

    Tell Apple about it: http://www.apple.com/feedback/iphone.html
    Be sure to give as much detail as possible.
    I would also check LG's site.

  • Hello i have a problem with onfocus function on ipad. i am trying to bring my cursor on a text box on a button click. It works fine with safari web browser but not on ipad. Need a solution.

    Hello i have a problem with onfocus function on ipad. I am trying to bring my cursor on a text box on a button click. It works fine with safari web browser but not on ipad. Need a solution.

    I don't think that a software update from Apple will solve the issues that you are having. You have a rogue installation. After you posted I have just done the following:
    Disk Utility can verify  my partitioned Volume (including my boot disk) AND REPAIR the non-boot disks on the same Volume without a glitch. It repairs the non-boot disks containing data smoothly.
    I have used Mail to send some mails from some Yahoo and Hotmail accounts to my Thunderbird client containing GMail accounts - absolutely normal.
    I have iLife '09 but my iMovie '09 and iPhoto '09 open in a jiffy and I see no issues here. I have 6GB RAM (Maximum) on an early 2008 Macbook Pro with a 750GB hard drive partitioned with 120GB reserved for the Boot Drive.
    I am sorry that I cannot help further but I am sure there must be a way to reinstall the software without having to revert to restoring your ML backup. I have two clones and if you have such I would attempt to do that through that rather than through Time Machine - that is of course if you have a cloned drive.
    Good luck!

  • Problem with translate function (C++ parser v9)?

    When upgrading to v9 of the C++ parser, we notice a problem with the translate function within xsl stylesheets. Take the following snippet :-
    <StartDt><xsl:value-of select="translate(string(CheckInDate),'-','')"/></StartDt>
    Previously, this statement would strip the '-' chars from our input dates of the form 2002-05-02 to give 20020502. It now does not replace the '-' chars which causes our transformed output to be invalid. We have many developed and tested xsl's which now don't work.
    When we revert to v8, the same xsl's work correctly.
    This happens on all platforms (Windows/Linux/Solaris).
    Anyone else noticed this?
    Regards,
    Mike

    It worked for me as well.
    Use DUMP to find out the char code used for é and ú and try to replace these character codes.
    On my system it is 130 and 163
    SELECT TRANSLATE('héllú wúrld', 'éú', 'eu'),
           dump('héllú wúrld'),
           TRANSLATE('héllú wúrld', chr(130)||chr(163), 'eu')
    FROM   dual;
    hellu wurld
    Typ=96 Len=11: 104,130,108,108,163,32,119,163,114,108,100
    hellu wurld

  • Problem with a function of Dreamweaver Cs4

    Hi. Excuse me for my bad Inglish, but i am italian. I have a
    problem with Dreamweaver CS4. Before I have used the last version,
    CS3 and there were a function call image viewer (Insert >
    Multimedia objetcts > Image Viewer). In this new version, this
    function there is not. It's possible create the same effect with
    another function?
    Thank's

    The size of one line is 1024.
    if(bArray.length == 1023){
      out.write(bArray);       
      byte[] temp = new byte[1];       
      temp[0] = 100;       
      out.write(temp);     
    }else{       
      out.write(bArray);     
    In the 27 row the JCO trim the length of the line to 1023 bytes. The last byte is 100.
    And for this Problem I add the byte.
    Regards
    Thomas

  • Problems with the function RFC_GET_TABLE_ENTRIES

    Hi experts,
           We have a external application named P-Synch that is used when a user needs to change or unlock their password on our SAP system. The problem we are presenting is that in our PBP system the application is working fine but in our BW and XI environment when the P-Synch application call the function RFC_GET_TABLE_ENTRIES in SAP it can't take the result of the field 'expiration_date' because for some reason the output for this field is not in the same position that is in the PBP system.
    Example:
    This are the output that we receive in the environments with the function RFC_GET_TABLE_ENTRIES :
    PBP:
    000001ú320020401*99991231*AESSUSER
    BWP:
    0000200408039999*1231AESS*USER
    As you see in PBP P-Synch can take the expiration date (in bold) in the correct position '99991231'.... but for some reason in BWP the function present the expiration date in the incorrect position '1231AESS', for that reason the P-Synch application can't change or unlock the user of a person because terminate with error with the expiration date.
    Exist a way that I can fix this?
    Thanks a lot!
    Edited by: Carlos Mercado Aponte on Oct 16, 2009 3:42 PM

    Hello Carlos,
    Few days back i also faced some problem with the RFC_GET_TABLE_ENTRIES.
    May be you can try with RFC_READ_TABLE instead. Not much difference in the way you call the 2 FMs. From my experience i can tell, RFC_GET_TABLE_ENTRIES returns some garbage characters which RFC_READ_TABLE does not.
    For details refer to this [link|RFC_READ_TABLE v/s RFC_GET_TABLE_ENTRIES;.
    BR,
    Suhas

  • Problem with a function(reply me soon )

    hello
    i have some problem with following statement, please answer me , what will be the answer.
    Within the current application, a COBOL program calculates the annual allowable budget for each studio based on historical analysis.This value, stored in a COBOL variable , will be passed to your function as an argument. Which function will you create?
    1. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, :cobol_variable_budget IN NUMBER)
    RETURN number
    IS
    BEGIN
    UPDATE studio
    SET yearly_budget = :cobol_variable_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    2. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, :cobol_variable_budget IN NUMBER)
    RETURN number
    IS
    v_new_budget NUMBER := :cobol_variable_budget;
    BEGIN
    UPDATE studio
    SET yearly_budget = v_new_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    3. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, v_new_budget IN NUMBER := :cobol_variable_budget)
    RETURN number
    IS
    BEGIN
    UPDATE studio
    SET yearly_budget = v_new_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    reply me soon thanx

    If you correctly copied the proposed functions from your homework, then you really need to get a new teacher.
    First, none of the functions are syntactically correct. You cannot use bind variable (i.e. :variable_name) in the way they are used in these functions.
    Second, even removing the colons, which does allow the functions to compile, and passing values to the functions results in:
    ERROR at line 1:
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "OPS$ORACLE.SET_BUDGET", line 6
    Third, even if you could do the update in a function, the function will always return 0. The COMMIT sets SQL%ROWCOUNT to 0. If you want to use the value, you need to get it immediately after the statement, before doing anything else.
    The accepted way of doing DML on objects is through PROCEDURES.
    You need something like:
    CREATE OR REPLACE PROCEDURE set_budget
    (v_studio_id IN NUMBER, cobol_variable_budget IN NUMBER, rowcount OUT NUMBER)
    IS
    BEGIN
       UPDATE studio
       SET yearly_budget = cobol_variable_budget
       WHERE id = v_studio_id;
       rowcount := SQL%ROWCOUNT;
       COMMIT;
    END;
    To call this from sqlplus, you would need to
    1. Create the output variable rowcount by
       VARIABLE rowcount NUMBER;
    2. Then call the function with appropriate parameters
       exec set_budget(1,100,:rowcount);
       Note the use of a bind variable for the OUT parameter[b]To call this through a COBOL program would be similar, except that you would probably use the COBOL variables for all three parameters. The OUT parameter would still have to be passed as a bind variable.
    John

  • Having problem with to_lob function

    Hi,
    Oracle DB version: 10.2.0.1.0
    Tools being used: SQL Developer and SQLPlus (I have tried the query on both)
    Create table test
    col_xml LONG
    ...Note: We cannot convert this column to CLOB permanently because we just don't have the right to do that. :-(
    Now, the problem is, I'm trying to convert this LONG into a CLOB using the TO_LOB function but still getting this error:
    select TO_LOB(col_xml) from test;
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got LONGBy the way, our main goal is to query this column so that we could filter the rows that we need.
    Sort of:
    select TO_LOB(col_xml) from test where TO_LOB(col_xml) like '%criteria%';Have I missed something or any idea on how to make my goal possible. The TO_LOB function is pretty simple but I don't know why it doesn't work in our my environment.
    Suggestion/Ideas/Links to learning materials is high appreciated (Prefer oracle sites, message boards and forums are blocked by the firewall :-( ).
    Thanks.

    Spongebob wrote:
    Follow up question: This TO_LOB function looks simple and easy to use but as shown above in my post it throws an error message. Have I missed something or is there something in our environment that affected the behavior of this function?Have a look at Oracle® Database SQL Language Reference.
    There are several limitations with this function. It boils down to the following:
    "<i>Before using this function, you must create a LOB column to receive the converted LONG values. To convert LONG values, create a CLOB column. To convert LONG RAW values, create a BLOB column.</i>"
    So in other words, this function needs a destination LOB to write the LONG content into. It does not dynamically create the destination LOB/CLOB.
    So you cannot do this as there is no explicit LOB definition to receive the converted LONG content:
    SQL> select TO_LOB(text) from all_views where owner = 'SYSTEM' and view_name = 'PRODUCT_PRIVS';
    select TO_LOB(text) from all_views where owner = 'SYSTEM' and view_name = 'PRODUCT_PRIVS'
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got LONGBut if we create a destination LOB, we can use the function. E.g.
    SQL> create table view_text( view_name varchar2(30), view_sql clob );
    Table created.
    SQL> insert into view_text select view_name, TO_LOB(text) from all_views where owner = 'SYSTEM' and view_name = 'PRODUCT_PRIVS';
    1 row created.
    SQL> The bottom line to this is: LONG IS AN EVIL DATA TYPE.
    It should not be used. It dates back to Oracle 7. We are now at 11g. Several versions later. Still using the LONG data type in applications should be dealt with swiftly and harshly using the old lead pipe. Even a legacy app would have undergone several updates since Oracle v7. And that would have provided ample opportunity to convert from the horrible LONG data type to LOB.

  • Problem with externalURL function over sandboxbridge

    I have a simple application that I am running , I have run items through the sandbox bridge without any issue until I try to run the openExternalURL command, that one will not run, I am posting my client and the page here in hopes that someone might have come across this and have a fix for it , I am pretty sure that the fix is simple and that I am probably overlooking something small with this one LOL .
    If I call any of the other functions they work like a charm but if I call openExternalURL , it won't work so I am pretty sure the problem is the function openExternalURL
    Any ideas would be helpfull
    -R
    **************AIR CLIENT*********************************************************************
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="AIRAliases.js"></script>
    <script language="javascript">
    function openExternalURL(href) {
    var request = new air.URLRequest(href);
    try {           
    air.navigateToURL(request);
    catch (e) {
    function testFunction(T){
    alert(T);
    function getUrlVars(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    hash = hashes[i].split('=');
    vars.push(hash[0]);
    vars[hash[0]] = hash[1];
    return vars;
    function noLogin(){
    alert('Your login information was incorrect, please try again');
    top.location.href="login.html";
    var Exposed = new Object();
    Exposed.openExternalURL = openExternalURL;
    Exposed.getUrlVars = getUrlVars;
    Exposed.noLogin = noLogin;
    Exposed.testFunction = testFunction;
    function doLoad() {
    var frame = document.getElementById('viperframe').contentWindow.parentSandboxBridge = Exposed;
    setIframeHeight('viperframe');
            </script>
    </head>
    <body onload="doLoad();" onresize="setIframeHeight('viperframe');" onfocus="setIframeHeight('viperframe');" bgcolor="#222222">
    <iframe src="processlogin.html" id="viperframe" name="viperframe" frameborder="0" scrolling="no" width="100%"></iframe>
    </body>
    </html>
    ********************************END AIR CLIENT*********************************************
    *******************************PAGE CALLING FUNCTION**********************************
    <script language="javascript">
         parentSandboxBridge.openExternalURL('http://www.google.com')
    </script>
    ****************************END PAGE CALLING FUNCTION********************************

    Hi
    Could not find exact FM for your requirement but I have one logic which I also used for similar rquirement
    Table MCHB contain the batch and 'clabs' is the field for quantity,
    Just write your own logic and get the desired result.
    Hope this helps.
    Regards
    Bikas

Maybe you are looking for

  • How can i change the length of a line like-particle in Particle World settings?

    I made a Particle World with the Line type of particles, but i want to change the individual length of the particles (the lines) is this possible somehow? Thanks in regard. 

  • Oracle Text  - Help needed

    Hi, I am using Oracle Text 9.2 on Oracle databas version 9.2. I want to search for two words, which should be next to each other. For ex. select col1, col2 from tab1 where contains (col2, 'personal computer') > 0; I don't want those rows, which have

  • Target  Filename generation - receiver proxy.

    Hi, I need to create target filename same as source filename. When receiver communication channel is proxy. Communication channel. Thanks, Venu.

  • Could not complete import command.

    Hello, I get an error message that says "Could not complete import command because of a problem with the acquistion interface." I've commented out all of my code and even the code inside of the main entry point and still get this error. What causes t

  • Can you still sort songs by popularity, name, etc.

    Can you still sort songs by popularity, name, etc.? It does not appear as thought these options are still available. Message was edited by: DrDanCDman