Loop problem - please help :-)

Hi I'm relatively new to PLSQL and I'm having a problem with a loop does not execute properly. I'll show you the code below (it's a bit long sorry) and then I'll explain it in detail, and then explain the problem.




I'm looping 1.student_count



/*

HTP.print (' student # ');
HTP.print (i);
HTP.print (')
');
HTP.print ('PIDM: ');
HTP.print (pidm_store (i));
HTP.print (')
');
HTP.print (' participated in the answer: "");
HTP.print (atten_store (i));
HTP.print (')
');
HTP.print ('CRN #: ');
HTP.print (crn_store (i));
HTP.print (')
');
HTP.print ('~ ~ ~');
HTP.print (')
');
HTP.print (')
');

JK * /.



OPEN AttenCheck (pidm_store (i), crn_store (i));
Look FOR AttenCheck IN temp_atten;



IF temp_atten IS NOT NULL THEN

HTP. Print ('test');


ON THE OTHER

IF i < = 9 THEN

j in 1.100
loop
If atten_store.exists (j) then


IF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "a".
THEN


temp_codes: = 'a ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;



ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "b".
THEN


temp_codes: = 'b ';.
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "c".
THEN


temp_codes: = 'c ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = has '
THEN


temp_codes: = ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store, (j), 2, 1) = 'e '.
THEN


temp_codes: = 'e ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "f".
THEN


temp_codes: = 'f';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "g".
THEN


temp_codes: = "g";
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "h".
THEN


temp_codes: = 'h ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = "i".
THEN


temp_codes: = 'i ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 1) = i AND substr (atten_store (j), 2, 1) = 'j '.
THEN


temp_codes: = 'j '.
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;
END If;

END IF;

end loop;

j: = NULL;
temp_codes: = NULL;

ON THE OTHER
j: = 1;


j in 1.100
loop
If atten_store.exists (j) then

IF substr (atten_store, (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "a".
THEN


temp_codes: = 'a ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;


ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "b".
THEN


temp_codes: = 'b ';.
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "c".
THEN


temp_codes: = 'c ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store, (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = has '
THEN


temp_codes: = ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store, (j), 3, 1) = 'e '.
THEN
;

temp_codes: = 'e ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "f".
THEN


temp_codes: = 'f';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "g".
THEN


temp_codes: = "g";
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "h".
THEN


temp_codes: = 'h ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = "i".
THEN


temp_codes: = 'i ';
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

ELSIF substr (atten_store (j), 1, 2) = i AND substr (atten_store (j), 3, 1) = 'j '.
THEN


temp_codes: = 'j '.
temp_responses: = temp_responses | temp_codes;
temp_codes: = null;

END IF;


END IF;

end loop;

END IF;




So here's the problem with this code.

I collect responses from the box on an html form - each (if enabled) box adds value to atten_store which is in this format (student #) to j, if the student is no. 1 and the person checks 3 checkboxes (the top 3), then the values of atten_store (1)-(3) would be 1 a, 1 b 1 c respectively. - so I store these responses in atten_store (x). The following code loops through student records and controls for their individual responses.

There may be up to 50 students with up to 9 responses each. so up to 450 values in atten_store.

The above loop starts by counting the total number of students and a loop in each where i represents the student number. IF statements are of course intended to determine if the student is # 1-9 or 10 + the reason for this is the values box... all students will be from 1 to 9 have values like this: 1a, 5 g, 9j etc - where the nature, the research will build on these 2 characters to find the right letter for a given total student. Loops removes the previous letter and gives the values provided for each student. The value of end, sent to the DB for 1 student is so, as you can see if student 1 gave a 1a, 1 c, 1f 'acf '.

For students who are > student # 9 must be treated differently as its replies of 3 characters. ex: 10A, 10B, so if I < = 9 then do one thing, if I > = 10 then do something else. By something else I am just searching differently if characters.

Of course, I suppose that there is a way better way to do it, but if you make the suggestion please try to explain it better, you can so I can try to implement with the rest of the code. in any case this is the problem...

On the entry screen with check boxes when I press on submit on page 1 - Page 2, load - which the above code is responsible. Page 2 shows the responses so far, and will soon add to DB. When I put in no value for student 1-9, this code works and display page 2. It will show the answers given for each student (ONLY WHEN I GET the ANSWERS FOR STUDENTS 10 +) if I get any response for students does not load 1-9, page 2. I get no error at all - so I guess its a kind of problem of NULL value or something (why not IE or Firefox displays an error? just page not found), but when I come back and only enter values for students 10 + it works beautifully.

So of course, my need is this: I want to be able to enter values for any student 1-9 or 10 +! She's. I guess it is a mistake to loopback somewhere in there, and I would be grateful any entry :-)

Thanks in advance,
Jeff

Published by: 795018 on Sep 15, 2010 08:25

Hello

You can simplify your code (parts):

IF i <= 9 THEN
  for j in 1..100
  loop
    if atten_store.exists(j) then
      IF substr(atten_store(j), 1, 1) = i
      and substr(atten_store(j), 2, 1) in ( 'a','b','c','d','e','f','g','h','i','j')
      THEN
          temp_responses := temp_responses || substr(atten_store(j), 2, 1);
      END IF:
   end if;
 end loop;
else
  -- same kind of code only for i>= 10

There is no closing the cursor (OPEN AttenCheck (pidm_store (i), crn_store (i))); in your code shown. Where you don't close it?

In addition, you have only a loop from 1 to 100 for j, but you mentioned, it could be 450. Is it possible that the students of 1-9 are not in this range? The atten_store table begins with your students of 1-9, or perhaps with the number 22.

Hope that helps a bit

Herald tiomela
http://htendam.WordPress.com

Tags: Database

Similar Questions

  • Table and the loop problems (please help)

    Im making a site for a project where I have to include a table and a loop.

    For this section, I put in a "contact us / Q and A" page where the user can enter a name, email, and question.
    This information is sent to a table and then following image shows the form of the table information in the dynamic text boxes.

    I've included a loop to check that each part of the table contains data (name, email and the issue).
    Then I have an If Else, which clears the form either if a section has been missed, OR if the form was completely correctly it directs the user to the frame following where as I said above the details appear in dynamic text boxes.

    The problem im having is the loop to check For the table that's a waste. Someone can please help me out here and get the loop to verify that all fields have been filled.

    Here is my code for the initial frame

    You must update the values in your table at the time you press the submit button. Code follows

    There is a second example to check the strings (it's a little complicated, but it's a useful trick if you can understand). This does not leave the Send button work unless all fields have something in them

  • my Iphone 5 was automatically turned off, and then I couldn't go? What is the problem please help me?

    my Iphone 5 was automatically turned off, and then I couldn't go? What is the problem please help me?

    Have you tried to connect your iPhone to iTunes or the wall charger and let your iPhone for 5-10 minutes to charge its battery?

  • Resolution / gambling problem please help me

    OK, I have vista 32 bit and when I get in any game at all and play... then get out of the wreck is fine... but then when I restart the Res changes again in the wreck the last game I played was set to and if the game does not have my native resolution it mess everything up on top of my desk and its starts to become annoying if someone could please help me because I really don't want to personalize then go to display settings and change every time that I log on... I tried to uninstall the latest software, tried to use the yahoo answers and they are not any help, MY RIG: AMD Athlon x 2 Dual Core 6000 + 3.1 Ghz, 8600 GT, 4 GB of ram, vista 32-bit , 22 inch monitor, native res: 1680 x 1050, Cyborg keyboard game... and I have IE8, any other information you need to know please ask me. Thanx

    Maniac of Vista,
    If you think that the problem started when you installed the Extreme 3D Pro stick, have you tried to uninstall it to see if the problem goes away?  Who will tell you for sure if that's the problem, you can access the web site of the manufacturer and see if they have a fix for this problem, or simply reinstall the software for the joystick could fix.

    You can also try to do a restore back before the problem occurred:
    To restore the operating system to an earlier point in time, follow these steps:
    Click Start, type system restore in the search box, and then click System Restore in the list programs.
    If you are prompted for an administrator password or a confirmation, type your password or click on continue.
    In the System Restore dialog box, click on choose a different restore point and then click Next.
    In the list of restore points, click a restore point created before you started having the problem, and then click Next.
    Click Finish.
    The computer restarts and system files and settings are back to the State they were in when the restore point was created.

    Let us know if this helped, or if you need further assistance.
    Thank you
    Gloria
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I had a "Blue screen" problem, please help me!

    Well, I don't really know the source but it happened several times already, here are the details of the error:

    Signature of the problem
    Problem event name: BlueScreen
    OS version: 6.0.6001.2.1.0.768.2
    Locale ID: 2057

    Files helping to describe the problem (some files may be is no longer available)
    Mini091109 - 01.dmp
    SysData. XML
    Version.txt

    See a temporary copy of these files
    WARNING: If a virus or other security threat caused the problem, open a copy of file can harm your computer.

    Additional information about the problem
    BCCode: 1000008e
    BCP1: C0000005
    BCP2: 8A90628F
    BCP3: 9CCAEDB0
    BCP4: 00000000
    OS version: 6_0_6001
    Service Pack: 1_0
    Product: 768_1
    Information about the server: 7ec0ad43-82ec-418c-af58-c7d4e1d1d9e8

    copied and pasted this information of view problem history in Control Panel and it was the biggest mistake, what happened is that the PC I use suddenly gets a blue screen with big writings saying something like she stops by unexpected error. After rebooting, it says "Windows has recovered from unexpected shutdown" and gives me a chance to see solutions on the net, but the work does'nt. Fortunately, I don't have an error for hours, but I'm afraid it may happen again. Please help me.

    My laptop has:
    AMD Athlon processor
    1 GB of RAM
    1.60 Ghz
    ATI Radeon X 1250
    Windows Vista
    120 GB hard drive (33 GB free now)

    I think that the mistake occurred whenever I might have too many applications open, especially in the section of the status bar, that I can't do it, please help me!
    Thank you.

    Hello

    Think the drivers - do all.

    Could be a nuisance pilot. Update your drivers manually looking at system manufacturer and
    Sites of the manufacturer of the device.

    This is my generic how updates of appropriate driver:

    For drivers, visit manufacturer of emergency system and of the manufacturer of the device that are the most common.
    Control Panel - Device Manager - Display Adapter - note the brand and complete model of your
    video card - double - tab of the driver - write version information. Now click on UPdate Driver (this
    cannot do anything as MS is far behind the certification of drivers) - then do a right click - Uninstall - REBOOT
    This will refresh the driver stack.

    Repeat this for network - card (NIC), Wifi network, sound, mouse, and keyboard if 3rd party with their
    own the software and drivers and all other main drivers that you have.

    Now go to the site of the manufacturer of system (Dell, HP, Toshiba as examples) (restoration) and then of the manufacturer of the device
    (Realtek, Intel, Nvidia, ATI, for example) and get their latest versions. (Look for the BIOS, Chipset and software)
    updates on the site of the manufacturer of the system here.)

    Download - SAVE - go to where you put them - right click - RUN AD ADMIN - REBOOT after each installation.

    Always check in the Device Manager - tab drivers version you install actually shows up. This
    because some restore drivers before the most recent is installed (particularly that audio drivers) so install a
    pilot - reboot - check that it is installed and repeat if necessary.

    Repeat to the manufacturers - BTW on device at the DO NOT RUN THEIR SCANNER - manually check by model.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    How to install a device driver in Vista Device Manager
    http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.html

    If you update the drivers manually, then it's a good idea to disable the facilities of driver in the Windows updates,
    This leaves ONE of Windows updates, but it will not install the drivers who are generally older and cause
    questions. If updates offers a new driver and then hide it (right click on it) and then go look for new ones
    manually if you wish.

    How to disable automatic driver Installation in Windows Vista - drivers
    http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
    http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx

    Hope these helps.

    Rob - bicycle - Mark Twain said it is good.

  • Hi people I have some hard drive problems, please help :)

    Hi guys, I just bought a Sata HDD internal 2 TB, but I do not see it in 'my computer', but when I go to computer management I see, I tried to do something with it, but an error pops up, I treid deleting and creating a new partition, but just before the end, I get this error : "The operation failed to complete because the disk management console view is not updated.  Refresh the view by using the refresh task.  If the problem persists close the disk management console, then restart disk management or restart the computer. "Please help. TNX

    Did you try to restart and try again as he proposed?  Assuming that you I had two ideas.  First of all, if your system is not aware of Windows updates, I would now.  Secondly, I have had good success called Easeus Partition Master that you can download from http://easeus.com .  I see they have a page for a free version 9.1 for users running the environments of 32 and 64 bit to http://www.partition-tool.com/personal.htm .

    I hope this helps.  Good luck.

  • Windows 7 blue screen problems, please help me

    Hey guys, I'm using windows 7, my laptop these past two weeks have blue screen problems. When I boot my laptop, and I use internet after some cell time but I have a blue screen with MSG (Message Details: to your computer. igdpmd64.sys PAGE_FAULT_IN_NONPAGED_AREA)

    If this is the first time that you have, "

    Please help me, there are the details:

    Signature of the problem:

    Problem event name: BlueScreen

    OS version: 6.1.7601.2.1.0.768.3

    Locale ID: 1033

    More information about the problem:


    BCCode: 50

    BCP1: FFFFF8811C177B60

    BCP2: 0000000000000000

    BCP3: FFFFF880067A5A18

    BCP4: 0000000000000005

    OS version: 6_1_7601

    Service Pack: 1_0

    Product: 768_1

    Files helping to describe the problem:


    C:\Windows\Minidump\042414-20155-01.dmp

    C:\Users\manjeet varsha\AppData\Local\Temp\WER-37752-0.sysdata.xml

    Read our privacy statement online:

     

    http://go.Microsoft.com/fwlink/?LinkId=104288&clcid=0x0409

    If the online privacy statement is not available, please read our offline privacy statement:

    C:\Windows\System32\en-US\erofflps.txt

    Here is an article describing how your problem may be related to a bad Windows Update.

    http://www.InfoWorld.com/t/Microsoft-Windows/Microsoft-pushes-another-botched-automatic-update-213802

    KB2670838 update uninstall can solve the problem for you.

  • BlackBerry Smartphones BB APP WORLD v. 1.1 PROBLEM - Please HELP!

    I am a new user/owner of a BB Curve 8330. In the options screen, it said c. 4.5.0.77 (Platform 3.2.0.51). I'm not sure what these numbers correlate exactly with (operating system, software device, etc.)-pathetically.

    This morning, I tried to upgrade to the new version 1.1 BB App World. I think I can get screwed up. When I installed it, it asked me if I wanted to remove the 1.0 version, and I said 'yes '. After installation of v. 1.1 and rebooting, I tried to use the new version and I always get the following error message:

    "BlackBerry App World is had problems connecting to the server BlackBerry App World. Check your network connections, and then try again. »

    My phone is not compatible with this version? I can't understand. I was going to download the 1.0 version and reinstall, but I can't seem to be able to find this version available for download.

    Please help - I don't know what to do.

    Thank you in advance,

    TDS

    PS: by the way, I know my network connections are fine. Everything works as it should.

    Here's the answer to the question I was trying to Irdawg a Newbie CrackBerry.com:

    Model: Curve 8330

  • Battery problems please HELP

    Hi all I just brought a laptop from pc world and there no battery sothey gave me money to buy one, but I can't find an anywere is a nightmere is a compaq presario a935em

    P/N KU062EA, someone got any idears and I have verified that hp and compaq sites please help

    Thank you very much

    HP parts... (800) 227-8164

    Contact HP:

    http://welcome.HP.com/country/us/en/wwcontact_us.html

  • I have a problem, please help me

    I have a leptop I buy. This leptop is the Windows operating system.

    My label to the back of Breackfast is not clear, I don't see it clearly

    know there's other way get my product key Home Premium.

    This my Leptop Modul:PC portable Compaq Presario CQ42-269TX

    [S/N deleted]

    Product number: WZ588PA #UUF

    Please Help me I need my Procuct Key to the label to recover my Windows operating system

    [Personal information]

    I have a month.

    My highlight number I don't know what that number might be that I need.

    Under writing HP
    and as scan code (line, line)

    584043 001

    Please help me.

    This is a forum for peer to peer and members here help each other voluntarily. Please see the link below in order to contact HP
    http://WWW8.HP.com/my/en/contact-HP/phone-assist.HTML#section

  • Help, please. Security problem please help. ___

    Another person in the apartment where I live has put its media player as an icon in my taskbar without asking. Please help me to make sure that it is impossible to do it again
    Thank you for your time and effort

    Make sure your firewall is on and Security Center Windows to check and make sure that everything is green, if there is something red or yellow then see what he wants. Make sure that you use the version of anti-virus update and update your Windows and antivirus. If you use try Wi - Fi to enable WPA2 or WEP 128, see the manual of the wireless modem.

    As AntiVirus, you can use Microsoft Security Essentials for free
    Scan with your antivirus complete and remove the threat. use of strong passwords for your Windows login, create strong passwords have look at:
    https://www.Microsoft.com/protect/fraud/passwords/checker.aspx

    Try to go to the BIOS Setup and disable the boot with CD and network and make sure you boot from the hard drive is turn on and rest are disable. (Check your BIOS manufactor to aid)

    If you are using Windows Vista Ultimate using Bitlocker

    Remember, if you choose password of Windows to the top, because if he has lost or forgotten, we cannot help you. In Windows, you can backup password.

    Remmember back up your data before password and put weekly or daily backup policy that if something is wrong you have backup (it is a good idea but a backup external hard drive). Windows Vista have already great backup feature.

  • BlackBerry Smartphones Re: 9360 Curve problem please help!

    An error occurred contacting the client BlackBerry World. If you have a content protection enabled on your device, please disable and try again. the same message that I get when connecting my laptop... Please help me

    I think that you... I think that you have tried. But, from what you say here, I have no idea exactly what you have tried. There are the specifics... The KB numbers would help. But telling us just what you have said so far we, we cannot say anything on what you actually tried and therefore cannot give you next steps as we have need to exclude what you have already tried. But you need to tell us exactly what you have tried (even once, would help the KB numbers).

    Please consider that we have only your words to guide us... nothing more than that. So far, your words have all the details to help us understand what you have already tried. I think you you tried something... I have no idea what it was.

    Thank you and let us know.

  • TWO PROBLEMS, please help me, I'm on a dead line, which was held yesterday.

    I want two fields unrolling to connect.  When I click on the first and say click on cards, I want the other to put only the sizes for the cards. When I cilck on Brochures, I want the other to get only sizes for brochures.    I did a test with the send e-mail button. When potential clients receive not, I want that they fill out the form and just be able to send it right back to me. Well after I filled out the form and tried to submit it, a box pops up and asked what kind of e-mail account was I trying to send it with, and then he made me save and attach myself to an e-mail.  Is there a way to get to where when they press on submit, they won't have to go through all this?   Please help me I'm on a deadline.  I guess I have this done yesterday.   I have attached the form...         Thank you

    Here you go...

    See the attached document. The solution is simple. I had to make a few simple changes in the 'DropDownListScript' script and add the JS code in the event of changing the drop-down list item. Now it's working.

    Also I added the new button next to your button to submit by e-mail. This a normal button but it does the same thing you want using script. Check the script to the title of the "click" event However to avoid, it will ask you what mail client, it assumes to use you need to set up some things before you try...

    For IE browsers...

    1. right click on the IE icon and choose Properties.

    2. open the "Programs" tab

    3. find the value in E-mail: box... it must match with your e-mail client.

    For example: it could be "MS OutLook" or "Lotus Notes"...

    Note1: He folds on each individual when computer is not fixed will be guest like the one you saw. There are therefore no control over that.

    Note 2: However, you must assign additional user rights to complete and submit this form. With that I guess that you only see blank form when someone sends you e-mail.

  • ADF 11 g: create with the data control problem: Please help

    Hello

    In my application, I tried to create a customized data controller.

    I created a Java class results and a bean ResultsBean class.
    Then I selected class results-> right click-> data controller to create.
    The Results.xml is created
    Everything is going well so far.

    Then I updated the details of class Bean in Results.xml and tried to re-create the data controller but did ResultsBean.xml ' t formed.


    In other words ResultsBean have not associated with outcome data controller.
    Please help on this.

    Version of the ADF: Studio Edition Version 11.1.1.3.0
    Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660

    Thanks and greetings
    Maryline Roussel

    Yes you use generics to the JDeveloper type, how the JDeveloper Assistant know the ResultBean is used to return an ArrayList value?

  • creating user problem - please help

    HII to all...

    I'm using oracle 11g. I created a user as a student as below...

    SQL > CREATE a NAMED USER student learn
    2 users DEFAULT TABLESPACE
    3 TEMPORARY TABLESPACE temp;

    Created by the user.

    SQL > grant connect, the resources of the student;

    Grant succeeded.

    SQL > conn
    Enter the user name: student
    ERROR:
    ORA-00604: an error has occurred at the SQL level 1 recursive
    ORA-01830: date format picture ends before converting all of the input string
    ORA-06512: at line 2


    WARNING: You are more connected to ORACLE.


    Please help me how to connect the student user...

    You can disable the logon trigger and try? What is the code?

Maybe you are looking for