output is not appropriately when using if condition?

Hi all

CREATE TABLE TEST_CASE

AS

Select *.

de)

Select the amount 0.1 double

Union of all the

Select double 0

Union of all the

Select double 0

Union of all the

Select - 1.22 double

Union of all the

Select - 7.12 of double

);

DECLARE

CURSOR c1

IS

SELECT * FROM TEST_CASE;

v_acc_1 VARCHAR2 (1000);

v_acc_2 VARCHAR2 (1000);

BEGIN

Dbms_output.put_line (' there are 1' |) '  , ' || " Account 2 ");

C_rec IN C1

LOOP

v_acc_1: = NULL;

v_acc_2: = NULL;

IF c_rec.amount < 0

THEN

v_acc_1: = v_acc_1 | LPAD (NVL (TO_CHAR (c_rec.amount), ' '), 17);

ON THE OTHER

v_acc_2: = v_acc_2 | LPAD (NVL (TO_CHAR (c_rec.amount), ' '), 12);

END IF;

Dbms_output.put_line (v_acc_1 |) '   ,  ' || v_acc_2);

END LOOP;

END;

Account_1, Account_2    

,            .1

,             0

,             0

-1.22,

-7.12,

PL/SQL procedure successfully completed.

If remove the If condition then it will be fine

Thank you

Post edited by: Rajesh123 corrected table_name

you could also create the entire string first and output that:

DECLARE
  CURSOR c1 IS
    SELECT CASE WHEN amount < 0 THEN amount ELSE NULL END AS amount_1
        , CASE WHEN NOT amount < 0 THEN amount ELSE NULL END AS amount_2
      FROM (SELECT 0.1 amount
              FROM DUAL
            UNION ALL
            SELECT 0
              FROM DUAL
            UNION ALL
            SELECT 0
              FROM DUAL
            UNION ALL
            SELECT -1.22
              FROM DUAL
            UNION ALL
            SELECT -7.12
              FROM DUAL);

  result  VARCHAR2( 4000 );
BEGIN
  result      :=
      result
    || 'Account  1  '
    || '  , '
    || '    Account  2  ';

  FOR c_rec IN c1 LOOP
    result      :=
        result
      || '
'; -- important linebreak
    result      :=
        result
      || LPAD( NVL( TO_CHAR( c_rec.amount_1 ), ' ' )
            , 17
              )
      || '  ,  '
      || LPAD( NVL( TO_CHAR( c_rec.amount_2 ), ' ' )
            , 12
              );
  END LOOP;

  DBMS_OUTPUT.put_line( result );
END;

Good bye

DPT

Tags: Database

Similar Questions

  • Change in 2013 Excel formatting Options are not visible when using high Windows - why contrast themes?

    I am currently using the theme of white high contrast Win 7.  However, in Excel 2013, many formatting options do NOT work, when using this theme:

    1. Fill color
    2. Font color
    3. Conditional formatting
    4. Colors tab

    To reproduce this problem, using Excel 2013 with a Windows high-contrast theme, whatever we have to do is:

    1. Select a cell and try to change the fill color.  It does not work.
    2. Type the text in the cell, and then try to change the color of the font.  It does not work.
    3. To implement conditional formatting for this cell.  It does not work.
    4. Try changing the color of the tab the active tab at the bottom of the worksheet.  It does not work.

    It would seem that, if the high contrast themes have been made to ease of use for those who have poor vision, whereas they should be able to change the options in shape in Excel to make things more visible within their own documents.

    I understand very well that changes in the end formatting options will appear if the user switches to another theme of Windows, but who certainly defeated the purpose of using a theme of contrast in the first place.  Why should they play this user switch to a different theme of Windows just to see the changes he made, using the Windows high contrast theme?  Why the user does NOT agree to see the changes that he or she has filed in formatting options in Excel 2013, when you use a high-contrast theme?

    The user with special vision must assets concerns of colors.  Excel will meet your needs for a higher contrast (black and white pure) at all costs in order to ensure the highest possible contrast.

    Microsoft do not escalate this, it works as expected.

    I don't think you are right to say that this is normal.  When you use OneNote in high contrast black it allows indeed to the colors of different fonts, it is just an oversight or a bug of Microsoft on not supporting the themes of their office software.

  • Serial number not accepted when using disc to download on the second computer.

    Serial number not accepted when using download ot CS6 drive to the second computer. Help...

    Make sure that you enter the correct serial number to the correct product: http://helpx.adobe.com/x-productkb/global/find-serial-number.html

    If you are sure that you do this, contact support adobe technique: http://www.adobe.com/support/chat/ivrchat.html

  • receive ' make order not aviaible when using actions)?

    When using my actions of sky, I receive the order does not make available anyone can help please?

    This type of error occurs when a condition sine qua non of the action about to be executed step is not met. For example, a layer or another object may be selected where this step will be performed. Knowing what stage this error occurs on we will tell more about what should be done. The solution might be to perform an extra step (for example, you need to have created a selection before performing the action). This step may be a prerequisite to the implementation of the action or an additional step that can be added to the action to prove this error to appear.

  • Outlook has started to get a connection not approved when using firefox

    Outlook started having no reliable connection error when using firefox. Not sure why it started, but all the few minutes that it times out and I have to re - open outlook from google. He does not receive this error on IE or firefox android. I use win 7. I talked with microsoft and they say it's a problem of firefox not outlook.

    I tried the things:
    -Updated firefox
    -Updated antivirus
    -antivirus scans
    -disable the anti-virus
    -from firefox in safe mode.
    -clear all the cache and history
    -Disable all add-ons
    -system restore
    -past by mistake "untrusted connection" on the help of mozilla (does not solve it. There is no option to allow the certificate)
    -search on the net for a similar problem (found nothing)

    So far, it has been like this for a week and its starting to piss me off as it happened out of the blue.

    I solved the problem for someone else who has the same problem.

    Options - troubleshooting information - reset firefox

  • Google results is not accurate when using Firefox

    After that I installed Chrome, when I used the search on Google with Firefox, the results have been distorted. For example, when I searched for Netflix using google on Firefox, the home page does not appear. When I used google on Chrome or IE, Netflix home page would then appear as always. The results were the same, using any keyword, like Yahoo, Ebay, etc. Is there a reason for the change of the algorithm when using google and Firefox?

    You seem to be signed in to Google, so it is possible that Google stores your search history and offers you "customized" links.

    Is there a difference in when you're not connected?

    So, you can check the parameters of Google to see if web history is enabled (click on the gear icon in the form on the page of Google results).

  • Satellite A660 - Webcam does not work when using Skype

    I recently bought a Satellite A660-15J. I am running Windows 7 64 bit.

    I have the latest version of Skype (5.3.0.111).

    The integrated Webcam does not work when you run Skype. If I run the Toshiba Web Camera Application the webcam works fine. However, when I test it in Skype, I get a message saying "cannot start video. Try quitting other programs that use the webcam '.

    However, as far as I can tell there no other programs available. I have tried Skype with the Web Camera Application clised & open. I also confirmed that I do run the latest version of the program.

    One of the main reasons we have this laptop is to use Skype video... Help, please.

    Disable webcam application start-up and exit this application before you start Skype.

    I used Skype many different models of laptops, including friends A660 and it worked correctly.

    When you open Skype video settings is listed as default camera USB webcam?

  • Invoke the activity do not dehydrate when using retry policy fault

    When the political use of fault with retry behavior, invoke activities are not being dehydrated properly (even if we use idempotent = false on the functioning of partnerlink).

    This poses a problem if the process is in "canceled at the last point of dehydration" - given that dehydration doesn't is not made.

    If the Invoke is successful on the first invoke (do not have to use the strategy of fault and retry behavior), he's dehydrated properly, and if the process at a later stage makes a point of dehydration cancellation exist properly.

    So it seems to be linked to the fault policy and other code running, or perhaps some properties have not been set properly (__Non-db-persist?).

    No idea how to solve this problem?

    We use SOA Suite 11.1.1.7

    According to Oracle support, political fault retry and with idempotent = false are not compatible.

  • Hyperlink window not Visible when using anchor

    Hello community, for some reason my window for a hyperlink became inactive when using anchors. I had some problems of Muse today and did a re-install Adobe Muse CC.jpg without success. Any ideas?

    George

    Hi George,.

    The hyperlink menu appears only after you select an object that can be a hyperlink. If you have selected the object anchor, hyperlink option, it will go away because it is not a hyperlink. If you click on a button, object shape, picture, or text, the hyperlink option should appear on the right.

    I hope this helps!

    Emily

  • JavaFX 2.2 initialize is not called when using ControllerFactory

    Is there a reason why the initialize method is not called when specifying a controller factory (by calling FXMLLoader #setControllerFactory) instead of an instance of a controller (via FXMLLoader #setControllerFactory)? By the "initialize" method, I mean one of the following:
    public void initialize()
    @FXML private void initialize()
    @Override public void initialize(URL, ResourceBundle) /*as defined in the Initializable*/
    Published by: 951674 on August 8, 2012 12:27

    First of all, I'm not using the static version of the load method. I call class #getResourceAsStream not the #getResource class.

    Well Yes, you are right. I read it too fast. See? Source of confusion. ;-)

    But just to repeat what said Tom - Yes, fx:controller is always necessary, even if you specify a controller factory. The type specified by the fx:controller attribute is the type that is passed to the factory. If you do not specify a type of controller, then the plant is not called.

  • label of an element is not hidden when using $f_Hide_On_Value_Item

    Hi friends,

    I use the apex javascript '$f_Hide_On_Value_Item' function to hide an element of text field 'P72_T1' when the value of P72_S1 is I_VAL1. I put the line in the form of P72_S1 HTML element attribute.

    OnChange = "$f_Hide_On_Value_Item (This, 'P72_T1', 'I_VAL1')". "

    But only the textfield assosiated with this item (P72_T1) hides when you select the value "I_CAL1". Label the assosiated with this text field is still visible.

    I am able to hide the label when you use the script

    OnChange = "$f_Hide_On_Value_Item_Row (This, 'P72_T1', 'I_VAL1')". " But as there is more than one item in the same line I am not able to use it. Please help me solve this problem.

    Kind regards
    TJ

    Published by: tj2010 on 06-Sep-2010 03:43

    Hello

    It should work with IE8 and FF 3.6
    I do not guarantee that it works.

    function Hide_Item_and_Label_By_Value(t,p,v){
     var j=document.wwv_flow.getElementsByTagName('label').length;
     for(var i=0;i;if($x(p).id==l.getAttribute('htmlFor')||$x(p).id==l.getAttribute('for')){break;}}if($v(t)==v){$x_Hide(p);$x_Hide(l);return true;}else{$x_Show(p);$x_Show(l);return false;}}
    
    
    Probably I did invent wheel again, but learn something =) 
    
    Regards,
    Jari                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    
  • computer Dell laptop will not work when using battery

    Original title: my pc dell 1564 model. Act when I remove the battery (with adapter only), but when I fix the battery, it is not turn on

    my pc dell 1564 model. Act when I remove the battery (with adapter only), but when I fix the battery, it is not turn on

    Hello

    It is best to get the laptop battery checked from Dell or a local technician. It seems that the battery is dead and does not load when you insert it into the laptop.

    However, you can try to update all drivers installed on the laptop (including the motherboard) and check if it makes a difference.

    http://Windows.Microsoft.com/en-in/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    Navigate through the common troubleshooting steps of http://www.dell.com/support/troubleshooting/us/en/04/KCS/KcsArticles/ArticleView?c=us&l=en&s=bsd&docid=266588

    http://FTP.Dell.com/DIAGS/R66243.htm

    Hope this information helps. If you have any questions, please let us know.

  • Digital output is not 5V when connected to a circuit

    I have a very simple circuit I want to operate a valve. I have a NI USB 6008 with 12 digital i/o ports, a KF0602D solid state relay, 12V power and a solenoid valve.

    The idea behind this circuit is pretty simple: use a digital line of the 6008 to close or open the switch in the KF0602D. With the switch closed, current flows from the power supply through the switch, to the valve and that opens. When the switch opens no current flow and the valve closes.

    When I plug my 6008 in the KF0602D, however, my 'high' digital output falls from 5V to 1.73V. It's a problem because my switch requires at least 3V to close. I don't know why the voltage decreases because the relay is supposed to just on 3mA current with an input 5V, wells in the area of the specs listed 6008. What can I do to make this work?

    Outputs digital USB-6008 are drain opened with pull-up 4.7 kohm resistors. This will NOT lead your SSR entry requiring > 2 my.

    He must reverse the polarity of your control signal. Wire-entrance of the Republic socialist Soviet to the line of the 6008.  Wire the + input of the Republic socialist Soviet to + 5 V. Then you have the 8.5 my driving ability to do what you want.

    Lynn

  • Satellite Pro U200: VGA output works not properly when the AC adapter / CC has been connected

    Hello

    I have a problem with vga output. When I'm working on the battery and connect my laptop to external monitor is ok, but when I connect adapter then start waving also bluetooth and wlan is not working properly. In other cases when I disconnect laptop battery and connect the AC adapter it works correctly.

    Thanks in advance

    Hello

    Can you please describe more precisely what is happening here? Does not properly is a rather general statement.

  • REF InsertedVI of high school still not valid when using VI Server

    I'm trying to access subpanel controls (in an executable file) via the server of VI, but he doesn't seem to be allowing me to get a valid reference to the inserted VI (1026: VI reference is invalid).  If I use the same code in the executable itself, it works fine.

    The executable file and the VI that I use to try to get a reference to the Secondary VI is attached.

    Any ideas why this happens?

    OK, I see the problem, VI references are local to the instance of LabVIEW that generate them. When you read the VI reference, you get the correct numeric value (as evidenced by the fact that it is zero). However, in the development environment from which you access the executable, the reference is not valid. This reference is only valid in the environment of the executable. What you need to do in the executable is to get the name of the VI in high school, when you insert it and store that name in a FGV. Then from your remote application, read this FGV - and you will have the name of VI.

    Mike...

Maybe you are looking for

  • Firefox will not print on my HP PSC 750 printer and loses all formatting when you try to print to the printer Brother HL-5240

    I have no problem with one of my printers when printing 11.7 before or IE 6.0.2800.1106 but cannot print from Firefox 3.6.13 (or earlier).When you try to print to the HP PSC 750 inkjet printer, a "Print" dialog box appears, showing the title: xyz and

  • G42-250BR: laptop enter your administrator password or power on password

    (1) HP G42-250BR(2) Windows 7(3) enter the password Admin password or power.(4) no modification, just update as usual.(5) no updated BIOS.Disable the system is [68813330] Need help please Thank you Fernando

  • OfficeJet 6812: I get a print head error message

    I get the error message "problem with printhead. I tried all of the suggestions I found on the forum and am unable to solve the problem. I spoke with a representative chat, and she asked if he was allowed to have a technician call me. I said ok and g

  • Email listening to BB10

    Hello This forum is very useful for me. Can someone tell me if we can send and receive emails using the BB10 API as well can we have any API that helps us to listen to incoming emails? Thank you and best regards, Shubhangi

  • 8900 special edition upgrades

    Just buy the 8900 special edition with tuberculosis and SSD hard drives. I would like to upgrade the GPU GTX 960 to the 970.  Even if the plug indicates 460W power would work, all other sources, including the NVIDIA said less a Psalm of 500W my quest