PL/SQL :: Problem With Large Number Computation.

Greetings Experts,
I am relatively new to Oracle-DB. And I have a question regarding PL/SQL. I was trying to find the factorial of a number 100 as this is the most common programming problem for the beginners. But when I tried to execute the same, I was getting weird result(~) instead of actual value, i. e. 100!. I would highly appreciate if you experts can guide me in this regard. I have posted the program herewith for your reference.
SQL> DECLARE
2 X NUMBER := 100;
3 INDX NUMBER := 1;
4 BEGIN
5 INDX := X;
6 WHILE X > 1
7 LOOP
8 X := X - 1;
9 INDX := INDX * X;
10 END LOOP;
11 DBMS_OUTPUT.PUT_LINE('The Factorial of 100 is : '
12 || INDX || '.');
13 EXCEPTION
14 WHEN OTHERS THEN
15 RAISE_APPLICATION_ERROR(-20156,SUBSTR(SQLERRM,1,500));
16 END;
17 /
The Factorial of 100 is : ~.
PL/SQL procedure successfully completed.
TIA.
Hex.

This is PL/SQL and works up to 1463:
SQL> CREATE OR REPLACE FUNCTION factorial(
  2     pNumber   IN   NUMBER)
  3     RETURN VARCHAR2
  4  IS
  5     f   VARCHAR2(32767);
  6
  7     FUNCTION multiply(
  8        pX   IN   VARCHAR2,
  9        pY   IN   VARCHAR2)
10        RETURN VARCHAR2
11     IS
12        xManLength   PLS_INTEGER;
13        yManLength   PLS_INTEGER;
14     BEGIN
15        xManLength := LENGTH(RTRIM(pX, '0'));
16        yManLength := LENGTH(RTRIM(pY, '0'));
17        RETURN    TO_CHAR(TO_NUMBER(SUBSTR(pX, 1, xManLength)) * TO_NUMBER(SUBSTR(pY, 1, yManLength)))
18               || RPAD('0', LENGTH(pX) - xManLength + LENGTH(pY) - yManLength, '0');
19     END multiply;
20  BEGIN
21     f := 1;
22
23     FOR n IN 1 .. pNumber LOOP
24        f := multiply(f, n);
25     END LOOP;
26
27     RETURN f;
28  END factorial;
29  /
Funktion wurde erstellt.
SQL>
SQL> SELECT 1463, factorial(1463) AS fact
  2    FROM DUAL;
      1463
FACT
      1463
229804713272032214845417447319796313384000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000

Similar Messages

  • VAT Reconciliation Problem with large number of transactions

    Hi
    We are experiencing problem when it comes to doing a Manual Internal Reconciliation for the VAT G/L account.
    We have about 10,000 Output VAT transactions per month. So when we do a manual reconciliation for all these 10,000 credit entries against one debit entry SAP B1 resulted in "Out of Memory Error" or "Internal Error".
    We are currently on SAP B1 2007A PL49.
    The client system spec is Intel Core 2 Duo T7300 2.0GHZ with 2GB memory.
    Has any one come across the same issue before? Or SAP B1 cannot handle 10,000 transactions reconciliation due to limit in application?
    BR,
    Jimmy

    For this kind of volume, you may have to do reconciliation more often to avoid error messages.  I don't think this is application error but the limitation of all resources.
    Thanks,
    Gordon

  • Hello, i have a problem with this number code  213:19,  please help me!

    Hello, i have a problem with this number code  213:19,  please help me!

    dan
    What version of Premiere Elements and on what computer operating system is it running?
    If you are using Premiere Elements 13, have you updated it to 13.1 yet? If not, please do so using an opened project's Help Menu/Updates.
    What type of user account are you using....local administrator or domain type?
    Please review the following Adobe document on the 213.19 issue. Have you read that already?
    Error 213:19 | Problem has occurred with the licensing of this product
    ATR

  • Lookups with large number of records do not return the page

    Hi,
    I am developing an application using Oracle JHeadstart 10.1.3 Preview Version 10.1.3.0.78
    In my application I created a lookup under domains and used that lookup for an attribute (Display Type for this attribute is: dropDownList) in a group to get the translation fro this attribute. The group has around 14,800 records and the lookup has around 7,400 records.
    When I try to open this group (Tab), the progress shows that it is progressing but it does not open even after a long time.
    If I change the Display Type for the attribute from dropDownList to textInput then it works fine.
    I have other lookups with lower number of records. Those lookups work fine with dropDownList Display Type.
    Only I have this kind of problem when I have a lookup with large number of records.
    Is there any limitation of record number for lookups under Domains?
    How I can solve this?
    I need to translate the attribute (get the description from another table using the code).
    Your help would be appreciated.
    Thanks
    Syed

    We have also faced similar issue, but us, it was happening when we were using the dropDownList in a table, while the same dropDownList was working in table format. In our case the JVM is just used to crash and after google'ing it here in forums, found that it might be related to some JVM issue on Windows XP machines without Service Pack 2.
    Anyway... the workaround that we taken to get around the issue is to use LOV instead of a dropDownList in your jHeadStart.
    Hope this helps...
    - rutwik

  • Out.println() problems with large amount of data in jsp page

    I have this kind of code in my jsp page:
    out.clearBuffer();
    out.println(myText); // size of myText is about 300 kbThe problem is that I manage to print the whole text only sometimes. Very often happens such that the receiving page gets only the first 40 kb and then the printing stops.
    I have made such tests that I split the myText to smaller parts and out.print() them one by one:
    Vector texts = splitTextToSmallerParts(myText);
    for(int i = 0; i < texts.size(); i++) {
      out.print(text.get(i));
      out.flush();
    }This produces the same kind of result. Sometimes all parts are printed but mostly only the first parts.
    I have tried to increase the buffer size but neither that makes the printing reliable. Also I have tried with autoFlush="false" so that I flush before the buffer size gets overflowed; again same result, sometimes works sometimes don't.
    Originally I use such a system where Visual Basic in Excel calls a jsp page. However, I don't think that this matters since the same problems occur if I use a browser.
    If anyone knows something about problems with large jsp pages, I would appreciate that.

    Well, there are many ways you could do this, but it depends on what you are looking for.
    For instance, generating an Excel Spreadsheet could be quite easy:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class TableTest extends HttpServlet{
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
              response.setContentType("application/xls");
              PrintWriter out = new PrintWriter(response.getOutputStream());
                    out.println("Col1\tCol2\tCol3\tCol4");
                    out.println("1\t2\t3\t4");
                    out.println("3\t1\t5\t7");
                    out.println("2\t9\t3\t3");
              out.flush();
              out.close();
    }Just try this simple code, it works just fine... I used the same approach to generate a report of 30000 rows and 40 cols (more or less 5MB), so it should do the job for you.
    Regards

  • Trace file in bdump (SQL ID with large Version Count encountered.)

    Hi, all.
    I found tons of this trace file in one of my oracle servers. What does this mean? did anyone ever see this? How to solve it?
    Thanks.
    *** ACTION NAME:(Auto-Flush Slave Action) 2009-01-28 18:00:10.985
    *** MODULE NAME:(MMON_SLAVE) 2009-01-28 18:00:10.985
    *** SERVICE NAME:(SYS$BACKGROUND) 2009-01-28 18:00:10.985
    *** SESSION ID:(84.5246) 2009-01-28 18:00:10.985
    SQL ID with large Version Count encountered.
    SQL Id: b221muwskhm6
    Version Count: 299, Parse Calls: 12, Shareable Mem: 11907351
    Elapsed Time: 0, CPU Time: 0, Executions: 0
    Disk reads: 0, Buffer Gets: 0, I/O Wait Class: 0
    Application WC: 0, Concurrency WC: 0, Cluster WC: 0

    Refer Oracle Support note 4632024.8

  • Cannot contact the Adobe Service, I have a problem with the number.

    Hi,
    I would like to have more information in regard of the Adobe DC. My intent is to buy the product and use it in my office, we are a small company (4 PC).
    If I'm not wrong I should take the Standard Plan for Business, but I cannot arrange any payment request for information because I have a problem with the number I am supposed to call.
    Is there any other way to know if this software suit fine for me and my company, and most of all how much it will cost.
    Thank you for your consideration.
    Have a nice day!
    I look forward to hearing from you.
    Best,
    Augusto

    Hi Avgvstvs67,
    Please refer this link : https://acrobat.adobe.com/in/en/pricing/business-pricing.html
    Regards,
    Rahul

  • I Just upgraded to mountain lion os x to 10.8.1 and I have a problem with restart my computer

    I Just upgraded to mountain lion os x to 10.8.1 and I have a problem with restart my computer.
    Now my computer is stuk on restart and wont turn on.
    Can somone help me with it?
    Thanks.

    If Mende 1's suggestion doesn't solve it you might find the following useful:
    I would first reset the SMC:
    Shut down and unplug the Mac.
    Keep the Mac unplugged for at least fifteen seconds.
    Plug the Mac back in and do not turn it back on for at least five seconds.
    Press the power button to turn the Mac back on.
    Then I would reset the PRAM by rebooting the iMac while simultaneously holding the Command-Option-P-R keys until the machine restarts a second time.
    Hope this helps

  • Problems with large scanned images

    I have been giving Aperture another try since 1.1 came out, and I am still having problems with large tiff files derived from scanned 4x5 negatives. The files are 500mb or more, 16 bit RGB, with ProPhoto RGB or Ektaspace PS5 profiles, directly out of the scanner.
    Aperture imports the files correctly, and shows their thumbnails. When I select a thumbnail "Loading" is displayed briefly, and the the dreaded "Unsupported Image Format" is displayed. Sometimes "Loading" goes on for a while, and a geometric pattern (looking like a rendering of random memory) is displayed. Restarting Aperture doesn't help.
    Lower resolution (250mb, 16bit) files are handled properly. The scans are from an Epson 4870 scanner. I have tried pulling the scans into Photoshop and resaving with various tiff options, and as PSD with no improvement. I have the same problem with corrected/modified psd files coming out of Photoshop CS2.
    I am running on a Power Mac G5 dual 2ghz with 8gb of RAM and an NVIDIA GeForce 6800 GT DDL (250mb) video card, with all the latest OS and software updates.
    Has anyone else had similar problems? More importantly, is anyone else able to work with 500mb files of any kind? Is it my system, or is it the software? I sent feedback to Apple as well.
    dual g5 2ghz   Mac OS X (10.4.6)  

    I have a few (well actually about 100) scans on my system of >500Mb. I tried loading a few and am getting an inconsistent pattern of errors that correlates with what you are reporting.
    I imported 4 files and three were troubled, the fouth was OK. I imported another four files and the first one was OK and the three others had your reported error, also the previously good file from the first import was now showing the same 'unsupported' image' message.
    I would venture to say that if you shoot primarily 4x5 and work with scans of this size that Aperture is not the program for you--right now. I shoot 35mm and have a few images that I have scanned at 8000dpi on my Imacon 848 but most of my files are in the more reasonable 250Mb range (35mm @ 5000dpi).
    I will probably downsample my 8000dpi scans to 5000dpi and not worry to much about it. In a world where people believe that 16 megapixels is hi-res you are obviously on the extreme side.(Good for you!) You should definately file a bug report but I wouldn't expect much help anytime soon for your super-sized scans.

  • How to Capture a Table with large number of Rows in Web UI Test?

    HI,
    Is there any possibility to capture a DOM Tabe with large number of Rows (say more than 100) in Web UI Test?
    Or is there any bug?

    Hi,
    You can try following code to capture the table values.
    To store the table values in CSV :
    *web.table( xpath_of_table ).exportToCSVFile("D:\exporttable.csv", true);*
    TO store the table values in a string:
    *String tblValues=web.table( xpath_of_table ).exportToCSVString();*
    info(tblValues);
    Thanks
    -POPS

  • I am having problems with my old computer so syncyed my ipod to my new computer. all the appliance/games synched but not my music. I have somehow manged to wipe all my music from my ipod and it will not synch with my music libary from my old computer

    Hi
    I am having problems with my old computer so syncyed my ipod to my new computer. all the appliance/games synched but not my music. I have somehow manged to wipe all my music from my ipod and it will not synch with my music libary from my old computer. Any suggestions.

    ? Anyone have any suggestions?

  • Problem with user number

    Goodmorning, I have a problem with user number of my smartphone Blackberry Curve 8900: when I call a numer of my adress book, on the right,  appears a user number, that I don't know. Why dont'appears mine? I don't have buy this smartphone personally, but I had it (used) through the smartphone's owner...I think that the user number that appears on my display is his. How I can do to remove it?
    Waiting for an answer, thank you.

    Hello scricciolina90
    Welcome To Support Forums
    On or Curve 8900 from the Home screen > click Options > Click Advanced Settings > SIM Card > Highlight the phone number > Press the Menu key and click Edit SIM Phone Number > Check that field or Enter you Mobile number in that field .
    Good luck.
    Click " Like " if you want to Thank someone.
    If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.

  • RESOLVED - K8N Neo2 Platinum problem with large Seagate disk

    Hi All,
    I've been running this system for 4 years and I'm very happy with it. But I've run into a problem:
    I'm trying to exchange my 120 GB Seagate Barracuda systemdisk with a 500 GB Barracuda and I can't install XP with SP2.
    First I tried to clone the old HD with Norton Ghost and Acronis True Image. The cloning looked fine but after taking the old HD out and moving the new one to P-ATA 1 as Primary Master I get an "error - no operating system found". I also tried a fresh install from CD. After the CD reboots the system I get the same error.
    The HD is present in BIOS with the right parameters and all is looking well - but still no go.
    I've fiddled around in BIOS (vers. 1.3) with the different settings (LBA, Large, Auto, Csh.) The last 2 options gives the "no operating system" error and the first 2 gives a "disk error" although Seagate says that I should change settings to "LBA".
    I only have the new HD in the machine. I also tried fixboot and fixmbr. I can see all the installed files when I put it in as a slave.
    So my question is:
    Does the K8N Neo2 Platinum have a problem with large hd's as system disk?
    Or is this a Seagate or Windows problem ?
    Any help is much appreciated!
    Mads

    Actually that was the first thing I did just to see if the drive worked :-) - except that I had it as master on the second ide cable. It formats like it should and all partitions report "healthy". The only difference is that the new drives c-partition is set as active (can't find a way to change it back)  - while the old one is set as system. Could this make a difference ?
    Since neither cloning nor a fresh install works I think the problem is something else. Maybe I should try Seatools and see if that makes any difference.
    Thank's all for help so far! - Other suggestions ?

  • Problem with  large databases.

    Lightroom doesn't seem to like large databases.
    I am playing catch-up using Lightroom to enter keywords to all my past photos. I have about 150K photos spread over four drives.
    Even placing a separate database on each hard drive is causing problems.
    The program crashes when importing large numbers of photos from several folders. (I do not ask it to render previews.) If I relaunch the program, and try the import again, Lightroom adds about 500 more photos and then crashes, or freezes again.
    I may have to go back and import them one folder at a time, or use iView instead.
    This is a deal-breaker for me.
    I also note that it takes several minutes after opening a databese before the HD activity light stops flashing.
    I am using XP on a dual core machine with, 3Gigs of RAM
    Anyone else finding this?
    What is you work-around?

    Christopher,
    True, but given the number of posts where users have had similar problems ingesting images into LR--where LR runs without crashes and further trouble once the images are in--the probative evidence points to some LR problem ingesting large numbers.
    I may also be that users are attempting to use LR for editing during the ingestion of large numbers--I found that I simply could not do that without a crash occuring. When I limited it to 2k at a time--leaving my hands off the keyboard-- while the import occured, everything went without a hitch.
    However, as previously pointed out, it shouldn't require that--none of my other DAMs using SQLite do that, and I can multitask while they are ingesting.
    But, you are right--multiple single causes--and complexly interrated multiple causes--could account for it on a given configuration.

  • Change transaction using BDC-problem for large number of lines on screen

    Hi All,
    I am developing BAPI (using BDC) which creates quality notification in SAP which is entered via front end web application. Structure p_qmsm contain 3 lines of task in notification. The code is as given below. To avoid problem of large no of lines on screen,code lines starting with * is used. This actually for pagedown after entering every 2 lines and creates new line. so that 2 lines always push up on screen and there will not be problem for creating large no of lines on screen
    perform bdc_dynpro using 'SAPLIQS0' '7200'.
    perform bdc_field using 'BDC_OKCODE' '=10\TAB11'.
    LOOP AT p_qmsm INTO wa_qmsm.
    *IF wa_qmsm_cntr > 2.
           wa_qmsm_cntr = 2.
           perform bdc_dynpro  using 'SAPLIQS0'                   '7204'.
           perform bdc_field   using 'BDC_OKCODE'                 '=PEND'.
    ENDIF.
    perform bdc_dynpro using 'SAPLIQS0' '7204'.
    perform bdc_field using 'BDC_OKCODE' '/00'.
    CONCATENATE 'VIQMSM-QSMNUM(' wa_qmsm_cntr ')' INTO wm_qmsm_qsmnum.
    CONCATENATE 'VIQMSM-MNGRP(' wa_qmsm_cntr ')' INTO wm_qmsm_mngrp.
    CONCATENATE 'VIQMSM-MNCOD(' wa_qmsm_cntr ')' INTO wm_qmsm_mncod.
    CONCATENATE 'VIQMSM-MATXT(' wa_qmsm_cntr ')' INTO wm_qmsm_matxt.
    perform bdc_field using wm_qmsm_qsmnum wa_qmsm-qsmnum.
    perform bdc_field using wm_qmsm_mngrp wa_qmsm-mngrp.
    perform bdc_field using wm_qmsm_mncod wa_qmsm-mncod.
    perform bdc_field using wm_qmsm_matxt wa_qmsm-matxt.
    wa_qmsm_cntr = wa_qmsm_cntr + 01.
    ENDLOOP.
    CALL TRANSACTION 'IQS2' USING wt_bdc
    MODE 'N' UPDATE 'A'  MESSAGES INTO P_MESSTAB.
    The same code is used in modify mode also. web application is sending all 3 lines in modify mode even if single line is modified. It is already decided to send all rows back from web application to SAP in same sequence. It is working fine if i comment 5 lines which is starting with *. But in modify mode, how can i ensure that correct row is modified? and how can i achieve problem of large no of lines on screen?Please suggest?

    Hi yogesh,
    how can i ensure that correct row is modified?
    1. For this we need to know two things ;
       a) the database table in which the entries are already stored
       b) the sequence in which they are displayed in the transaction.
    2. So before changing any line, we need to compare (the primary key values / important values)
       a) as per the database table and as per the incoming data from web application (using bapi)
      b) if the match is ok, it means that particular row was not modified, else modified.
    how can i achieve problem of large no of lines on screen?
    1. For this I am  not sure about the transaction and its screen. Manytimes for appending row on the screen,
      there is a PLUS + button on the grid toolbar. So for every entry, (inspite of some empty/filled rows already visible on the screen), we should use the + button, and this new row always appears on the top i.e. row number 1.
    hope this helps.
    regards,
    amit m.

Maybe you are looking for

  • No longer able to traverse structure in sharepoint.

    I have the following folder structure in Sharepoint 2007 Documents o   Region1 Department A Joe's Reports Lisa's Reports Bob's Reports Department B Department C o   Region2 o   Region3 I have assigned permissions at the "Reports" level giving Joe Con

  • Is it possible to use Powershell to determine if Windows Server Source Files are present on disk?

    Hi everyone, I would like to know if it is possible to use a Powershell cmdlet to determine if Windows Server 2012 (R2) Source Files are present on disk. We are using an automated PS script to install roles and features and some registry keys and app

  • Javax.mail CSV file attachment corrupt?

    I'm having some trouble with attaching a file to an outgoing email, it's a CSV file and when it is uploaded/attached to the email, it becomes "corrupt". Excel will still open it but if I open it in notepad the formatting is noticeably messed up. I ne

  • Audio on the internet

    My speakers are working, when I have tested them they seem to be working fine. When I go to watch a video or clip on the internet, there is no sound. As my speakers are working and the volumes are all turned up to max, I am not sure why the sound is

  • Someone knows why iMessage in iPad doesn't send message any more.

    I usually used iMessage in my iPad, but now it does not send messages. Someone knows how to fix it?