Query for finding shortest path

I know nothing about Oracle Spatial. Just want to know if this query is possible using Spatial.
Given the following data for undirected weighted graph,
v1: vertex 1
v2: vertex 2
w: weight between vertices v1 and v2(or, distance of edge)
table name : wgraph
v1  v2  w
k   a    2
m  a    3
k   c    1
k   d    4
c   b    2
h   d    3
c   h    3
h   e    4
e   b    4
m  b    6Can I make a query which gives the shortest path from vertex 'a' to vertext 'e' using Spatial?
If this possible, that query gives the following result. (row-spanning form)
I think this is almost impossible using just a hierachical query.
Any method for this in Oracle Spatial?
spath
a
k
c
b
e
This is not a sort of homework or exam, just my interest.
Thx in advance.
Query Your Dream & Future at
http://www.soqool.com

yes why not! in your case just create a logical network- called LRS Network and insert your vertices in node- table and additional information plus cost in the link table.
you can find ways using by dijkstra and A*

Similar Messages

  • Graphs, finding shortest Path using BFS

    COuld some one give me some lead on how to go about finding shortest path between two nodes on a graph using BFS, Edges are labeled but not weighted. What kind of modification will be need to BFS for this?

    http://en.wikipedia.org/wiki/Breadth-first_search

  • An error occurred while querying for the Webfolders path.

    Hi Guys,
    I have a logic file that runs a stored procedure and dtsx gets to that step it gives an error saying :"An error occurred while querying for the Webfolders path."
    I saw that there were a similar post a while ago, but i am running the package from the DM.
    Any ideas?
    Regards,
    AvdB

    Hi Guys,
    Thanks for the replies. Please have a look at the code and let me know what I am doing wrong.
    'DEBUG(on)
    TASK(ImportAccount,USER,%USER%)
    TASK(ImportAccount,APPSET,%APPSET%)
    TASK(ImportAccount,APP,%APP%)
    TASK(ImportAccount,LOGICFILE,C:\BPC\Data\Webfolders\NewClicks\AdminApp\FINANCE\account_load.lgf)
    TASK(ImportAccount,LOGICMODE,1)
    PROMPT(MESSAGE,"When this package is running, end user functionality will be affected (i.e. data cannot be sent to the database or incorrect numbers can be retrieved from the database while this package is running)")
    TASK(CreateAccount,DESCRIPTION,CreateAccount)
    TASK(CreateAccount,APPSET,%APPSET%)
    TASK(CreateAccount,APP,%APP%)
    TASK(CreateAccount,USERID,%USER%)
    TASK(CreateAccount,PROCESSMODE,4)
    TASK(CreateAccount,DIMENSIONNAME,Account)
    TASK(CreateAccount,SOURCETABLE,mbrAccount_shadow)
    TASK(CreateAccount,BAPPLICATIONPROCESS,1)
    TASK(CreateAccount,BTAKESYSTEMAVAILABLE,1)
    Is there any documentation around this code? It is very difficult to debug something without the relevant documentation.
    Regards,
    Andries

  • Write a query for finding STDDEV for OLAP Cube

    Can anybody post a sample query which will find the standard deviation of sales for each month in the sample GLOBAL OLAP schema for Oracle 11g.
    The OLAP option automatically generates a set of relational views on cubes, dimensions, and hierarchies in Oracle 11g. So how can i write a query for finding the Standard deviation on these views.

    The easiest way to do this is to do this directly within the AW using a custom calculated measure. In AWM11g you can use the 11g custom measure wrapper to execute the STDDEV function:
    olap_dml_expression('function',data type)
    For example
    olap_dml_expression('STDDEV(cube_name, time_dimension_name)',number)
    You can then simply expose this calculated measure as another column in your SQL View and then there is no need to use the SQL equivalent. This means the calculation is performed inside the AW (which is as close to the source data as you can get) ensuring performance of the whole query remains high.
    If necessary you can take this a step further, if required, and wrap the STDDEV calculation within an OLAP DML program that would allow you to manipulate the status of time within the calculation. For example, you may want the STDDEV calc to only take into account the last 12 time periods rather than all time periods currently in status.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • ACO for finding best paths on a graph.

    hello,
    i am trying to use aco alg to print shortest path from a specified source node to a destination node. i have created a graph where i have all the vertices (array of strings) and edges(neighbours) stored. I am trying to get the ants to trail randomly on the connected edges from start to dest and then return the route.please can someone give me some advice??.
    my code is as follows,...
    public class ACOLevel7 {
         private static myGraph g = new myGraph();
         public static void main(String[] args) {
              String start = "";
              String finish = "";
         ACOLevel7 p = new ACOLevel7(g,start,finish);
    /* instance variables */
         protected String[] names = g.getNames();
         protected boolean[] Edges;
         private static String istart;
         private static String idestination;
         private static int iAntSteps = idestination.length();
    private static int iColonySize = 10000;
    private static double iPheromoneStrength = 1.8d;
    private static int iEvaporationSpan = 100;
    private static double iEvaporationRate = 0.98d;
    private boolean[][] graphEdges;
    private Random iRandom = new Random();
    /* constructor */
    public ACOLevel7(myGraph g, String start, String finish) {
         Map map = new Map();
         istart = start;
         idestination = finish;
         graphEdges = g.getEdges();
         if(g.validStartAndFinish(istart,idestination)){
         double bestScore = -1;
         System.out.println("Level 7");
         System.out.println(">>> Here is your route planner! <<<");
         for (int i = 0; i < iColonySize; i++) {
         Ant ant = new Ant();
         ant.wander(map, iAntSteps);
         double score = calcScore(ant.getTrail());
         ant.dropPheromones(score);
         if (score > bestScore) {
         System.out.println(String.format(" %5d %s %4.2f", (new Object[]
         { new Integer(i), ant.print(), new Double(score) })));
         bestScore = score;
         (map).tick();
         System.out.println("\n>>> finished <<<");
         else {
              System.out.println("\n>>> start or finish not in names array<<<");
    double calcScore(AntTrail trail) {
    double score = 0;
    for (int i = 1; i <= iAntSteps; i++);
    //      Gets the next Node to travel to
    I NEED HELP HERE!!
         String String = idestination.substring(i - 1);
    return (score / 55d) * iPheromoneStrength;
    private class Map {
    /* instance variables */
    HashMap Map = new HashMap();
    Location iStart = new Location();
    /* constructor */
    public Map() {
    Map.put(iStart.getKey(), iStart);
    public Location start() {
    return iStart;
    public ArrayList to(Location fromHere) {
    // generate every vertex location that is valid from here
    ArrayList newLocations = new ArrayList();
    for (int i = 0; i < istart.length(); i++) {
    Location n = new Location(fromHere,
    String.valueOf(istart.String(i)));
    if (!Map.containsKey(n.getKey()))
    Map.put(n.getKey(), n); // add to the map
    else
    n = (Location)Map.get(n.getKey()); // existing location
    newLocations.add(n);
    return newLocations;
    public void tick() {
    Iterator i = Map.entrySet().iterator();
    while (i.hasNext())
    if (((Location)((java.util.Map.Entry)i.next()).getValue())
    .evaporate())
    i.remove();
    private class Location {
    private String iKey;
    private String iname;
    private double iPheromones = 1;
    private int iEvaporation = iEvaporationSpan;
    /* constructor: start location */
    public Location() { istartt = ""; }
    /* constructor: from another location */
    public Location(Location from, String names) {
    iKey = from.getKey() + "|" + names;
    istartt = names;
    public String getKey() {
    return iKey;
    public String getName() {
    return istartt;
    //public String getidestt(){
    public void dropPheromones(double d) {
    iPheromones += d;
    iEvaporation = iEvaporationSpan; // reset the evaporation counter
    public double getPheromones() {
    return iPheromones;
    public boolean evaporate() {
    iPheromones = iPheromones * iEvaporationRate;
    return --iEvaporation == 0;
    private class Ant {
    private AntTrail iTrail = new AntTrail();
    public void wander(Map map, int steps) {
    iTrail.addStep(map.iname());
    for (int i = 0; i < steps; i++)
    step(map);
    private void step(Map map) {
    ArrayList choices =map.to(iTrail.current());
    Location next = null;
    double span;
    // sum the available span
    span = 0;
    Iterator i1 = choices.iterator();
    while (i1.hasNext())
    span = span + ((Location)i1.next()).getPheromones();
    // choose an index value
    double index = iRandom.nextDouble() * span;
    // find the location within the span with this index
    span = 0;
    Iterator i2 = choices.iterator();
    while (i2.hasNext()) {
    next = (Location)i2.next();
    span = span + next.getPheromones();
    if (index < span) break;
    // add the chosen location to the trail
    iTrail.addStep(next);
    public AntTrail getTrail() {
    return iTrail;
    public void dropPheromones(double score) {
    iTrail.dropPheromones(score);
    public String print() {
    return iTrail.print();
    private class AntTrail {
    private ArrayList iTrail = new ArrayList();
    public void addStep(Location n) {
    iTrail.add(n);
    public Location getStep(int index) {
    return (Location)iTrail.get(index);
    public Location current() {
    return getStep(iTrail.size() - 1);
    public void dropPheromones(double score) {
    Iterator i = iTrail.iterator();
    while (i.hasNext())
    ((Location)i.next()).dropPheromones(score);
    public String print() {
    String s1 = "";
    Iterator i = iTrail.iterator();
    while (i.hasNext()) {
    String s2 = ((Location)i.next()).getName();
    if (!s1.equals("") && !s2.equals("")) s1 += "-";
    s1 += s2;
    return s1;
    }

    Presumably the thing that you want to do is to choose a path from a small number of alternatives based on some continually changing probability distribution (based on your Phermone strength)
    Consider the simple case, where you choose between two paths, one with weight 17 and one with weight 5.
    You sum the two weights, T = 17+5 = 22
    You generate a random number between 1 and 22
    and if it is less than 17 you choose the first path and if it is greater you choose the other path. Given the uniform distribution of your random numbers you have choosen the first path 17/22nds of the time.
    In more general terms, without integer weights
    You have a collection of n weights, Wi, you total them, T
    You choose a random number, R, between zero and T (i.e. choose a random number between 0 and 1 and multiply by T) This effectively normalizes your distribution.
    Then you subtract W1 from R. If the result went below zero your value was less than W1 so you take path1, if not, subtract W2 from R (R has already been reduced by W1 so what you are testing is whether your original random number was between W1 and W2) if it goes below zero take path 2, ...
    Go through the weights in order until you get a result below zero.
    This is the classical algorithm to select an alternative from a small number of possible alternatives where each alternative has a known probability of being selected.
    I hope that helped. I did not actually read your code to see what you are doing, I just looked at the comment prior to the I NEED HELP HERE and made a guess as to what your problem was.
    In the future, you will be more likely to get help quickly if you summarize your problem rather than just posting a wad of unreadable code.
    So if I answered your question, your welcome, if not, well perhaps you can take a little more effort to explain your problem so that we don't have to work so hard to figure out what you want.
    I am assuming that you know about the Random class and actually know how to generate simple random numbers. You see, you really didn't tell us what your problem is and where you need help, and thus force us to make assumptions.

  • Hoc can u find shortest path from a Map of a building

    i have to find a shortest path on a map of building how should i do it any good idea, i m newbee plz help me here

    This is not the proper forum for that sort of question. You should define your problem more clearly and post it to the New to Java forum

  • Query For Finding Yearly Opening and Closing Balance for All the Items

    Hi Experts,
    I am working on Query Based Report for finding the Yearly Opening and Closing Stock for all the Items
    i will give yearwise selection and I want opening and closing stock in between that years
    Warm Regards,
    Sandip Kokate
    Edited by: Sandipk on May 20, 2011 1:58 PM

    Hi,
    Declare @SDate DateTime
    Declare @EDate DateTime
    Declare @Whse nvarchar(10)
    Set @SDate= (SELECT min(F_RefDate)  FROM  OFPR T1 where  T1.[Name] ='[1%]' )
    Set @EDate= (SELECT max(T_RefDate)  FROM  OFPR T1 where  T1.[Name] ='[%1]' )
    Set @Whse=(Select Max(s2.Warehouse) from OINM S2 Where S2.Warehouse = '[%2]')
    BEGIN
    Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,
    sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
    ((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,
    (Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM
    from( Select N1.Warehouse, N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
    as OpeningBalance, 0 as INq, 0 as OUT From dbo.OINM N1
    Where N1.DocDate < @SDate and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,
    N1.Dscription Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance,
    sum(N1.inqty) , 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <= @EDate
    and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription
    Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT
    From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <=@EDate and N1.OutQty > 0
    and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription) a, dbo.OITM I1
    where a.ItemCode=I1.ItemCode
    Group By a.Itemcode Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0 Order By a.Itemcode
    END
    I hope this will work for you.
    In above query you can also user OFPR.Code, OFPR, Category OFPR.Indicator instead of OFPR.Name.
    Regards
    Vaibhav Anharwadkar
    Edited by: Vaibhav Ancharwadkar on May 24, 2011 9:23 AM

  • Need helping in writing query for finding percentage of duration

    Can any one please help in writing query for this.
    The table is like this :-
    ID     Region     Month     Duration
    I1 R1     Jan     80
    I2     R2     Jan     70
    I3     R1     Jan     70
    I4     R3     Jan     40
    I5     R1     Feb     80
    I6     R2     Feb     30
    I7     R3     Mar     100
    I want to write a query to find
    % of duration for each and every region against each and every month.
    Please help in solving this query. I am in urgent need of this.
    Thanks in advance.

    I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
    Nicolas.

  • Query for Finding the Daily Cumulative Production Total

    Hi Experts,
    I want Query based Report for finding Daily Cumulative i.e Running Production Total
    Suppose Yesterdays Production for Item A0001 is 20 and Todays Prodction is 20 then it will show 50 but it shout be datewise selection.
    Warm Regards,
    Sandip Kokate

    Hello
    Report Scenario as follow
    Item Code    Item name    Todays Producion     Yesterdays Production   Total Productio
    A001           Computer     20                                    20                                  40
    A002           Mouse          10                                    05                                  15
    A003           CPU              15                                    05                                  20
    This is Exact Report
    Regards,
    Sandip Kokate

  • Recursive query for finding parents and children against two tables

    Hi I have two tables where the data is stored hierarchially.
    I have found using connect_by, level and other oracle functions doing its job when the data is in one table.
    Can I traverse against two tables by using the same oracle functions.
    My Table A can go 2 levels deep in my hierarchy and level 3 and so forth has to be done against a different table.
    Appreciate your insight..
    Thanks in advance

    The number of levels that I can traverse in the first table is dynamic (sometimes 2 levels and sometimes 3 levels and actually no level limit) and then has to dynamically start looking at second table for finding any more levels in the other table.
    I was able to implement them seperately and union them.
    I was more looking for a comprehensive solution to reduce the number of lines that I have to maintain...
    Thanks in advance
    Edited by: user566193 on Jan 15, 2010 1:58 PM

  • Query For Finding Revised PO Amout in Purchasing in Each Revisions

    Can anybody please tell me how
    can i write a query for Extracting
    individual PO amounts in each revisions of a
    PO from PO_LINES_ARCHIEVE_ALL..
    ie FOR Each revisions of a PO What was the total PO Amount
    Regards
    Binu

    Hi Geoff,
    You can use the ROW_NUMBER and CASE Functions to acheive this. Here with , i have give u a small idea with an ex:
    Qry :
    B.ItemCode,SUM(B.PO1)[PO1],SUM(B.POQty1)[POQty1],SUM(B.PO2)[PO2],SUM(B.POQty2)[POQty2] From
    select Itemcode
    CASE when Sno=1 Then DocNum End [PO1]
    CASE When Sno=1 Then Qty End [POQty1]
    CASE when Sno=2 Then DocNum End [PO2]
    CASE When Sno=2 Then Qty End [POQty2]
    From(
    Row_Number() Over (Order By Opor.Docnum) [Sno], Opor.DocNum,POr1.ItemCode,sum(POr1.Quantity)[Qty] from OPOR join Por1 on Opor.DocEntry=por1.DocEntry
    ItemCode='20002' group by oPor.DocNum,por1.ItemCode
    A where A.Sno<=2)B Group By B.ItemCode
    Result :-
    ItemCode  PO1         POQty1           PO2            POQty2
    20002       18            1.000000         19                10.000000
    Thanks,
    Karthikeyan.P

  • Query for Find Mode Fails-AutoGenerated WHERE clause missing quotation mark

    Using Oracle JDev 10.1.3.2. In 'Find Mode' the query execution fails.
    The error shown below is caused by the WHERE clause statement. The column name is quoted in the database but the code generated by the ADF framework does not use quotes. As a result the column name is illegal. Is there a way to hint to the ADF framework to ALWAYS use quotation marks?
    (oracle.jbo.SQLStmtException) JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT "PLATE","WROW","WCOL","WFIELD","AVGNUC.NUC_CELL_INTENSITY","MEDNUC.NUC_CELL_INTENSITY","AVGORG.INCLUSION_BCKG_INTE","MEDORG.INCLUSION_BCKG_INTE","MEDORG.COUNT","MEDORG.SPACING","MEDORG.NEIGHBOR_COUNT" FROM ICSUMSTAS_1888_295) QRSLT WHERE ( ( (MEDORG.COUNT >0) ) )

    It is true that these are not the most column 'friendly' names, but they are what they are. In the database these columns are quoted and they must be so in order for the query to work correctly.
    The suggestion of directly manipulating the View Criteria is a good one and I have implemented a solution based on it but it's cumbersome. Here is how it works:
    First, use the default query mode UI to add new View Criteria. If you were to execute the query at this point it would fail due to the columns names not being quoted. So, instead, implemented my own execute query button that first uses the View Criteria to create a properly quoted WhereClause for the ViewObject.
    I then reset the ViewCriteria (or they will interfere with the WhereClause), set the custom constructed WhereClause on the ViewObject, and re-execute the query. The cumbersome part is that I have to create my own parser for user input to write a valid WhereClause. And when the user uses query mode again the previously set ViewCriteria have been reset (which is annoying, and not the typical query mode behavior which might confuse the user)
    below are some of my code snippets:
    * This action is triggered by clicking the FIND button on the UI.
    * It uses a combination of the ViewCriteria default UI and custom code that processes
    * user input into a whereClause for the ViewObject
    private void jbFind_actionPerformed(ActionEvent e) {
    jbAddRow.setEnabled(false);
    //reset old where clause
    System.out.println("OLD WHERE:"+myView.getWhereClause());
    myView.setWhereClause(null);
    String customWhere=getCustomWhere();
    /* The case for null and blank View Criteria is tested below
    * when there are blank ViewCriteria the sequence (--) is generated from getCustomWhere
    * Note the use of contains instead of equals
    * The use of equalIgnoreCase etc for unexplained reasons seem to fail to detect when customWhere is (--)
    if(customWhere==null||customWhere.contains("(--)")){
    return;
    }else{
    /*remove ViewCriteria because they can not handle special Column names
    * That's why we go into the trouble of creating our own find function
    myView.getViewCriteria().removeAllElements();
    myView.setWhereClause(customWhere);
    myView.executeQuery();
    jUNavigationBar1.doAction(JUNavigationBar.BUTTON_EXECUTE);
    jTable1.revalidate();
    private String getCustomWhere(){
    StringBuffer custom=new StringBuffer();
    ApplicationModule am = (ApplicationModule) panelBinding.getApplication().getDataProvider();
    DCJboDataControl jbodc = new DCJboDataControl(am);
    JUIteratorBinding iterBinding = new JUIteratorBinding(jbodc,myView );
    int criteriaCount=iterBinding.getViewCriteria().getRowCount();
    //Validation when no ViewCriteria are defined
    if (criteriaCount==0){
    System.out.println("ViewCriteria Count: "+criteriaCount);
    return null;
    }else{
    System.out.println("ViewCriteria Count: "+criteriaCount);
    int attr=iterBinding.getViewCriteria().getCurrentRow().getAttributeCount();
    int criteriaRows=iterBinding.getViewCriteria().getAllRowsInRange().length;
    String[] attrNames=iterBinding.getViewCriteria().getCurrentRow().getAttributeNames();
    for (int r=0;r<criteriaRows;r++)
    {custom.append("(");
    for (int k=0;k<attr;k++){
    if(iterBinding.getViewCriteria().getRowAtRangeIndex(r).getAttribute(k)!=null){
    custom.append("(\""+attrNames[k]+"\"");// LIKE '"+(String)iterBinding.getViewCriteria().getRowAtRangeIndex(r).getAttribute(k)+"') AND ");
    //trim white space
    String attrK=((String)iterBinding.getViewCriteria().getRowAtRangeIndex(r).getAttribute(k)).trim();
    String qual=attrK.substring(0,1);
    if(qual.equalsIgnoreCase(">")||qual.equalsIgnoreCase("<")||qual.equalsIgnoreCase("=")||qual.equalsIgnoreCase("!")){
    custom.append(" "+qual+"'"+attrK.substring(1)+"') AND " );
    }else{
    custom.append(" LIKE '"+(String)iterBinding.getViewCriteria().getRowAtRangeIndex(r).getAttribute(k)+"') AND ");
    }custom.append("--");
    custom.append(")");
    custom.append(" OR ");
    }//end criteria rows
    custom.append("--");
    //now need to remove terminal AND and OR tagged with --
    String cleanWhere=custom.toString().replaceAll("AND --","").replaceAll("OR --","");
    System.out.println("NEW CUSTOM WHERE: "+cleanWhere);
    return cleanWhere;
    }

  • GREP query for find/change operation

    Hi everyone,
    In the following line, there's a comma after the first name. This type of formatting is repeated hundreds of times on a number of pages so I need to use a GREP find/change query to remove the comma after the first name and replace it with a space.
    Firstname,Lastname,State
    I wondered if something could tell me what the GREP code would be?
    Appreciate any assistance.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    ..  it's also doing it for the second comma
    That's impossible. You must have entered something else than Scott's code.

  • Query for finding data during special holidays

    Hi, i have a table for special holidays that looks like this:
    PROFILE_DAY
    VAR_DATE
    REGULAR_HOLIDAY
    1/1/2013
    H_WEEK_THURSDAY
    3/28/2013
    H_WEEK_FRIDAY
    3/29/2013
    REGULAR_HOLIDAY
    12/24/2013
    REGULAR_HOLIDAY
    12/25/2013
    REGULAR_HOLIDAY
    12/31/2013
    And another table (LOAD_PROFILE_TEST), which contains LOAD_PROF1 values from (TIME_EQ) 0 to 24 at intervals 0.25 for (PROFILE_DAY) MONDAY to SUNDAY including REGULAR_HOLIDAY, H_WEEK_THURSDAY and H_WEEK_FRIDAY.  All in all, this table contains 970 records (97 records between 0 to 24 with interval of 0.25 per PROFILE_DAY, with 10 distinct PROFILE_DAY).
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    REGULAR_HOLIDAY
    11.47
    0.25
    REGULAR_HOLIDAY
    11.27
    0.5
    REGULAR_HOLIDAY
    11.3
    0.75
    REGULAR_HOLIDAY
    11.08
    0
    MONDAY
    11.27
    0.25
    MONDAY
    11.33
    0.5
    MONDAY
    11.18
    Now, I have this query to update value of LOAD_PROF2 of the said table whenever parameters V_DATE_OUT & V_DATE_IN is entered:
    UPDATE LOAD_PROFILE_TEST
         SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
         WHERE  UPPER(PROFILE_DAY) IN (select UPPER(to_char(:V_DATE_OUT + (level-1), 'fmDAY'))
                       from  dual
                       connect by level <=  :V_DATE_IN - :V_DATE_OUT  + 1
    where :LOAD_DIFF is a certain pre-determined value.
    This query works fine if i am trying to update regular days from MONDAY to SUNDAY.  What i would like to do is to determine if the two parameter dates, V_DATE_OUT & V_DATE_IN would fall under any of the holidays on the first table LOAD_PROFILE_TEST, then update only those rows.  For example, V_DATE_OUT = 12/02/2013, Monday and V_DATE_IN = 12/06/2013, Friday.  The query above would update the values of LOAD_PROF2 for PROFILE_DAY -  MONDAY to FRIDAY, corresponding to dates 12/02/2013 and 12/06/2013.  If however, V_DATE_OUT = 12/23/2013, Monday and V_DATE_IN = 12/27/2013, Friday, this should update the rows corresponding to PROFILE_DAY - MONDAY for 12/23/2013, THURSDAY for 12/26/2013, FRIDAY for 12/27/2013, and REGULAR_HOLIDAY for the dates 12/24/2013 and 12/25/2013 since these two are included in the first table (table of holidays).  This same scenario will work the same way when V_DATE_OUT  and/or V_DATE_IN fall in the dates 3/28/2013 and 3/29/2013.  All other dates not included in the table for special holidays will be treated according to the day they fall on (Monday thru Sunday).  I hope my point is clear.  Thank you in advance.

    Thanks for your reply.  Firstly, I am using Forms [32 Bit] Version 10.1.2.0.2 (Production).  I will try to explain a little further but I don't know if i can give the exact details of the tables since this would be voluminous. First i have a table REG_HOLIDAYS, whcih contain the following:
    PROFILE_DAY
    VAR_DATE
    REGULAR_HOLIDAY
    1/1/2013
    H_WEEK_THURSDAY
    3/28/2013
    H_WEEK_FRIDAY
    3/29/2013
    REGULAR_HOLIDAY
    12/24/2013
    REGULAR_HOLIDAY
    12/31/2013
    REGULAR_HOLIDAY
    12/25/2013
    Now i have another table LOAD_PROFILE_TEST which i will simplify just to show what i wanted to do:
    CREATE
    TABLE LOAD_PROFILE_TEST
    TIME_EQ
    NUMBER (5, 2),
    PROFILE_DAY
    VARCHAR2 (15 BYTE),
    LOAD_PROF1
    NUMBER (6, 2), 
    LOAD_PROF2
    NUMBER (6, 2)
    Here are the sample values of this table:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    0
    Tuesday
    2.1
    0
    Wednesday
    2.3
    0
    Thursday
    2.5
    0
    Friday
    2.2
    0
    Saturday
    2.4
    0
    Sunday
    2.3
    0
    Regular_holiday
    1.9
    0.25
    Monday
    2.1
    0.25
    Tuesday
    2.1
    0.25
    Wednesday
    2.4
    0.25
    Thursday
    2.2
    0.25
    Friday
    2.5
    0.25
    Saturday
    2.3
    0.25
    Sunday
    2.3
    0.25
    Regular_holiday
    2.5
    However, in the actual table, TIME_EQ will start with 0 until 24 with interval of 0.25 (i.e 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, ...23.5, 23.75, 24).  So for a PROFILE_DAY of 'Monday', there will be 97 rows corresponding to TIME_EQ of 0 to 24.  The same is true for Tuesday, Wednesday until Sunday including Regular_holiday.  All in all, this table would contain 776 rows.  LOAD_PROF1 values are random values initally inputted with PROFILE_DAY and TIME_EQ.
    The first goal is to UPDATE this table (LOAD_PROFILE_TEST) by updating the column LOAD_PROF2 by adding a certain parameter value, :LOAD_DIFF, say 0.1. Now, i will have two scenarios to show what i would like to happen.  First, i have two date parameters :V_DATE_OUT and :V_DATE_IN.
    First Case, V_DATE_OUT = 12/15/2013 (Monday); V_DATE_IN = 12/22/2013 (Sunday)
    I will have this query to update said table:
    UPDATE LOAD_PROFILE_TEST
           SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
       WHERE   UPPER(PROFILE_DAY) IN (select UPPER(
                                                                     to_char(
                                                                          :V_DATE_OUT + (level-1),
                                                                          'fmDAY'))
                                                                    from  dual
                                                     connect by level <=
                                                           :V_DATE_IN - :V_DATE_OUT  + 1);
    The output of this query would be:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    2.1
    0
    Tuesday
    2.1
    2.2
    0
    Wednesday
    2.3
    2.4
    0
    Thursday
    2.5
    2.6
    0
    Friday
    2.2
    2.3
    0
    Saturday
    2.4
    2.5
    0
    Sunday
    2.3
    2.4
    0
    Regular_holiday
    1.9
    0.25
    Monday
    2.1
    2.2
    0.25
    Tuesday
    2.1
    2.2
    0.25
    Wednesday
    2.4
    2.5
    0.25
    Thursday
    2.2
    2.3
    0.25
    Friday
    2.5
    2.6
    0.25
    Saturday
    2.3
    2.4
    0.25
    Sunday
    2.3
    2.4
    0.25
    Regular_holiday
    2.5
    Since, 12/15/2013 up to 12/22/2013 is from Monday to Sunday without having a particular day included in the first table, REG_HOLIDAYS, therefore all the rows with Monday to Sunday are updated.
    Second Case, V_DATE_OUT = 12/23/2013 (Monday); V_DATE_IN = 12/29/2013 (Sunday)
    Take note that 12/24 and 12/25 are included in the first table, REG_HOLIDAYS, therefore i need a query so that this would be my output afterwards:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    2.1
    0
    Tuesday
    2.1
    0
    Wednesday
    2.3
    0
    Thursday
    2.5
    2.6
    0
    Friday
    2.2
    2.3
    0
    Saturday
    2.4
    2.5
    0
    Sunday
    2.3
    2.4
    0
    Regular_holiday
    1.9
    2.0
    0.25
    Monday
    2.1
    2.2
    0.25
    Tuesday
    2.1
    0.25
    Wednesday
    2.4
    0.25
    Thursday
    2.2
    2.3
    0.25
    Friday
    2.5
    2.6
    0.25
    Saturday
    2.3
    2.4
    0.25
    Sunday
    2.3
    2.4
    0.25
    Regular_holiday
    2.5
    2.6
    As can be seen, since 12/23/2013 up to 12/29/2013 is from Monday to Sunday, rows with Monday upto Sunday should be updated, HOWEVER, since 12/24 and 12/25 which falls on a Tuesday and a Wednesday also were declared as holidays (included in the REG_HOLIDAYS table),  instead of updating rows with PROFILE_DAY of Tuesday and Wednesday, the query should instead update rows with Regular_holiday as PROFILE_DAY and leave as is the rows with Tuesday and Wednesday.  Additional note, days declared in the REG_HOLIDAYS table with PROFILE_DAY of Regular_holidays are treated as DISTINCT as in the case of 12/24 and 12/25.
    The query you gave me gives the correct value if the involved days between V_DATE_OUT and V_DATE_IN is from Monday to Sunday only, otherwise it always gives Regular_holiday only regardless of the other dates queried.  As in the first case above, it would give Monday to Sunday (correct) but for the second case, it will only give Regular_holiday, the other days (Monday, Thursday, Friday, Saturday and Sunday) was not outputted.
    I hope this became clearer since i will still be needing this for another query which i will inquire again after resolving this issue.  Thanks a lot for your help.

  • Query for finding Unpacked Item

    Hi
    I created a Sales Order and Manual Packing is completed.
    Example :
    In a Sales order , having different 25 items, I missed to pack one item in the sales order.
    I wanted to write a query (report) to find the item which is packed and unpacked, group by the sales order.
    Pls help me out in the table , column name, status of the column.
    If you have a sample query,pls do share with me.
    Regards
    Yram

    I don't have a , But you can join tables like this:
    See delivery lines associated with order line (source_type=OE)
    check respective parent delivery line (source_type=WSH) --This is delivery line created with respect to LPN
    join given delivery with wms_license_plate_numbers to find LPN

Maybe you are looking for