Help ordering a recordset

Hello, I'm new to Oracle and SQL as well. I have a table that stores hundreds of names in the following pattern:
RMAWSTI09
RMAWSTI10
RMAWSTI100
RMAWSTI11
RMAWSTI01
RMAWNOTE01
RMAWNOTE10
RMAWNOTE11
RMAWNOTE100
I want to order those names considering only the numeric part. Can anyone assist me on how to do it? I found out that this is possible by using the regexp_replace function, but I'm having trouble to understand its syntax. Thanks in advance.
edit: using oracle 10g

Massimo Ruocchio wrote:
Or
ORDER BY TSTRING,  TO_NUMBER(REGEXP_REPLACE(TSTRING,'[^0-9]+',''));if tstring for sure starts with alphabetic characters... less regex evaluation means improved performances...Have you actually tried it? It doesn't return the same results:
SQL> WITH test_data AS
  2  (
  3          SELECT 'RMAWSTI09' AS TSTRING FROM DUAL UNION ALL
  4          SELECT 'RMAWSTI10' AS TSTRING FROM DUAL UNION ALL
  5          SELECT 'RMAWSTI100' AS TSTRING FROM DUAL UNION ALL
  6          SELECT 'RMAWSTI11' AS TSTRING FROM DUAL UNION ALL
  7          SELECT 'RMAWSTI01' AS TSTRING FROM DUAL UNION ALL
  8          SELECT 'RMAWNOTE01' AS TSTRING FROM DUAL UNION ALL
  9          SELECT 'RMAWNOTE10' AS TSTRING FROM DUAL UNION ALL
10          SELECT 'RMAWNOTE11' AS TSTRING FROM DUAL UNION ALL
11          SELECT 'RMAWNOTE100' AS TSTRING FROM DUAL
12  )
13  SELECT  TSTRING
14  FROM    TEST_DATA
15  ORDER BY REGEXP_REPLACE(TSTRING,'[0-9]+','')
16  ,       TO_NUMBER(REGEXP_REPLACE(TSTRING,'[^0-9]+',''));
TSTRING
RMAWNOTE01
RMAWNOTE10
RMAWNOTE11
RMAWNOTE100
RMAWSTI01
RMAWSTI09
RMAWSTI10
RMAWSTI11
RMAWSTI100
9 rows selected.
SQL> WITH test_data AS
  2  (
  3          SELECT 'RMAWSTI09' AS TSTRING FROM DUAL UNION ALL
  4          SELECT 'RMAWSTI10' AS TSTRING FROM DUAL UNION ALL
  5          SELECT 'RMAWSTI100' AS TSTRING FROM DUAL UNION ALL
  6          SELECT 'RMAWSTI11' AS TSTRING FROM DUAL UNION ALL
  7          SELECT 'RMAWSTI01' AS TSTRING FROM DUAL UNION ALL
  8          SELECT 'RMAWNOTE01' AS TSTRING FROM DUAL UNION ALL
  9          SELECT 'RMAWNOTE10' AS TSTRING FROM DUAL UNION ALL
10          SELECT 'RMAWNOTE11' AS TSTRING FROM DUAL UNION ALL
11          SELECT 'RMAWNOTE100' AS TSTRING FROM DUAL
12  )
13  SELECT  TSTRING
14  FROM    TEST_DATA
15  ORDER BY TSTRING
16  ,       TO_NUMBER(REGEXP_REPLACE(TSTRING,'[^0-9]+',''));
TSTRING
RMAWNOTE01
RMAWNOTE10
RMAWNOTE100
RMAWNOTE11
RMAWSTI01
RMAWSTI09
RMAWSTI10
RMAWSTI100
RMAWSTI11
9 rows selected.100 is ordered before 11 in both cases. You need to sort only the characters then the numbers.

Similar Messages

  • Need help with a recordset

    I need some help with a recordset that selects a series of
    vehicle makes that then show models when a make is selected. The
    problem is when I select the make it shows a list of models like it
    should, some of the make lists have five models and some have ten
    or more. What I need help with is how to limit the list to just the
    models and not include the "null" values. This makes my drop down
    list have large empty spaces at the end of the options listed. The
    query is as follows:
    SELECT *
    FROM saa.vehicle_make
    WHERE make = '#FORM.select_make#'
    Question # 2:
    What can I add to this recordset so that I can search on just
    the make alone without the model included. The submit includes both
    of the make and model lists so that makes it tough to break up.
    Here is the recordset:
    SELECT make
    FROM saa.vehicle_make
    ORDER BY make ASC
    Thanks
    Shane

    Sorry I guess I wasn't being clear. The lists work fine with
    the present recordsets but I was trying to clean them up just a
    little. I am using a table in mysql instead of an array for ease of
    maintenance due to the high number of makes and models I am working
    with.
    For question number one I was looking for sql that allows me
    to only show the models in the table for each make no matter how
    many are in the row. Currently when I use the existing recordset I
    get a long list of blank spaces as it is returning the "null"
    fields also. I would like it to just show the models and stop at
    the first null field.
    For the second question I wanted to be able to submit the
    form with just the make listed if someone wanted to see all Hondas
    lets say. Not I have to select the make also so it limits the
    return.
    Thanks for all of the input
    Shane
    Here is the code I am using for the two dependent select
    boxes:
    <p align="center">Vehicle Search by
    Make/Model</p>
    <!--- store the selected make variable after the first
    select boxes submits itself --->
    <cfif isDefined('form.select_make')>
    <cfset page.select_make = form.select_make>
    </cfif>
    <cfoutput>
    <form name="DropDown" method="post">
    <!--- query DB for the first drop down list --->
    <cfquery name="get_make" datasource="saa">
    SELECT make FROM saa.vehicle_make ORDER BY make ASC
    </cfquery>
    <!--- first drop down list --->
    <!--- NOTICE the onChange javascript event in the select
    tag, this is what submits the form after the first selection
    --->
    <p align="center">Model:<select name="select_make"
    required="yes" onchange="this.form.submit()">
    <option>Select Make</option>
    <!--- dynamically populate the first drop down list based
    on the get_make query --->
    <cfloop query="get_make">
    <option value="#make#" <cfif
    isDefined('form.select_make')><cfif form.select_make eq
    "#make#">selected</cfif></cfif>>#make#</option>
    </cfloop>
    </select></p>
    <!--- if the first selection has been made, display the
    second drop down list with the appropriate results --->
    <cfif isDefined('form.select_make')>
    <!--- query DB for second drop down list, based on the
    selected item from the first list --->
    <cfquery name="get_model" datasource="saa">
    SELECT * FROM saa.vehicle_make WHERE make =
    '#FORM.select_make#'
    </cfquery>
    <!--- second drop down list --->
    </cfif>
    </form>
    </cfoutput>
    <cfoutput>
    <form action="buyerModelSearchresults.cfm"
    method="POST">
    <p align="center">Model: <select name="model"
    required="yes">
    <option>Select Model</option>
    <!--- dynamically populate the second drop down list
    based on the get_make query --->
    <cfloop query="get_model">
    <option value="#model1#">#model1#</option>
    <option value="#model2#">#model2#</option>
    <option value="#model3#">#model3#</option>
    <option value="#model4#">#model4#</option>
    <option value="#model5#">#model5#</option>
    <option value="#model6#">#model6#</option>
    <option value="#model7#">#model7#</option>
    <option value="#model8#">#model8#</option>
    <option value="#model9#">#model9#</option>
    <option value="#model10#">#model10#</option>
    <option value="#model11#">#model11#</option>
    <option value="#model12#">#model12#</option>
    <option value="#model13#">#model13#</option>
    <option value="#model14#">#model14#</option>
    <option value="#model15#">#model15#</option>
    <option value="#model16#">#model16#</option>
    <option value="#model17#">#model17#</option>
    <option value="#model18#">#model18#</option>
    <option value="#model19#">#model19#</option>
    <option value="#model20#">#model20#</option>
    <option value="#model21#">#model21#</option>
    <option value="#model22#">#model22#</option>
    <option value="#model23#">#model23#</option>
    <option value="#model24#">#model24#</option>
    <option value="#model25#">#model25#</option>
    </cfloop>
    </select>
    </p>
    <p align="center">Search by Make/Model:</p>
    <p align="center"><input type="submit" name="Submit"
    value="Submit"></p>
    </form>
    </cfoutput>

  • Help with multiple recordsets and pulling an ID value (ASP)

    I started this discussion when first developing my project and posted on the General Tab.  I have figured out that issue (trying to get my Insert to work in ASP) but now am having trouble retrieving an ID value.  It should be simple.  I want to insert a new record into a single table and want to create a unique ID field.  I am using SQL Server and tried the Identity setting but won't be able to have admin privileges which are required to set the ID.  So, I'd like to just take the ID value from the last record and just add '1' to it to get a new unique ID manually. My INSERT portion was working, so I just decided to query the records to retrieve the last CatalogID and add '1' to get my new ID.  But it's not working!  I tried opening both a command and a recordset, but get various errors on invalid command use. 
    Any help would be great!  I'm new to all of this!
    I've posted a code snippet of what I thought I should do:
    <%LANGUAGE = “VBSCRIPT” CODEPAGE=”65001”%)
    <!--#include file=”Connections/CapConnect.asp”” -->
    <%
    If (Cstr(Request(“MM_insert”)) = “form1”) Then
                    Dim MM_editCmd
                    Dim MM_Lookup
                    Dim NextCatalogID
                    Set MM_Lookup = Server.CreateObject (“ADOB.Recordset”)
                    MM_Lookup.ActiveConnection = MM_CapConnect_STRING
                    MM_Liikup.Source = “Select CatalogID From dbo.tblCatalogItems ORDERBY CatalogID Ascending”
                    MMLookup.Open
                    MM_Lookup.MoveLast
                    NextCatalogID = MM_Lookup.Fields(“CatalogID”) + 1   'this is supposed to be my new ID value
                    Set MM_Lookup = Nothing
                    Set MM_editCmd = Server.CreateObject(“ADOB.Command”)
                    MM_editCmd.ActiveConnection = MM_CapConnect_STRING
                    MM_editcmd.CommandText = “INSET INTO dbo.tblCatalogItems (CatalogID, ModelName, Description, POCName, [POCPhone]) VALUES (NextCatalogID, ?,?,?,?)
                    MM_editcmd.Prepared = True
                    MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param2”, 202, 1, 100, Request.Form(“modelname”) )
                  MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param3”, 202, 1, 300, Request.Form(“Description”) )
    [Subject line edited by moderator to add server model]

    Ok, you've got lots of problems. First, explain again why you are not able to modify the CatologID to be an identity column? What is the datatype of that column now?
    Next, you are going about selecting your recordset incorrectly. If you are just looking for the last value inserted, there is no need to return all values to the recordset. Just select the max value:
    MM_Liikup.Source = “Select MAX (CatalogID) From dbo.tblCatalogItems”
    Next, you have a typo in your insert statement "“INSET INTO" should be "INSERT INTO"
    Next, your CommandText is wrong. There is no ending quote, and NextCatalogID will be treated as a string literal, not a variable. Use a ? placeholder for it and use the CreateParameter method to populate it.
    Next, your command text includes 4 placeholder, but you are only populating 2.
    But even when you get this to work it will be problematic. What happens when 2 users execute this at the same time? They both read the same value for the max record and increment by one, but the first will succeed and the second will fail. That's why it is always better to use an auto increment (Identity) column.

  • Datagrid Column Ordering from Recordset?

    I often populate my datagrids with a recordset, an array of record objects, by passing the recordset in the dataprovider constructor. However, this results in unpredictable column ordering i.e. it doesn't correspond to the order of the fields in the record object. I know you can define the columns and then use add item to add the records to resolve this, but I'm curious why the datagrid doesn't order the columns according to the record object field order in the first place and why the order can actually change between renderings of the datagrid?

    Thanks for the response. I understand the method to order the columns, I'm more curious why doing something like this:
    var arr:Array = new Array();
    arr.push({label:"item 1b", qty: 1});
    arr.push({label:"item 2b", qty: 2});
    var dp:DataProvider = new DataProvider(arr);
    results in the columns being randomly ordered. It be nice if the data grid always produced columns in the order of
    label   qty
    Its probably rooted in the fact a for..in loop doesn't get values from an object in a useful order either.

  • Help: ORDER BY variable does not work in CS3

    I have a variable in my recordset query for the ORDER BY
    clause which is set by the URL variable, 'order'. With CS2 the
    recordset worked fine with the variable. CS3 shows N/A for the
    variable type in the Recordset dialog, and when I click Test to
    test my recordset, it says I need to specify a variable type. So I
    set it to 'Text' and suddenly the variable doesn't even work. It
    just orders the records by ID. Am I going to have to use CS2 to
    create recordsets with an ORDER BY variable in the future or is
    there some other way around this?

    AngryCloud wrote:
    > In CS2, Dreamweaver does not ask for a data type.
    There is no such thing as Dreamweaver CS2. You are presumably
    talking
    about the version of Dreamweaver that was bundled with Adobe
    Creative
    Suite 2 after Macromedia was acquired by Adobe. That was
    Dreamweaver 8.
    From the sound of it, you have the original Dreamweaver 8,
    which didn't
    use data types for variables. Everything changed when the
    8.0.2 updater
    was released. The updater made important changes to the way
    Dreamweaver
    handles variables in SQL queries. These are designed to
    prevent
    malicious attacks through SQL injection. Dreamweaver CS3 uses
    the same
    code as Dreamweaver 8.0.2.
    If I remember correctly, Dreamweaver will automatically
    update all the
    code if you open the Recordset dialog box, make any changes,
    and then
    click OK. If that doesn't work, the safest approach is to
    select the
    Recordset in the Server Behaviors panel, and click the minus
    button to
    remove it cleanly. Then build the recordset again: a
    nuisance, I know,
    but it makes your code more secure.
    When using LIKE in a SQL query, you must always choose Text
    as the data
    type, even if you're using numbers in the variable field.
    This is
    because the SQL specification says that LIKE is for comparing
    strings.
    Dreamweaver 8.0.2 and above now follows the SQL
    specification, whereas
    it didn't before.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Need Help Ordering Photos

    Hello. I am having trouble getting my photos in order on my New Ipod 20G.
    The photos always appear in a different order on the ipod than they do in the window on my pc. I have tried naming in them in order etc, but they are always mixed up when they appear on the ipod. If anyone could explain how to order photos on the ipod, I would greatly appreciate it.
    Thanks.

    Here is one way I discovered to deal with this problem. Make a separate sub-folder under the main folder you use to sync photos with i-Tunes. When you update your iPod it will copy this folder and it's contents. If you have a specific order you want the photos in, use a number or letter prefix in the name or some other sequential naming convention. (for example I used 01_filename.jpg, 02_filename.jpg, etc.) If you start your slideshow from this sub-folder, it will display in descending alpha-numeric order.
    The photos will also show up in the folder the iPod creates by default in its default order, which seems to be first in/first out. I haven't determined whether this means there are two copies of the photo on the iPod or not.
    Hope this helps.

  • Need help ordering pictures and calenders

    When I try to order pictures or calendars from IPhoto nothing happens, I mean nothing… it does not ask me to login, it doesn't bring up the spinning wheel, it doesn't hang or freeze, it’s as if I never clicked the button. I’ve tried using the button near the lower right corner that says “order prints”, I’ve tried using the button from the drop down menu at the top, same result, nothing… any ideas? I have ordered pictures in the past with no problems… no I’m trying to order for Xmas and…!Anyone have any ideas?

    dthrasher:
    Welcome to the Apple Discussions. First delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your User/Library/Preferences folder and try again. If that doesn't help log into another account on your Mac and see if those buttons work over there. Just create a temp library add a few photos and try to order. You can abort the process at any time after you determine whether the buttons work or not.
    If they don't work in the other account you may have to reinstall iPhoto. If you do try a reinstall of iPhoto you'll have to delete the current application and all files with "iPhoto" in the file name that reside in the HD/Library/Receipts folder.
    If they do work in the other account it may be a bad preference file (other than iPhoto's) that's the culprit. Here's how to check that out:
    Trouble Shooting Preferences
    Go to HD/Users/Your_name/Library. Move the Preferences folder (in its entirety) to the Desktop and make a second copy of it so you have Copy A and B. Now try the the process again and determine if problem is fixed.
    If the problem IS fixed, then go to the new Prefs folder that the OS will have created and open it up.
    Open Copy B on the Desktop and select all of the items inside. Drag them into the open new library folder. When the Copy window comes up check the Apply to All check box and then click on the Don't Replace button as seen here. That will keep the new files created and bring back all of the others.
    If the problem is NOT fixed, trash the new Prefs folder and move the intact Copy A folder back to the Library folder .
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Need help ordering custom size prints in iphoto....

    I don't know how to order custom size photos? After I edit photo in constrain tab and type the size i need it doesn't show that available size in kodak menu. Only standard sizes show up like 3x5, 4x6 etc... I need various sizes like 4 3/4 x 4 3/4 for example.
    iMac 1.9 GHz Power PC G5   Mac OS X (10.4.4)  

    HI Plexi,
    As far as I know, there are only the standard sizes available for prints.
    You will have to print the custom sizes with your printer.
    thanks - I'll give your suggestion a try and let you know how it turns out.
    iMac 1.9 GHz Power PC G5   Mac OS X (10.4.4)  

  • Help ordering Windows 7 Upgrade disc 2

    I have a G60-442OM notebook that came with Vista with a Windows 7 upgrade.
    I just performed a system recover on the PC and now I am stuck with Vista as I can not find the second upgrade disc
    Any help?

    Hello themix1019
    Are you saying that when you purchased the notebook, you received a free upgrade to win7?
    If so,  you would have been sent a key to activate the upgrade in your email or you were sent an upgrade disk.
    The key for a physical disk would be in the box the disk came in most likely.
    Either way, downloading a new copy is not a problem. If you don't have the key, then theres a problem. You need the key.
    Let me know  the situation.

  • Help ordering calendar from iPhoto

    Hi,
    I am trying to order a calendar from iPhoto - I have done this successfully for the last 4 years.  This time when I go to order I get a message saying I have recently updated my account information, so I go into my profile and everything looks OK - I even reenter my credit card - and try again.  Sometimes at this point I get an error saying I do not have a valid city/state/zip combination, but it is the same as always.  Sometimes I get through that and try and order the calendar again and I get the original message.
    I don't know if this is an iPhoto error, a print products issue, or an apple ID issue.
    Any thoughts?
    Thanks!

    Sometimes at this point I get an error saying I do not have a valid city/state/zip combination, but it is the same as always.
    The invalid zip code suggests you are ordering from an Apple Print Products store in a foreign country and not your home country.
    Check, if you are connected to the correct Apple Print Products Store:
    iPhoto Preferences > Advanced > Print Products Store
    The country in this setting needs to be the same as the country of your billing address and delivery address.

  • Saved order management in ATG.

    Hi All,
    Please help me understanding in processing the saved order management in ATG.

    below threads will be helpful :
    Order Object Creation
    Order Creation for Anonymous and Registered/Loggedin User

  • PPDS - Product hurestic giving planned  orders six month later

    Dear All
    I m facing a prooblem while executing the product heurisitc in APO-PPDS. Problem is that planned orders are scheduled six month later even though the requirments are in early period. I hv checked the resource capacity and time profile. In addition I hv also run the report /SAPAPO/CRES_CAPACITY_LENGTHEN. Still the orders are postponed.
    Please suggest what can be the possible causes for this error.
    Thnx
    VS

    I faced a similar problem but while creating orders manually in APO. Here is the link to the thread; you may like to refer it if some of the solutions provided would be of help:
    Order created with Delay in RRP3 page
    In my case the Transportation Lead Time + GR Processing time was making the orders shifted in the future...

  • 6230i error message Please Help!

    Hi
    Can anyone help me please? I have a nokia 6230i on Orange network but it has been unlocked to any other network. Everytime I switch the phone on I get an error message saying "check connection settings" Can anyone tell me what this means and how I can get rid of it or what I need to do to get rid of it?
    Cheers

    this means that the phone is trying to connect to something on the internet, maybe an email account or something?
    you can get your settings from the network, by going to this address: http://www.nokia.co.uk/nokia/0,8764,76912,00.html or if you have pc suite you can go to help - order settings

  • Hung during upload, had to force quit - do I re-order?

    Not sure of the status it hung at 27% upload status (the internet connection was and is fine).
    I could not quit aperture while it said I had a book order pending so I had to force quit as there seemed to be no way out.
    Now how do I re-upload? Do I have to go through the Buy Book process again? I have a valid order, how do I re-send the file?

    Question answered:
    Under Help / Ordering Books and Prints in Aperture menu was a link for order status (keyed to my Apple ID). As no order was listed I went ahead and went through the "Buy Book" process again and it went through the upload fine. Followed by an e-mail confirmaion back to me.
    http://www.apple.com/support/aperture/customerservice

  • Apple Cancelled Order - But no refund?

    Hi,
    I am from Maldives. I wanted to buy an iPhone 6 but since the price here is around $300 higher than Apple store, I decided to buy from the online US Apple store, send the package to a freight forwarder and ship it to Maldives. However, I later came to know this is against the policy of Apple. My order was cancelled.
    My Order Number: ******** | Ordered on Dec 21, 2014
    Then got a the mail saying,
    "Thank you for your recent order with the Apple Online Store. We appreciate your business.
    We are unable to complete your order. We do not ship to freight forwarder addresses. Therefore your order has been cancelled. While you may see a pending authorization on your account, you will not be charged and that pending authorization will drop off in accordance with your banks policies. Please contact your bank for an exact timeframe."
    My problem is, since to this day, January 6, 2015, I still haven't received my refund. I have called to the bank (Bank Of Maldives). They have confirmed that it takes 10 working days to receive the refund if the order is cancelled but they have not received the refund.
    Since I do not live in US, I haven't found a way to directly contact Apple. Any help?
    <Personal Information Edited by Host>

    Have you checked with your bank whether the payment was actually taken? What Apple have said is that you will see a 'pending authorization'- this is in effect a pre-notification of a charge, but the charge itself should not be taken. So you need first to confirm whether the charge was actually taken. If it was taken in error you should first notify your bank. Then this page may help: Order Status

Maybe you are looking for

  • TS2090 Apple TV2: HDMI Audio not working

    I know this is a very common problem everyone is facing, and I also tryed everything suggested here: http://support.apple.com/kb/TS2090 and here: http://support.apple.com/kb/TS2090?viewlocale=en_US&locale=en_US ... Nothing worked. I'm using an Onkyo

  • Use of Custom ABAP Function in ABAP Extractor

    We are extracting PSA data out of BW system, and encountering CR/LF errors within text columns coming out of PSA. There is ABAP coding to handle the problem: REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN <I_O_PARAMETER> WITH ' '. REPL

  • Connection between 2 routers across a Switch

    I have a link on for example VLAN 211 and I need devices on VLAN 1 to get access through. How can I do this. The Link line is on VLAN 211 but the switches can only be on VLAN 1 as they are just actng as hubs and VALN 211 cannot be created on them. Th

  • ISync  cannot connect with my Motorola A 1000 phone ... Help needed please.

    My motorola A 1000 phone cannot hook up to my Powerbook G4 ... tried several times .... I checked the iSync supported phone list ... Motorola A 1000 is not supported ... I would really like to use this with my Powerbook ....I tried bluetooth it recog

  • Photos not on my computer are still on iPod and new ones aren't syncing.

    I deleted some photos from my computer and now new photos aren't syncing to my ipod and the ones that I deleted from my computer are still on my iPod- even if I change what folder the photos sync from to a completely different folder.