How to make a loop in SQL

Hi Have below requirement,

a.     Take the first 7 digits of a Number string and multiply the 1st digit by 8, the 2nd digit by 7 .....etc..... the 6th digit by 3 and the 7th digit by 2;
b.     Sum up the values of the above seven multiplication;
c.     Subtract 97 from the value at b. above until you have a negative number;
d.     Digits 8 and 9 of the number, the “check digits”, will correspond with the absolute value of the negative number determined at c. above. 

Example:

Passing input as number specific one, 'SK391313073' 

now first 7 digits are 3913130 and perform Sum like this (3*8)+(9*7)+(1*6)+(3*5)+(1*4)+(3*3)+(0*2) [Sum wil be 121]

I have achieved till above through sql,

Now the sum I should subtract with 97 till it get equal with 8th and 9th digit (here I should loop)

in this case 

121-97=24 so this is not equal to 73 (last two digits of input)
so now I need to again perform 24-97 which is -73 and abs(-73)=73 so I need to stop here,

All your help is appreciated,,

I don't think you need to loop.

you just need to find the minimum number, he will get to before arriving at zero and take then take it a plus:

for example

select abs(mod(121,97)-97) from dual

Good luck!

Tags: Database

Similar Questions

  • How to make a loop audio Clip?

    PrE7.

    How to make an audio clip loop a given time period?

    Let me know if you need, more or less long. I always your original, so the version published on the system. Do not delete for a few days. We can also adapt a modified version to get an exact duration, by basically Time stretch the Clip. I'm doing this at the hearing, so I can maintain the field and other aspects of the case. Pre can do, to a certain extent, but I like the control of the hearing. In addition, we can Volume keyframe fade sooner than the last Audio Unit, if they had to.

    Good luck

    Hunt

    PS - If you use SFX, I often more material, I'm going to need. Rather than change in Audition, I just put all the Clip of SFX on a track and keyframe and the Keyframe to just the place that I need. In this way, if, let's say I lengthen my video Clip later, I just need to set keyframes for SFX and I still have enough material to use - I have no re - edit in Audition.

  • How to make a loop with variable values depending on where you are in the loop

    Hello

    I need loops / nested loops that choose different figures depending on where you are in the loop.

    The entire function must operate at times 'ml '. 'ml' is a dynamic figure.

    Loop 1 = while the loop is the first 12 iterations, "exconemp" must be equal to 100. 13-24 iterations, 'exconemp' to 102.5 equal, for 25-36 TI 105.06, 37-48, it will be 107.69. This must change each 12th iteration until he reached 'ml '. The calculation takes the value of the previous 'exconemp' and then that multiply by 0.025.

    Loop 2 = while the loop is in 120 first iterations, 'abc' should be equal to 0.015 and additional iterations should use 0.01. It should also work in a way to know if 'ml' is greater or less than 120 and work accordingly.

    My main problem is - this - how can I get loops to go like this:

    While the iteration is < 12, to do this, THEN take the final figure (12th iteration) and begin the 13-24, make this SO etc etc.

    How to produce a THEN statement? I can get the code to pick up the final values, but does not change along the way.

    I think I might better create an array for loop 1, but I'm not entirely convinced of that. Also, I think it would be better/more net if I can get "month total 1 ' and ' month 2 total ' in loops, but do not know how to do this.

    The values I need to produce (only 36 first shown):

    1-12 = 125.55, 251,65, 378.31, 505.52, 633.29, 761.63, 890.53, 1019.99, 1150.03, 1280.63, 1411.81, 1543.57
    13-24 = 1679.05, 1815.12, 1951.79, 2089.06, 2226.93, 2365.41, 2504.50, 2644.20, 2784.52, 2925.45, 3067.00, 3209.18
    25-36 = 3355.19, 3501.85, 3649.15, 3797.11, 3945.71, 4094.96, 4244.87, 4395.44, 4546.68, 4698.57, 4851.14, 5004.38

    var ml = 240 / / dynamic figure, multiple of 12 up to 780
    var exconemp;
    var exconem = 100;
    var inf = 0.025;
    Tree var;
    var tec;
    power of the var;
    var fvis;
    var abc;
    var fvee;
    MVT var;
    function myfunction() {}

    Loop 1

    While (ml < = 12) {}
    exconemp = exconem;
    // }
    so that {(ml > 12)
    exconemp = exconem * inf;
    //}

    end loop 1

    trace ("exconemp =", exconemp); employee contribution

    tree = exconemp /(1-0.2)-exconemp;
    TEC = exconemp + tree;
    trace ('tree', tree);
    trace ("tec", tec);
    power = Math.pow (1 + 0.07, 1/12);

    Loop 2

    While (ml < = 120) {}
    ABC = 0.015;
    //}
    then {}
    ABC = 0.01;
    //}

    end loop 2

    fvis = power *(1-abc/12);
    trace ("fvis =", fvis);
    FVEE = tec * fvis;
    trace ("fvee =", fvee); month 1 total
    MVT = (CET + fvee) * fvis;
    trace ("MVT =", MVT); month 2 total
    //

    for (var i: Number = 0; i < ml; i ++)
    {
    MVT = (CET + MVT) * fvis;
    trace ("tfvloop =", MVT);
    }
    }

    I hope that I've explained this well enough.

    Thanks in advance.

    I think that will do it even if I don't quite get the numbers you posted.

    Stop();

    var ml = 48; figure dynamic, multiple of 12 up to 780
    var exconemp;
    var exconem = 100;
    var inf = 0.025;
    Tree var;
    var tec;
    power of the var;
    var fvis;
    var abc = 0.15;
    var fvee;
    MVT var;

    MyFunction();

    function myfunction()
    {
    exconemp = exconem;

    for (var index: uint = 1; index)<= ml;="">
    {
    trace(index + "--------------------------------");
               
    tree = exconemp /(1-0.2)-exconemp;
    TEC = exconemp + tree;
    power = Math.pow (1 + 0.07, 1/12);
    fvis = power *(1-abc/12);
    FVEE = tec * fvis;
                       
    if(index == 1)
    {
    trace ("month 1 total =", fvee);
    }
    another if (index == 2)
    {
    MVT = (CET + fvee) * fvis;
    trace ("month 2 total =", MVT); month 2 total
    }
    on the other
    {
    MVT = (CET + MVT) * fvis; now that we're here the MVT auto perpetuates on himself
    trace ("months" + index + "total =", MVT); month total n
    }
                       
               
    If (index %12 == 0)
    {
    exconemp = exconemp *(1+inf);
    trace ("changed to exconemp to:" + exconemp);
    }
               
    If (index % 120 == 0)
    {
    ABC =. 01;
    trace ("changed abc to:" + abc);
    }
               
    }
    }

  • How to make a loop performance during a given period of time?

    Hello!

    I'm new to labview and have found how to do a loop running for 2 seconds for example, and then to get out.

    Hi Hookso,

    You can do this by using different loops like while loop and loop for Roderic has already indicated how using a loop for I illustrated in the attached vi how using a while loop and function of elapsed time. Take a peek inside.

    Kind regards

    Amine31

    (Give congratulations to good answers and Mark as a Solution If your problem is resolved)

  • How to make Apple Loops loops securities if they are not my own?

    In garageband, I'm open to a screen with what is called the 'loop' at the top. He tells me that I can't use loops that are not highlighted in green because they are not "Apple Loops". There is a track that I would use, but it is not an "Apple Loop" with a green logo on the side. How can I make an Apple loop if it isn't my own record but found on garageband. I have attached what looks like on my screen. The track that you see in the Favorites is the one I want to use. Thank you

    Drag the 'Deep End Echo Piano' loop to the empty space under all your tracks.  It's an audio loop and not a software instrument loop. If you can not drag on a software instrument track. You can drag it onto an audio track or below all the Flickr photos to create a new track.

  • How to make a loop on downloaded mp3 sound for iPhone 6

    I downloaded Brown noise via iTunes. It is called white loops noise for a sleep sounds for life (Yes it's Brown noise!), but it is not in a loop. How can I do so that it plays continuously and helps me sleep loop on my iPhone 6?

    Thank you!

    In-app music play, press 'read' bar near the bottom so it slides up. A loop is displayed near the bottom (two arrows punting on themselves).

    Press it to activate a loop. You probably want to make sure that the file is in a playlist or album or other securities may loop.

  • How to make a loop that records data block without having to navigate to it

    I have a form with 2 tabs. Tab_1 displays the information of the monitor and tab_2 raw_data (that the user attempts to insert/update or delete) for the monitor. The two tabs have a button 'Post production', which messages the raw_data (in tab_2) to the database. If it is an update operation, I have to check if a column_value_1 has changed from what is present in the comic book. If so, then the user should be given a warning. The warning would be appropriate if the column_value_1 for any 1 record is changed. Therefore, the comparison can be stopped after first difference. The code in the when_button_pressed trigger looks like

    go_block (raw_data());
    first record;
    loop
    If value_changed then
    v_alert: = true;
    "exit";
    end if;
    IF: SYSTEM. LAST_RECORD = "TRUE" THEN
    EXIT;
    ON THE OTHER
    NEXT_RECORD;
    END IF;
    end loop;

    If v_alert then
    display_alert;
    end if;

    This should work fine if I'm in tab_2 (which displays the block of raw_data). But if I hit the 'Post production' button tab_1, go_block (raw_data()) would go to tab_2, I do not want to make. So, how can I browse the raw_Data in tab_2 block without having to navigate to this tab?

    Prosper,

    I don't have what it is possible to loop in a block without having to navigate to it. Instead, you can navigate to the control you are calling by GO_ITEM integrated.

    Kind regards

    Manu.

  • How to make a loop simple counter in labview 7.1?

    I'm trying to teach me how to use labview 7.1, but having trouble finding how to use functions properly. I am trying to create a simple loop to count from 1 to 10 with a delay of 1 second between each number. I would be grateful the help!

    Classes resumed?

    The key words are 'loop' (try a loop FOR the palettte of structures), 'delay' (try a wait (ms) of the range of timing). Use a constant instead of diagram for the "1 second" (or 1000 ms). and use a digital display to show the current number (for example by using an indicator connected to a terminal of the loop iteration FOR). Given that [i] starts from 0, first use a primitive of + 1. Wire a constant at the end of the loop to determine the number of iterations. You should be able to determine the correct value, math or by trial and error.

    Now try to gather all, shouldn't be too difficult. Where have you problems? Have you looked at the examples? Did you do tutorials?

    Once you have a project, post it here and we can propose possible improvements.

  • How to make a loop for

    Well, I have a problem I do not know how to solve.

    The idea is simple but I have no idea how to implement it on LabView. Here it goes:

    I start with a picture of a [i]. For i from 1 to 5, I initialize all values to zero. I want to build one because I have 1 to 5 that loop for each iteration replaces the value of a [i] EI with i.

    Maybe I'm missing something but I don't know how to do. I would appreciate it if you could give me some advice.

    Kind regards

    Can be done this way.  You don't know why you must initialize and then replace.  Much easier to create just using autoindexing.

  • How to make a loop that only loop 3 times?

    Hello

    I'm doing a HTML5 canvas animation (w / Adobe animate CC) loop that only 3 times.

    But when I want to publish it, I did that a check box that allows me to loop forever or not.

    How can I do? Do you have a solution for me?

    Thank you to

    Ludo

    Place the code in the last keyframe:

    {if(!this.alreadyExecuted)}

    this.alreadyExecuted = true;

    this.loopNum = 1;

    } else {}

    this.loopNum ++;

    {if(this.loopNum==3)}

    This.Stop ();

    }

    }

  • How to make a loop made up of images in another comp?

    Hello

    I rotoscoped an object in a montage video, composed before she and added to another composition, with the intention of putting in a loop. However, I am unable to loop the demo, get the error "this property has no keyframes.

    Duration of the pre-comp is 2 seconds, while the main computer is 20 seconds. I need the demo to last throughout the composition of 20 seconds. How can I do? I'm not allowed to simply drag the demo all the way to the 20th second on a timeline

    Remapping temporal or simply duplicate the layer as many times as necessary.

    Mylenium

  • How to make a backup of sql database before upgrade to vSphere 4

    Hi, I own a vcenter 2.5 running with microsoft sql server lite (supplied by binary vcenter)

    What is the best practice to backup my DB before doing the upgrade?

    Is there a risk to my host, because now, they run in 3.5

    Concerning

    On your database server, open SQL Server Management Studio Express.  Connect to the SQLEXP_VIM database. List drop-down list of databases, click with the right button on VIM_UMDB, go to work, go to the backup. Note the backup location, make the desired changes, then click OK. Do the same for the VIM_VCDB. vCenter4 has no problem of ESX 3.5 server management, I have a mixed environment at the moment and it works fine. Keep in mind when you begin to update your virtual hardware version 7, you will no longer be able to vmotion for ESX 3.5 boxes.

  • How to make the loop audio clips in the first or elsewhere

    HOW CAN I DO AUDIO LOOPING CLIPS IN THE FIRST OR ELSEWHERE?

    None of these answers are correct.

    My brother found this thread, looking for help and left in frustration, asking for the answer instead.

    Kevin Monahan response is only semi-finished.

    Here's the full answer:

    Looping a video or audio clip on the timeline, right-click and select 'nest...".

    Name the nest, what you please.

    Now, double-click on nested clip you just created. This allows to enter the nested sequence.

    NOW you can select the clip, copy and Paste several times. (Just keep hitting CTRL V, and the read head automatically moves forward to place the next clip.)

    Return to the main sequence.

    Now you can use the selection tool to extend this nest as much or as little as you like.

    It is a far superior method, because a nested sequence is a SINGLE ELEMENT that can be resized, given effects, moved, lengthened and shortened very easily.

  • Flash: CS Pro. How to make a loop of animation in continuous-Revisited

    I'm stumped on this question. All the tips here are greatly appreciated!

    In my original thread, my answer was given and that I should just take the information and tweak it so that it applies elsewhere in the code.

    Original thread:

    http://forums.Adobe.com/thread/679725?TSTART=0

    The event is marked as answered. How I built the code here has been using the built in code snippets and he DID almost exactly as I needed to.

    Only, I had the animation loop.

    Because each video Clip is handled individually, let explain me by Ned Murphy on this forum that I need to insert the code for each individual item to send it to start when it comes off the stage because it is structured to go to infinity with the symbols of movie continuing on their way.

    I get that. A bit of code to add was provided for a clip example that started above the stage and went down, then when he will leave the stage, go back. In this case, the additional code (provided by Ned Murphy, which is IMHO a guru here) it was for MovieClip_15 (on 15) Red has been added:

    _______________________

    / * Animate vertically
    */

    movieClip_15.addEventListener (Event.ENTER_FRAME, fl_AnimateVertically_13);

    movieClip_15.startY = movieClip_15.y;

    function fl_AnimateVertically_13(event:Event)
    {

         // Verify that the mc is still visible within the scenic space
    if(movieClip_15.y < stage.stageHeight+movieClip_15.height) {}

    movieClip_15.y += 1;

    } else { / / Reset on where he began to

    movieClip_15.y = movieClip_15.startY;

    }
    }

    _______________________________

    Worked perfectly!

    Has worked for clip 14 so simply by changing all references to MovieClip_14

    14 went down as well.

    ________________________________

    My Question now. Clip 13 comes up from the back of the stage, the top of the page. I tried all the logic (of course missed something)... changed <>icon has frozen in place. Tried to think through a few more things, but... it seems that the original code must return the clip... it doesn't. What I should tweak here and what I'm doing wrong? :

    movieClip_13.addEventListener (Event.ENTER_FRAME, fl_AnimateVertically_11);
    movieClip_13.startY = movieClip_13.y;
    function fl_AnimateVertically_11(event:Event)
    {
    If (movieClip_13.y < stage.stageHeight - movieClip_13.height) {}
    movieClip_13.y-= 1;
    } else {/ / reset on where he started}
    movieClip_13.y = movieClip_13.startY;
    }
    }

    If the movieclip is heading upwards on the top of the scene, then you want to test for when it is< 0="" (the="" top="" of="" the="" stage="" is="" where="" y="0)" but="" also="" factoring="" in="" the="" height="" of="" the="" movieclip,="" so="">

    If (movieClip_13.y<>

  • How to make the output of Sql Plus with an error Code

    Dear members,

    How can I define sql more exit with an error code.

    We have a simultaneous host program. The executable is a shell script for this program. This sql script Shell script request which in turn gives call to a custom database package that I built.

    The flow rate is:


    -> SQL-> CUSTOM PACKAGE SCRIPT SHELL SCRIPT

    Custom package has two PARAMETERS of the error indicator and the error message. If something fails in the package these two PARAMETERS is returned with a value.

    So my sql script code looks like this:

    WHENEVER SQLERROR EXIT 251
    WHEN the OSERROR EXIT 251
    Set serveroutput size 1000000
    set linesize 32767
    set verify off
    set the position
    Set feedback off

    DECLARE
    x_error_message VARCHAR2 (1000);
    x_sql_message VARCHAR2 (1000);
    x_exception EXCEPTION;
    e_value NUMBER;

    BEGIN
    dbms_output.put_line ('Inside sql file');


    XXpackage.xxproc (x_error_message, x_sql_message);


    IF (x_error_message IS NOT NULL) AND (x_sql_message IS NOT NULL) THEN
    RAISE x_exception;
    END IF;


    EXCEPTION
    WHEN X_EXCEPTION THEN
    e_value: = 1;
    DBMS_OUTPUT. Put_line (' Exit Code: ' | e_value);
    DBMS_OUTPUT. Put_line ('X_EXCEPTION: EXCEPTION IN SCRIPT xpoext04a.sql :'||) SQLERRM);
    DBMS_OUTPUT. Put_line ('x_error_message is: ' | x_error_message);
    DBMS_OUTPUT. Put_line ('x_sql_message is: ' | x_sql_message);
    DBMS_OUTPUT. PUT_LINE (' ERROR IS: ' |) SQLERRM);
    WHILE OTHERS THEN
    e_value: = 252;
    DBMS_OUTPUT. Put_line (' Exit Code: ' | e_value);
    DBMS_OUTPUT. Put_line (' OTHER: EXCEPTION IN SCRIPT xpoext04a.sql :'||) SQLERRM);
    DBMS_OUTPUT. Put_line ('x_error_message is: ' | x_error_message);
    DBMS_OUTPUT. Put_line ('x_sql_message is: ' | x_sql_message);
    DBMS_OUTPUT. PUT_LINE (' ERROR IS: ' |) SQLERRM);


    END;
    */*
    output
    */*


    As you can see from above, if the two PARAMETERS have value, then it goes to an exception.

    My problem is that if it goes with the exception of X_EXCEPTION, the sql is not come away with a mistake. I mean sql is not treat this case like a sqlerror.


    How can do us more sql dating a sqlerror so that the host program must fail.


    Thank you
    Sandeep

    Published by: user340 on July 28, 2009 12:51

    Published by: user340 on July 28, 2009 12:57

    the plu sql is not come away with a mistake. I mean sql is not treat this case like a sqlerror.

    This is because there is no error. You handled the exception.

    You can try adding a STIMULUS; at the end of your exception section. This re-triggers the exception so sql liked to see it.

Maybe you are looking for

  • Satellite M40X-159 - Fax Voice software

    Can anyone recommend a FaxVoice software more suitable for this machine? I try FaxTalk Messenger Pro but have problem initialize (a software modem from Toshiba). Other software (Mighty Fax) work very well, but did not voice option.

  • mathematical calculation in script on each element of the array.

    Hi all I am trying to write the VB script in which I want to do different mathematical operation on each element of channel-specific data. For example, for each element I want to find the next two index given way and both before and after publication

  • My security engine

    It bird constantly virus alerts, which don't exist. He's trying to make me buy a virus, called MY SECURITY ENGINE program? HOW can I get RID OF it

  • Cannot install microsoft visual c ++ runtime of the 2015

    HelloI can't install microsoft visual c ++ runtime 2015, during the attempt he stucks at 100% for hours. I have to manually cancel.I have tryied uninstalling all previous microsoft visual c ++ runtimes, does not help... It is Windows 7 N (for student

  • Where clause in the "default_where" of get_block_property is not cancelled...

    HelloI developed a form with two blocks.The first - block of non - database contains the criteria.Database of the other - block-displays the records according to the inserted.Also, there is a button that executes the query criteria.The code of the BU