SQL to get a LOV based on a value range (zips based on zipcode range)

I have a requirement to capture state,county,city and zipcode values based on AR Tax tables. I created an DFF with Input field for State, County and City and corresponding LOVs based on the tax tables. I am not sure how to proceed with zipcode (I am not a FORMS expert, that further makes it complicated :) )
For those who are aware of the tax tables - AR_LOCATION_VALUES and AR_LOCATION_RATES, there are no list of zipcode values. zipcodes are maintained at the city record level as a range FROM_ZIP_CODE and TO_ZIP_CODE. So a CITY record for GA.FULTON.ATLANTA has a from_zip of 30301 and to_zip of 30321-9999. I am not worried of the ( +4 ) values, all I care is the 5 digit zip and zip will increment by 1. For this scenario I want to show each zip code as a value in my LOV..so I want to show 30301, 30302, 30303....30320, 30321. Is there a SQL to generate such LOV based on range?
Any SQL experts out there with ideas?
Thx, Suresh

William Robertson wrote:
Nice, but I think he wants the zip range as 30301 - 30321, discarding the '-9999' (apparently known over there as the '+4' component of the zipcode).Thanks William, i missed out on that detail (though it makes a heck of a lot more sense than generating a LOV with 60,000+ elements :) )
TUBBY_TUBBZ?
with
   parsed_data as
   select
      lower_bound,
      substr(range_string, 1, instr(range_string, '-') - 1) as high_bound
   from
      select
         30301          as lower_bound,
         '30321-99999'  as range_string
      from dual
select
   lower_bound + level - 1
from
   parsed_data
connect by level <= high_bound - lower_bound + 1;
LOWER_BOUND+LEVEL-1
              30301
              30302
              30303
              30304
              30305
              30306
              30307
              30308
              30309
              30310
              30311
              30312
              30313
              30314
              30315
              30316
              30317
              30318
              30319
              30320
              30321
21 rows selected.
Elapsed: 00:00:00.01Would be the proper approach based on having a lower bound and having to parse the upper bound from a range string.
William Robertson wrote:
Now if I had a clue how to use MODEL...You're not alone in that boat :)

Similar Messages

  • List of values (LOV) based on PL/SQL

    Is it possible to create a LOV based on PL/SQL ?
    I want to do this because I have at least 5 LOV based on the same query (when you are using bind variables).
    This is the normal query (ex.: LOV_FREQ_CODES) :
    SELECT c.code ||' - '|| c.description AS display,
    c.code AS return
    FROM codes c,
    code_types ct
    WHERE c.code_type = ct.id
    AND ct.code_type_description = 'Frequency' (should be a Bind Variable)
    Thx

    Look into "Pipelined Table Functions" (http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Table_Functions_Cursor_Expressions/Pipelined_Table_Functions.htm)
    Basically you have your codes tables and a function (get_code). The function is passed a parameter (bind variable). The function then fires a query using the parameter value to render rows which are "pipelined" are a return value of the function. So you LOV query would look like:
    SELECT c.code ||' - '|| c.description AS display,
    c.code AS return
    FROM codes c, TABLE(get_code('Frequency')) ct
    WHERE c.code_type = ct.idMike

  • Creating a LOV based in a Web Service

    Hey guys...
    I need to create a Lov based in a Web Service Result, but in always getting the same error:
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Queries that I'm trying:
    Original Query:
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS'
    Other Query that I tried:
    select imgLocation, imgName from (
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS')
    And I tried creating a view, but I dont know where I have to put this.. Maybe in another process?
    create view as
    select imgLocation, imgName from (
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS')
    Thanks

    Fox,
    I'd start by adding column aliases D and R to the query and see if that helps.
    Greg

  • One select list with multiple LOV's (LOV based on how page was called)

    APEX 4.0.2
    I've a DML form page from a report on which I need a single select list item to have a differing LOV based on how the form page was called.
    The calling page (report), contains an edit link column and a create button. Depending on which is selected, I wish the LOV for my select list item to change. The idea behind this is that if someone creates a new entry, I want to constrain the select list to a subset of rows of a table query populating the LOV. On the other hand, if an existing item is edited, I want the select list LOV containing all rows of a table query populating the LOV.
    What I've tried...
    - Duplicates of select list item each triggered to render based on an arbitrary value set when either "create" or "edit" are selected. This did not work because the item was part of DML and would not allow replication on the same page.
    - Logic in the LOV sql statement controlling which sql was to be run based on an arbitrary value set when either "create" or "edit" are selected. This did not work as logic is not allowed in LOV sql statements.
    Any thoughts? Many Thanks!
    Paul

    Hello Patrick!
    Thanks for responding - Love your captcha plugin!
    Anyway, these are the two dynamic LOV's. The first I have in play right now (when creating new records). I need to have the other for existing record modifications.
    LOV #1
    select stock_no d, stock_no r
    from   [email protected]
    where  status like '%Awaiting Transfer%'
    or     status like '%On Hold%'
    order by 1LOV #2
    select stock_no d, stock_no r
    from   [email protected]
    order by 1As I mentioned, I attempted to use plsql logic in the query to trigger one or the other based on a value set when the user either clicked an edit link or a create button but couldn't get the dynamic LOV to commit with that extra code in it.
    Thanks!
    Paul

  • Second LOV based on First LOV in Oracle APEX tabular Form

    Hi,
    I had created a tabular form in which I am having two LOV's. This form is based on a query.
    I had created a javascript function which internally calls AJAX and populates the second LOV based on the value selected in first LOV when onchange.
    But the issue is, when the user recalls this APEX page to view the details or edit the details, the second LOV shows all the values instead of showing only the values related to first LOV.
    In the second LOV query I am trying to write the below query.
    select function_name fn
    ,function_code_id fci
    from catering_function_codes
    where function_type_id = NVL(#FUNCTION_TYPE_ID#,function_type_id)
    order by to_number(function_code_id)
    in which #FUNCTION_TYPE_ID# is the value of first LOV. But I am getting the below error.
    report error:
    ORA-20001: Error fetching column value: ORA-06550: line 1, column 187:
    PL/SQL: ORA-00911: invalid character
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored
    How can you refer to the Second LOV the value of First LOV in a report based tabular form?
    Kindly let me know if you do not understand the issue.
    Please help me in this issue.
    Thank you
    Regards
    Dev

    Hi Roel,
    Thank you for the quick reply.
    I used the query as given by you. This time it is not giving any error but showing all the values in the second LOV irrespective of what ever value is present in the first LOV
    This is an apex tabular form which is generated by apex based on a query. The controls will be dynamically generated by APEX for each row. How can we hard code the control name to :P99_FUNCTION_TYPE_ID?
    Please help me in this issue. Thank you
    Regards
    Dev

  • Dynamically subsetting a LOV based on a View Object

    Hi,
    Hoping you guys can help out. I am having issues with Partial Page Refresh and Dynamically
    STATUS table ( STATUS_ID NUMBER, STATUS_NAME VARCHAR2(10)) with values 1 = Open, 2 = Won, 3 = Lost
    ACTIVITIES ( ACTIVITY_ID NUMBER, ACTIVITY_NAME VARCHAR2(20), STATUS_ID NUMBER)
    The list of permissible activities is dependent on the value of the Status Id and both are shown as LOV's in the same popup/dialog.
    I've created EO's and VO's for both tables. I've created a query based view object called voPermissableActivities with sql "select * from activities act where act.status_id = :pStatusId " and have set up the bind variables, etc.
    Against the Activities VO I created a LOV for the ActivityId using the voPermissableActivities.
    I've set the autosubmit property of the Status Id LOV to true and created a ValueChangeListener for the Status LOV in the backing bean. I've also set the partialRefresh property of the Opportunity LOV to point to the Status LOV
    In the StatusChange listener I
    1. get the a DCIteratorBinding which points to the view iterator underpinning the two LOV's
    2. using the iterator I get the value of the Status LOV
    3. I then grab a reference to the ViewObject for voPermissableActivities and set the bind variable pStatusId to reflect the value of the Status LOV using the following code snippet
    ViewRowSetImpl vOppRSI = (ViewRowSetImpl) currentRow.getAttribute ( "voAccountOpportunity1");
    ViewObject voOpportunities = vOppRSI.getViewObject();
    voOpportunities.setNamedWhereClauseParam("StatusId", currentRow.getAttribute("StatusId"));
    System.out.println ( "Est. Row Count : "+voOpportunities.getEstimatedRowCount());
    voOpportunities.executeQuery();
    System.out.println ( "VO Query: "+voOpportunities.getQuery());
    I've got a tonne of debugging code in the method and can see the server log accurately reflecting changes at the UI layer - so I know it's working properly - also the estimatedRowCount returns values I would expect to see. However, the values in the LOV based on the voPermissableActivities view are not changing. So, I'm guessing that the LOV does not properly get refreshed !? or at least, the ADF framework does not automatically refresh it. So, I then found the following snippet to pogrammetically refresh the LOV -
    System.out.println ( "Getting ADF Context");
    AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
    System.out.println ( "Calling PPR") ;
    adfFacesContext.addPartialTarget(getLovOpportunityId());
    System.out.println ( "after calling ppr");
    Any ideas? This is driving me crazy !!!

    Cheers Frank,
    That works fine where I have a discrete and manageably small set of potential values - in the snippet I included there were 3 potential values - and it is feasible to prepare three VO's to drive the LOV. However, in the PRODUCTION version of what I'm trying to do I may have many more.
    Any other thoughts?
    One approach I wanted to explore was dynamically creating the VO at run time. Would that work?

  • Need - Search page with LOV based flexfield item as search criteria

    Our requirement is to make a flexfield item as search criteria.
    Flexfield is having 2 segments Applicaiton and Responsibility, where 2nd segment *(Responsibility) is dependent on 1st (Application).*
    Accordingly, an LOV must get displayed for each flex segment in the search panel.
    We tried to create a page having this flex (DFF) item as a search criteria, but cannot proceed to get results in results region - we tried to use both properties in the query region - resultsbasedSearch and autocustomizationCriteria:
    Any ideas how to make a search functionality having LOV based flexfield items in the search criteria?
    Any other suggestions regarding the solution are welcome.
    Thank you very much.
    Regards,
    May B.

    Hi,
    try a SQL query that uses bind variables as follows
    ... where column1 like '%:col1param%' and '%:column2%' like :col2param
    Then in the implementation (session facade) check for null values and add '%' in case a value is null.
    The query in EJB is defined in the entity
    Frank

  • Dynamic LOV based on Current user

    How do i make a dynamic LOV based on the user id of the current user.
    Also how to insert values from a form into a database
    Can anyone please help me out.
    Thanks

    Use portal.wwctx_api.get_user to get the currently logged in userid.
    The simplest example of a form manipulating data is to create the form based on a table. All DML works automagically. You can base your form on a procedure with dummy columns and do your own DML if you wish. Lots more flexibility that way...

  • SQL to get System Time/Date from Access 95

    Is it possible to query Access 95 in SQL to return the system (current) time and date?
    Kinda like a sysDate call would do in Oracle...?

    Won't that only return the date of the most current
    record? I'm talking about the actual system
    date..(The main clock where the dates that get created
    are based on)It returns the system date and time. Just try to see.

  • Sql problem in apex LOV

    I am not able to use this SQL statement for apex LOV, any ideas?
    select username, id
    from abusers
    order by decode(id,0, NULL ,username) NULLS FIRST ;
    I get the following error message:
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Re: How to concatenate two sql statements?

    Hi
    Remove the semi-colon at the end.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Dynamic LOV based on report column

    HI,
    I've a standard report with Two columns. Column1 is standard Report Column and Column 2 is a LOV based on an SQL Query.
    Now I need to filter the LOV (add a where clause) based on the value in the column1.
    For example, consider Column1 as "country" and column2 as "state". so the in column2(LOV), user should see only the list of states belongs to the corresponding country(Column1)
    Please note that the report is based on an SQL query
    Any clue on how to do this.
    I'm using APEX4.1.
    Thanks in advance
    Prasanth

    I think you are looking for this https://forums.oracle.com/forums/search.jspa?threadID=&q=tabular+form+cascade&objID=f137&dateRange=all&userID=&numResults=15&rankBy=10001
    please search the forum before posting a question
    Thanks

  • How to bind value to lov based on the output from other lov

    HI all, i have 2 message choice Lov, i am selected a value from the 1st lov based on this value i am a executing a query, i want to display one of the attribute value from the query result in the second LOV. i am getting the attribute value correctly but i dont know how to bind that(display) in the 2nd LOV(at runtime).

    Read the dev guide LOV section, it should give you details about this implementation.

  • Master Details form (LOV based on Detail Column of Join Condition)

    I have created a master detail form where user_id is joining master and details.
    I have created one dynamic lov based on child user_id in detail block to diplay all user who works under current user.
    Problem : When i want to select Insert detail action in detail block the dynamic lov should read the user_id which is going to be inserted when you press Save button. Means as its not getting populated till one click on save button my lov is not getting refereshed.
    Please advice what should i do.
    Thanks
    Bakulesh

    I solved myself by modifing some guru's script from this forum little bit. I am adding here for feedback or use to any.
    htp.p('<script language="JavaScript1.3">
    function getMstFieldValue(form,fieldName)
    var objName = "";
    var tmp = "";
    var dAction = "";
    var sel_idx = 0;
    var cnt = 0;
    var instance = 0;
    var slicedName;
    var fillData = new Array();
    var blkname;
    for(var i = 0; i < form.length; i++)
    slicedName = form.elements.name.split(".");
    tmp = slicedName[2];
    instance = parseInt(slicedName[3],10);
    blkname = slicedName[1];
    //alert("Fld "+tmp+" blk "+blkname+ " instance "+instance);
    if (!tmp)
    continue;
    objName = tmp;
    if (objName == fieldName && blkname == "MASTER_BLOCK")
    return form.elements[i].value;
    function setDetFieldValue(form,fieldName,value)
    var objName = "";
    var tmp = "";
    var dAction = "";
    var sel_idx = 0;
    var cnt = 0;
    var instance = 0;
    var slicedName;
    var fillData = new Array();
    var blkname;
    for(var i = 0; i < form.length; i++)
    slicedName = form.elements[i].name.split(".");
    tmp = slicedName[2];
    instance = parseInt(slicedName[3],10);
    blkname = slicedName[1];
    //alert("Fld "+tmp+" blk "+blkname+ " instance "+instance);
    if (!tmp)
    continue;
    objName = tmp;
    if (objName == fieldName && blkname == "DETAIL_BLOCK")
    form.elements[i].value = value;
    </script>');
    thanks
    Bakulesh

  • ADF BC selectOneChoice- populating an LOV based on another LOV

    scenario:
    country:country_id, country_nme ViewObj: CityVO
    city: city_id, country_id, country_nme ViewObj:CountryVO
    cc: cc_id, country_id(FK), city_id(FK) ViewObj:CCVO
    i have got two combo boxes(selectOneChoice) displaying
    coutntry LOV which i created by selecting
    base data source:CCVO, list datasource:countryVO
    mapped attribute:country_id, display attrib:country_nme
    similarly,city LOV which i created by selecting
    base data source:CCVO, list datasource:cityVO
    mapped attribute:city_id, display attrib:city_nme
    objective:
    now i need to populate the city LOV based on the country selected.
    i added valueChangeListener on countryLOV so that it will get the country_id and execute view criteria on cityVO
    problem:
    problem is that i can not get country_id value! i explored methods on the selectOneChoice variable accessor and ValueChangeListerner component but no luck!
    as i am displaying the country_nme so i have to use DCIteratorBinding to actually reach to the country_id value.
    this seems to be a tedious way! plus if country selected again it gives nullPointerException on 3rd line:
    DCBindingContainer dcBc = (DCBindingContainer)getBindings();       
    DCIteratorBinding  iter = dcBc.findIteratorBinding("CountryVO1Iterator");    
    Row row = iter.getRowAtRangeIndex(vce.getNewValue().toString()); //[error-prone] first time returns the database row of the selected country record.gives exception on 2nd time
    Q1. is there any direct way of getting country_id, based on the display name?
    Q2. is there any way to refresh the iterator? iter.release(), iter.clear() did not help
    Regards,
    Rabs

    Hi
    This is not possible in Discoverer 4i. The concept of Cacading lists of values was only introduced in Discoverer 10g R2 (10.1.2).
    Now there's a good reason to upgrade :-)
    Best wishes
    Michael

  • Change LOV based on another field value

    I have a need to change the LOV of a page item's select list based on the selection in another page item's select list. So in other words, for a page item that is a select list, I need to use one LOV normally, and a different LOV if the value of a different page item is set to X.
    A dynamic action would be useful here (on change where Select List 1 = x), but I don't know how to take the action of changing LOVsfor Select List 2 based on that action.
    Thanks in advance!
    John

    Good question. Here is more detail. 2 page items are involved here - P23_GEAR and P23_GEAR_TYPE. Normally, my SELECT for my LOV for the page item P23_GEAR is:
    select distinct gear_code d, gear_code r
    from gear_lk
    order by 2
    IF Page Item P23_GEAR_TYPE = 'S' (selected from a select list) THEN I need to use THIS SQL query for the LOV for P23_GEAR:
    select distinct gear_code d, gear_code r
    from season_gear_office_lk
    where season_code = :P23_SEASON
    and field_office_code = :P23_FIELDOFFICE
    order by 2
    So if Page Item P23_GEAR_TYPE = 3, then I have to use a different query for the P23_GEAR page item. And this one is dependent on 2 other page items.
    Where do customers come up with these things?!!!
    Thanks,
    John

Maybe you are looking for

  • ColdFusion 8 - 64-bit in distributed mode?

    We have been running 32-bit in distributed mode since 2004 using the J2EE WAR deployment on JRun 4. With CF8 Updater 1 we would like to migrate to the 64-bit version. Is it possible to run a cluster of two physical servers with ColdFusion clusters on

  • Connecting to a satellite phone

    Hello, I have a satellite phone, a Nera Fleet 33 system installed in my boat. It is 5 years old and offers ISDN like connection in any part of the world. I used to connect it to a Windows XP and Vista PC defining it as a generic dial up modem of 33 k

  • Using QT pro to play videos in full screen

    Can you paly videos purchased through iTunes in full screen with good resolution with QT pro? I bought some episodes of Lost and hate the resolution. Thanks!

  • I can't download iOS 6 on my iPad 2 it always says error ! Why?

    Plz help mere

  • Vision instance - warehouse mgmt system

    where does the warehouse mgmt system exist in the vision system for r12 i have logged in with operations and cannot see anything as i ve understood oracle inventory is different to wms any help? thanks.