Count with letters instead of numbers

Hello world

Today, I had an obligation to represent the rownums of a Recordset (1, 2, 3, 4, 5 and so on) as the letters (A, B, C, D, E and so on). First I thought there is a database function equal to the function to_char with RN parameter (which is capable of easily converting numbers to Roman numerals)... but I found nothing of didn t.

So is it a database work that I have not yet found a haven´t or you have a custom code to make me realize this?

Ty in advance
-Oliver

Hello

I don't think it's quite as simple as that. OP is not a number of base-26, because there is nothing quite like a 0 in this system, and therefore nothing quite like a 0.
In a base-26 system, you could represent 26 ^ 2 ^ distinct numbers with strings up to 2 characters.
OP wants something where you can represent 26 ^ 2 ^ + 26 separate numbers with strings up to 2 characters: 26 issues of the strings of characters-1 a set completely disjoint from 26 ^ 2 ^ ros with 2 strings.

I think the OP needs something more complicated, like this:

CREATE OR REPLACE FUNCTION to_abc
(      in_num       IN        PLS_INTEGER               -- Number to be converted
)
RETURN     VARCHAR2
DETERMINISTIC
IS
     in_num_26     PLS_INTEGER    := MOD (in_num, 26);
     rest          PLS_INTEGER;
     return_txt     VARCHAR2 (30);
BEGIN
     IF  in_num IS NULL
     THEN
          RETURN     NULL;
     ELSIF  in_num <= 0
     THEN
          RETURN  '-';
     END IF;

     return_txt := CHR ( 64 + CASE
                         WHEN  in_num_26 = 0
                         THEN  26
                         ELSE  in_num_26
                              END
                  );

     rest := CEIL (in_num / 26);

     IF  rest = 1
     THEN
          RETURN     return_txt;
     ELSE
          RETURN  to_abc (rest - 1) || return_txt;
     END IF;
END     to_abc;

Script test (including your base26 function, for comparison):

COLUMN     base26          FORMAT     A10
COLUMN     right_txt     FORMAT     A10
COLUMN     to_abc          FORMAT     A10

SET     NULL     "[NULL]"

WITH test_nums     AS
(
     SELECT     0 AS n,     '-' AS right_txt     FROM dual     UNION ALL
     SELECT     1,        'A'               FROM dual     UNION ALL
     SELECT     10,        'J'               FROM dual     UNION ALL
     SELECT     26,        'Z'               FROM dual     UNION ALL
     SELECT     27,        'AA'               FROM dual     UNION ALL
     SELECT     28,        'AB'               FROM dual     UNION ALL
     SELECT     52,        'AZ'               FROM dual     UNION ALL
     SELECT     53,        'BA'               FROM dual     UNION ALL
     SELECT     78,        'BZ'               FROM dual     UNION ALL
     SELECT     79,        'CA'               FROM dual     UNION ALL
     SELECT     702,        'ZZ'               FROM dual     UNION ALL
     SELECT     703,        'AAA'               FROM dual     UNION ALL
     SELECT     1404,       'BAZ'               FROM dual     UNION ALL
     SELECT     1405,       'BBA'               FROM dual     UNION ALL
     SELECT     18278,     'ZZZ'               FROM dual     UNION ALL
     SELECT     18279,     'AAAA'               FROM dual     UNION ALL
     SELECT     18280,     'AAAB'               FROM dual     UNION ALL
     SELECT     NULL,     NULL               FROM dual
)
SELECT     n
,     to_abc (n)     AS to_abc
,     right_txt
,     CASE
          WHEN  NVL (to_abc (n), '??') =
                NVL (right_txt,  '??')
          THEN  ' '
          ELSE  '<== WRONG!'
     END             AS flag
,     base26 (n)     AS base26
FROM     test_nums
ORDER BY  n
;

Results of the test script:

.        N TO_ABC     RIGHT_TXT  FLAG       BASE26
---------- ---------- ---------- ---------- ----------
         0 -          -                     [NULL]
         1 A          A                     a
        10 J          J                     j
        26 Z          Z                     aa
        27 AA         AA                    aa
        28 AB         AB                    ab
        52 AZ         AZ                    ba
        53 BA         BA                    ba
        78 BZ         BZ                    ca
        79 CA         CA                    ca
       702 ZZ         ZZ                    aaa
       703 AAA        AAA                   aaa
      1404 BAZ        BAZ                   bba
      1405 BBA        BBA                   bba
     18278 ZZZ        ZZZ                   aaaa
     18279 AAAA       AAAA                  aaaa
     18280 AAAB       AAAB                  aaab
[NULL]     [NULL]     [NULL]                [NULL]

Tags: Database

Similar Questions

  • My keyboard is typing the letters instead of numbers?

    My laptop keyboard is typing the letters instead of numbers. Before that happened, I was cleaning the keyboard with a toothpick, and when I clicked on Google Chrome, I typed in face and then I tried typing in the book, but then he is out,: faceb662 and at first I thought I used the numbers up but I wasn't.

    Uh, here is the info on my laptop:
    Windows Vista™ Home Premium
    Service Pack 2
    Manufacturer: Hewlett-Packard
    Model: HP Pavilion dv4 PC network
    Help, please! T T

    You have enabled your NumLock key, your number lock led should be on. Keep your 'fn + NumLock' keys at once to unlock.

  • Keyboard, type the letters instead of numbers

    After getting a virus on my computer and run MalwareBytes, my keyboard shows numbers when I typed letters. I have a Windows XP desktop PC and NUMLOCK is not on, so something is wrong. This does not occur when you use my admin account, apparently since I wasn't using it when I got the virus.  When they provide answers, please keep in mind that I can't run any programs in the account assigned because of problems caused by the virus file association. Runs the file XP on Doug Knox website for fixing exes did nothing within the affected account.

    The virus has not caused the problem. I found on another site that this is as a result of protection Comcast ConstantGuard.  I uninstalled it, and my keyboard is now back to normal. Most sites say it is caused by a num lock, but it wasn't the case with me.

  • keyboard typing letters instead of numbers.

    How to change a setting on my laptop keyboard to type letters numbers? It is stuck. I clicked on the upper button and it won't make the letters? I must have
    a click on a button to do this way. (accidentally). The laptop is a Compaq Presario F700.

    Frustrated,
    Jules

    Hello

    (1) have you made changes before the start of this issue?

    (2) this problem occurs when you type on the specific application?

    Method 1:

    Use the keyboard of the screen and check if the problem persists and let us know the status of the issue. Follow the steps in the link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/type-without-using-the-keyboard-on-screen-keyboard

    Method 2: You can have your NumLock. Please make sure that you turn it off by pressing the NumLock key and control if the problem persists.

    Also to ensure that the function key (fn) key on the keyboard is not subtracted when typing.

    I hope this helps.

  • A loop in the letters instead of numbers

    I need to create an array of strings containing ranging A100 at X 999.  I tried a loop in the letters, but I don't think this is possible

    var arrayAct = new Array();

    for (i = 'A'; I < = 'X'; i ++) {}

    for (i2 = 100; i2 < = 999; i2 ++) {}

    arrayAct.push (String (i + i2));

    }

    }

    Yes, but like this:

    for (var i = "A".charCodeAt (0); ") i<= "x".charcodeat(0);="">

    Console.println (string.fromCharCode(0)) (i));

    }

  • print small squares instead of numbers/letters

    having an intermittent problem with both my HP (laser & ink-jet) printers.  I've updated printer drivers, but still this problem - where small squares instead of numbers and letters sometimes appear.

    I read that the "print job wants to use a character that is not present in the selected font (font) and the character set' - that I sort of understand.  but I don't understand how/why that it just started to happen (I use these two printers for several years).

    and especially, I do not know what to do about it.  even when I save files as PDF files on my desktop, the small squares always appear...

    Thanks for any help!

    Applications > fonts Book.app

    Open the font book application.

    Click file >restore fonts Standard... and restore the fonts.

    Restart if necessary.

  • XP opens with symbols instead of letters, making it unreadable files and icons in the task bar and office

    To start my computer opens with letters replaced by symbols.  I ran antivirus, antimalware, etc. and finally went to the restoration of the system, and allows a point of restoring a couple of days before returning to the letters.  A few days later, the same problem occurred.  No, the system restore has no previous restore points available dates and I'm stuck. Help.

    HI AskDrL (and this also applies to the DrLHP - but you should follow the advice of the PA bear and not post back here if it does not help you - unless I suspect you two are really the same person with two usernames).

    Try a clean boot (Vista and W7) http://support.microsoft.com/kb/929135. If the problem goes away then it's just a matter of tracking down the culprit at the origin of the problem. Follow the procedures described in the article. Once found, remove, delete, disable or uninstall. Once don't forget to reset your system back to the normal state, as described in the procedures. If the problem occurs in clean mode then just restore the system to normal and reboot - this solution will not work. If you are using XP, see http://support.microsoft.com/kb/310353 and http://support.microsoft.com/kb/316434.

    Try starting mode safe mode with networking to see if the problem is here.  If this isn't the case, we have little room to work.

    Check the display properties to make sure that fonts and styles are correct:

    In XP, see http://support.microsoft.com/kb/140752/en-us.

    In Vista, see http://www.vistax64.com/tutorials/78281-advanced-appearance.html

    In Windows 7, see [2] http://www.sevenforums.com/tutorials/282-window-color-appearance-change.html?filter = appearance

    Check the locale and language to ensure that they do not appear in something weird and are set to standard English with normal fonts.

    Check Device Manager to see if there are problems with the video or monitor.  Whether (or not), go to the manufacturer of the computer or a web page of the manufacturer of the device and get the latest driver, firmware or software for the video card and monitor that are appropriate for your devices and your operating system.  To update all that is available and there is place and then reboot and see if that helps.

    If this does not work, I recommend repost you in the Windows Forum where experts in this will be more than happy to help you: http://answers.microsoft.com/en-us/windows/forum/desktop?page=1&tab=all&tm=1300700638376 but first, to the top, where it says Windows Version, use the dropmenu to select your, then you will find yourself in the appropriate forum for your system.

    I hope this helps.

    Good luck!

    P.S. If you are the same person, then you should uninstall it and use on McAfee removal tool as having AVG installed at the same time and it can cause disorders and problems - I doubt that what we see here, but it still needs to be done.  After normal uninstallation of McAfee, use the removal tool to get rid of leftovers: http://service.mcafee.com/FAQDocument.aspx?id=TS100507.  I don't know if this will solve the problem, but this should be done in any case that is likely to cause other problems on the road later.

  • When I open a link irc with a string name that contains "~" at the end, firefox (14.0.1) opens the same channel name but with "7%" instead of "~" at the end

    When I open a link irc with a string name that contains "~" at the end, firefox (14.0.1) opens the same channel name but with "7%" instead of "~" at the end
    http://img835.imageshack.us/img835/2856/clipboard05nq.jpg

    I can't open the image, but I can say something in general about the tilde.

    The tilde "~" is an unreserved character and that's why it can be replaced by its form encoded percentage '% 7' inside a URI without changing the meaning. See

    http://en.Wikipedia.org/wiki/percent-encoding

    According to article 2.3 of RFC3986 we should prefer the encrypted form so this behavior seems to be somewhat outdated.

  • Photosmart 5515: printing of the black bands with letters between them

    When I turned on the printer in a few minutes he printed some old stuff, so I have cancellation print and reset the queue of print.

    then I turn it on and once again and it automaticly in 30s feel something I don't know what it was on paper 4 black bands with letters inside, but I don't know what I have cancellation this new and send my project to Word ion it but he same thing printing.

    And when I do nothing there is every 30s trying to print black paper over and over again in the cycle

    Here's the video for it: https://youtu.be/gnvSbxrLqwE

    Hi again!

    I am happy to know that everything is working well for you again! Please click the "accept as Solution" button on my last post hereso that others in the community may also find and read our messages to help!

  • How to generate a single Point (On-Demand) edge counting with relaxing break

    I have problem when creating a Labview program to generate a single Point (On-Demand) edge counting with relaxing break illustrated in FIGURE 1 below. I only know how to build counter edge without relaxing break and my program is illustrated in FIG. 2 and gaskets also. Should what changes I make on my program? The DAQ card that I use is 6259 PCI/USB.

    FIG1. Single edge counting with break Point (on request)

    Fig.2 my program to generate the edge without relaxing break

    It is resolved

  • Using a counter with FiniteSamps and one with ContSamps

    I am using 2 counters on the NI USB-6229 (or USB-6259), case where a counter is implemented for FiniteSamps and another for ContSamps. I have the following MeasurementStudio code:

    ErrChk DAQmxCreateCOPulseChanTicks(hCnt0, "Dev1/ctr0", "", "20MHzTimebase", DAQmx_Val_Low, 0, 400, 400);
    ErrChk DAQmxCfgImplicitTiming(hCnt0, DAQmx_Val_FiniteSamps, 100);

    ErrChk DAQmxStartTask (hCnt0);

    ErrChk DAQmxCreateCOPulseChanTicks(hCnt1, "Dev1/ctr1", "", "20MHzTimebase", DAQmx_Val_Low, 0, 400, 400);

    ErrChk DAQmxCfgImplicitTiming(hCnt1, DAQmx_Val_ContSamps, 2);

    ErrChk DAQmxStartTask (hCnt1);

    When I run it, I get an error-50103 "the resource specified is reserved". If I change the FiniteSamps to ContSamps on the first counter, everything works fine.

    If I use only one counter with FiniteSamps, everything works very well.

    Is this a bug in DAQmx or the use of double counter on M Series devices is limited to ContSamps?

    VIC

    Hey Vic,

    It is actually planned on a device of the M series.  Here's a time diagram of the M Series user manual which might make this a little clearer:

    The device uses actually one counter for the other door so the result is a generation of finite pulse.  If you can provide the door from another source, you can configure a generation of continuous pulses on two counters and their door (DAQmx calls it a "relaxing break") of this external signal.

    You can also look at the use of the digital I/o correlated to generate impulses over multiple (up to 32 lines on your 6229 and 6259).  You could use one of the counters to generate a time base for digital lines and build the waveform as a result.

    One thing to note is that our new X series cards can generate a generation of impulses finished on a "single" counter (it was actually a paired internal counter that allows this).  There are four accessible counters by the user on the X series devices, which means you could generate four pulse trains finished.

    Best regards

    John

  • Control with Labview instead of MAX PCI-1422

    Hello Experts,

    I need your help in one of my problem. I have a camera of sensors unlimited that is SU - 640 1.7 RT - D and a card parallel NI PCI-1422. I can use and acquire data with power MAXI of the camera, but I want to exploit, use and acquire images from the camera by using LabView. Is it possible to export or using the camera with Labview instead to write fresh code in LabView?

    LabView offers it all support or bed automatically PCI-1422 or any possible solution that I get the code for the use of this device block diagram in LabView.

    Please let me know, answer.

    For any help or suggestion will be highly appreciated.

    Thanks in advance!

    Hi David,

    You can use the function IMAQ write file to record the images to the disc. Please see the link for an example below.

    IMAQ writing file 2 VI

    http://zone.NI.com/reference/en-XX/help/370281M-01/imaqvision/imaq_write_file_2/#IMAQWriteJPEGFile2

    IMAQdx enter and save individual files

    https://decibel.NI.com/content/docs/doc-19537

  • How to build a single Point (On-Demand) edge counting with relaxing break

    Hi, I am building a clock as shown below. It is also called 'Single Point (On-Demand) Edge Counting with relaxing break'.

    "

    I have problem to find the code example. So far, I can only build a counter edge without a controller trigger like below. Could someone help me?


  • How can I cerate a table with a set of numbers saying 1 to 12 random order but no recurrence.

    How can I cerate a table with a set of numbers saying 1 to 12 random order but no recurrence.

    I know it should be easy, but my brain doesn't work right now


  • My Win XP menu contextual folder always starts with 'Search' instead of how 'open' to ' open '?

    Original title: context menu of the folder

    My Win XP menu contextual folder always starts with 'Search' instead of how 'open' to ' open '?

    Edit the registry

    run regedit and navigate to [HKEY_CLASSES_ROOT\Directory\shell]
    the default value to 'none '.

    Or use this reg file, which does the same thing.

    Save and double-click, read this first if you want to check

    http://www.kellys-Korner-XP.com/regs_edits/folderopenssearch.reg

Maybe you are looking for