Connect by Level using count value from record collection

Hello:
PROBLEM:
) y,(select rownum MonthNo from dual connect by level <= Cnt)
Causes ORA-00904 Invalid identifier. Why can’t I use “Cnt” from my main query as using a constant works?
The count value is determined for each date range in How can I return the records I need?
Thanks, Sidney
BACKGROUND:
I need to be able to display a list of tax returns to my users and the status of those returns. Physical returns do not exist so it is necessary to create the data records dynamically using appropriate selects. This is not difficult and I thought I could then just use a connect by level to give me the date information so I could calculate and display the individual returns. However oracle is giving me an ORA-00904 when I try to send the “Cnt” value to connect by level. Everything works fine when I provide a constant instead of “CNT”. The “CNT” value is determined by a complex process that computes the start and stop dates for multiple return types, etc. as well as the number of periods and filing frequency. The data has to be dynamically generated using a master record which then yields the coding history from which my basic record collection is selected. Here is the result of that process:
TaxpayerNo,TaxClass,TaxCode,FilingFequency,StartDate,StopDate,Cnt,Frequency
10 S 1 M 6/1/2007 11/30/2008 18 12
10 S 2 M 11/30/2008 9/30/2009 10 12
10 S 2 Q 11/30/2010 8/18/2011 3 4
10 L 8 A 6/1/2007 9/30/2009 3 1
10 L 8 A 11/30/2010 8/18/2011 1 1
From this data, I need a record for each individual month,quarter,etc. ie:
10 S 1 M 6/1/2007 11/30/2008 18 12 6/1/2007
10 S 1 M 6/1/2007 11/30/2008 18 12 7/1/2007
10 S 1 M 6/1/2007 11/30/2008 18 12 8/1/2007
10 S 1 M 6/1/2007 11/30/2008 18 12 9/1/2007
10 S 2 M 11/30/2008 9/30/2009 10 12 11/30/2008
10 S 2 M 11/30/2008 9/30/2009 10 12 12/30/2008
etc.
DOES NOT WORK
select y.*,MonthNo,Add_Months(StartDate,MonthNo*Frequency) from (
select x.*,
(case when FilingFrequency = 'M' then Ceil(Months_Between(StopDate,StartDate))
when FilingFrequency = 'Q' then Ceil(Months_Between(StopDate,StartDate)/3)
when FilingFrequency = 'A' then Ceil(Months_Between(StopDate,StartDate)/12)
else 0
end) Cnt,
(case when FilingFrequency = 'M' then 1
when FilingFrequency = 'Q' then 3
when FilingFrequency = 'A' then 12
end) Frequency
from (
... complex code to calculate the values of the start and stop dates needed above...
) x
) y,(select rownum MonthNo from dual connect by level <= Cnt)
ERROR MESSAGE
This returns ORA-00904: "CNT": Invalid Identifier. I don't get an error if I use a constant:
WORKS USING A CONSTANT BUT MUST HAVE THE ACTUAL CNT VALUE
... Same code to generate data ...
) y,(select rownum MonthNo from dual connect by level <= 3)
How can I get this to work using the "CNT" value instead of a constant?

A technique like this should fix your problem.
TUBBY_TUBBZ?with data (col1, cnt) as
  2  (
  3    select 1, 3 from dual
  4      union all
  5    select 2, 2 from dual
  6  )
  7  select
  8    d.col1,
  9    t.column_value
10  from
11    data  d,
12    table(cast(multiset(select level from dual connect by level <= d.cnt) as sys.OdciNumberList)) t;
              COL1       COLUMN_VALUE
                 1                  1
                 1                  2
                 1                  3
                 2                  1
                 2                  2
5 rows selected.
Elapsed: 00:00:00.00
TUBBY_TUBBZ?As opposed to what you have now, which is basically this
TUBBY_TUBBZ?with data (col1, cnt) as
  2  (
  3    select 1, 3 from dual
  4      union all
  5    select 2, 2 from dual
  6  )
  7  select
  8    d.col1,
  9    level
10  from
11    data  d
12  connect by level <= d.cnt;
              COL1              LEVEL
                 1                  1
                 1                  2
                 1                  3
                 2                  2
                 1                  3
                 2                  1
                 1                  2
                 1                  3
                 2                  2
                 1                  3
10 rows selected.
Elapsed: 00:00:00.00
TUBBY_TUBBZ?

Similar Messages

  • Can you use the value from a numeric indicator in a numeric control?

    Hi!
         I have to develop a code where I have to find the maximum value of a waveform and draw a line at 50% of the value. So I chose to find the amplitude of say 10 cycles of waveforms and found the maximum value out of the amplitudes. 
    But my real problem is, I have to use the maximum amplitude value that I get from the max. array VI and put it back in program to calculate the 50% value. 
    So is it possible to use the value from a numeric indicator and put it in a numeric control? Like in MATLAB or C, you give the variable a name and use it later to do any computations. Is it possible to do something similar in LabVIEW? 
    Solved!
    Go to Solution.

    Hi!
         Thank you very much for taking some time out. I have been trying to do this since 2 months and I am stuck right where I am.
    The situation is, I have to calculate the amplitude of the irregular waveform for a few trials and then find the maximum amplitude out of the trials and display a line at whatever % of amplitude the user chooses. I tried using property nodes but I am getting Error 1055 for some unknown reason. Then I decided to draw the line using DC offset but it turns out it calculates the amplitude each time and so the line keeps dancing everytime. Now my challenge is to have the amplitude calculated for say, 20 loops and then calculate the max from that. I ran out of ideas so I am posting here. I am using LabVIEW version 8, and I'll upload a few of my attempts. I hope I am not troubling you'll much.
    Attachments:
    amplitude display.vi ‏217 KB
    amplitude display 1.vi ‏148 KB
    Using property node.vi ‏56 KB

  • How to get counter value from Historian

    Hi Experts,
    We have got a scenario to keep the number (counter) to see how many time a value of tag have been changed.
    For Example:
    If the values change from 1 to 0 and  0 to 1 for 25 times in a minute. We would like to get this number (25) from Historian (Wonderware).
    Currently we are not using any Pco to fetch the value from Hisotrian since we are able to fetch the tag values from Historian database through SQLConnection.
    I would like to know if we introduce Pco, will that help us to get this counter value.
    We are working on MII 15.0 version.
    Any help of this very much appreciated.
    Thanks
    Shaji

    Hi Shaji,
    PCo OPC DA does not support  PCoQuery TagAggregateMode as it only has access to Current Values of OPC Tags, because OPC DA only provides Current Value access.
    I know it is possible to execute SQL queries against the Wonderware Historian to retrieve counts aggregates, but don't have the details handy. Recommend that you deploy the InSQLPCo Data Server in MII and try using the PCoQuery TagAggregateMode method to retrieve the Counts aggregate first.
    Regards, Steve

  • How to get counter values from pci 6221 card?

    Hii
     I am using PCI 6221 card .. In that i am using the ctr o .. In my application i am using Linear encoder to measure the Lift movement.. so from software how to access the counter values i.e how much mm it moves... 

    Measure Angular Position.vi in the LabVIEW examples will be a good starting point. Adapt it to Linear Encoder by clicking on the selector below DAQmx Create Channel.vi.
    You can also create a corresponding DAQmx Global Channel (or task) in MAX and then use it in your code.
    Feel free to post back if you need further help.
    Message Edité par JB le 10-31-2008 02:15 PM

  • How to use Boolean values from 2 different sources to stop a while loop?

    I am working on a program for homework that states E5.4) Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. Be sure to include the Time Delay Exress Vi so the user has time to press the stop botton. 
    I am doing this right now but it seems as though I can only connect one thing to the stop sign on th while loop. It won't let me connect a comparision of N and the iterations as well as the stop button to the stop sign on the while loop. So how would I be able to structure it so that it stops if it receives a true Boolean value from either of the 2 sources (whichever comes first)? 
    Basically, I cannot wire the output of the comparison of N and iterations as well as the stop button to the stop button on the whlie loop to end it. Is there a solution?
    Thanks!
    Solved!
    Go to Solution.

    Rajster16 wrote:
    Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. 
    Look in the boolean palette for something similar to the word hightlighted in red above.
    LabVIEW Champion . Do more with less code and in less time .

  • Getting change values from a collection

    Title says it all. I have a collection connected to a
    datagrid and have a simple form that allows me to add/modify/delete
    entries from the collection. Now I want to send the changes to the
    collection back to the server. How do I read/parse the collection
    for these changes? Examples would be helpful. Below is what I have
    so far to examine the collection (found elsewhere) how do I extract
    the name/value pairs that have changed?
    public function
    collectionEventHandler(event:CollectionEvent):void {
    switch(event.kind) {
    case CollectionEventKind.ADD:
    addLog("Item "+ event.location + " added");
    break;
    case CollectionEventKind.REMOVE:
    addLog("Item "+ event.location + " removed");
    break;
    case CollectionEventKind.REPLACE:
    addLog("Item "+ event.location + " Replaced");
    break;
    case CollectionEventKind.UPDATE:
    addLog("Item updated");
    break;
    }

    ArrayCollection supports the length property, so you can
    simply iterate over it with a for loop and use the bracket notation
    to return each item. Build the structure you want to sent, then
    away you go.
    If you are wanting to only select changed values, you will
    have to track this yourself.
    Tracy

  • How to delete values from extension collection field through importer?

    Hi Experts,
    We have created one extension collection field in Master Agreement.
    We are able to add values to that collection field using Extension collection template CSV file through importer.
    Now we have a requirement to delete values from the Extension collection field through importer using CSV file.
    If anyone have template or idea please share with us.
    Thanks in advance!!
    Regards,
    Lava.

    Hi Agrawal,
    Thanks for you helpful information.
    Regards,
    Lava.

  • Filtering a sharepoint 2010 list using Multiple values from Multi-Select Filtering In Infopath 2010 form

    I am creating a browser based InfoPath 2010 form Calendar Filtering
    using SharePoint 2010 Calendar List (All Events) and InfoPath 2010.  This form has data connection to the Calendar list. Goal is to
    compare Calendar Events from Current Year to Previous Year. I have 2 columns called - Previous Year and Current Year. I have 2 drop-down controls in each columns called
    Select Year  and Select Week. I also have common drop down called
    Select Category which holds category of the events such as weather, power outages and so on. I wish to display specific events on specific date and specific week on both columns.
    I am able to filter the list based upon Year and Week
    on both these columns by applying rules in the InfoPath 2010 form. The real issue is that I want to apply category filter on the search result of
    Year and Week. Or it needs to show all the values if I
    select Category value as All. So I wish to apply filter on Search results using Category drop-down list selection.
    Hope I could explain this better but I tried to do the best here. Any suggestions, hint, or pointers
    Thanks
    Snehal H Rana
    Thanks Snehal H.Rana SharePoint Consultant

    I am creating a browser based InfoPath 2010 form Calendar Filtering
    using SharePoint 2010 Calendar List (All Events) and InfoPath 2010.  This form has data connection to the Calendar list. Goal is to
    compare Calendar Events from Current Year to Previous Year. I have 2 columns called - Previous Year and Current Year. I have 2 drop-down controls in each columns called
    Select Year  and Select Week. I also have common drop down called
    Select Category which holds category of the events such as weather, power outages and so on. I wish to display specific events on specific date and specific week on both columns.
    I am able to filter the list based upon Year and Week
    on both these columns by applying rules in the InfoPath 2010 form. The real issue is that I want to apply category filter on the search result of
    Year and Week. Or it needs to show all the values if I
    select Category value as All. So I wish to apply filter on Search results using Category drop-down list selection.
    Hope I could explain this better but I tried to do the best here. Any suggestions, hint, or pointers
    Thanks
    Snehal H Rana
    Thanks Snehal H.Rana SharePoint Consultant

  • Using the values from a drop down list to display in a separate cell

    Hi all,
    I must apologise if I don;t use the right 'terminology' as I am just an ordinary guy who uses a mac. I am also deaf which means I am totally dependant on the internet for fixing solutions.
    Basically, I wanted to create a drop down list which I had no problem doing.
    In the drop down, I have the options One-Piece, Two-Piece and Three-Quarter.
    I would like to get it so that when I select the One-Piece, the value of 160 appears in a separate cell. If I select Two-Piece, then I would need 130 to appear in that separate cell. Likewise, Three-Quarter to produce 150.
    Just to clarify, if we had a two-column and one row table, then the drop-down would be in A1, which the values would appear in B1.
    I do not know the formula, and cannot find any instructions anywhere as I am probably using the wrong terminology or function name!
    Any help would be much, much appreciated..
    Carl

    I don't guess what I may add.
    The contents of the table named lookup appear on the screenshot.
    cell A1 contains the string One-Piece, cell B1 contains the 'associated' value 160.
    cell A2 contains the string Two-Piece, cell B2 contains the 'associated' value 130.
    cell A3 contains the string Three-Quarter, cell B3 contains the 'associated' value 150.
    Now table Main
    In column B the cells contain a pop_up menu with four items like the ones described by Jerrold.
    In column C of the cells contain the formula :
    =IFERROR(VLOOKUP(B,Tableau 2 :: A:B,2,FALSE),"")
    I enhanced it since yesterdays because I forgot to treat the case when cell is blank in column B.
    I apologize but as I'm using my machine in French, the screenshot display the French formulas.
    I repeat that you may find useful infos in the PDFs files which we may download from the menus:
    Help > Numbers User Guide
    Help > iWork Formulas and Functions User Guide
    As you are in Stoke-on-Trent maybe your system is set to use the comma as decimal separator.
    If it's that, you must replace the comma by semi-colons in the formulas (you may see them in my screenshot).
    Yvan KOENIG (VALLAURIS, France) mercredi 24 mars 2010 09:27:53

  • Trouble Creating View Using Derived Values From With

    I want to use the two values derived from the sql statements in my WITH to use in a view. This is my code:
    WITH a AS(
    SELECT
    CASE
    WHEN (SELECT stvterm_code
    FROM stvterm
    WHERE sysdate >= stvterm_start_date
    AND sysdate <= stvterm_end_date) IS NOT NULL
    THEN (SELECT stvterm_code
    FROM stvterm
    WHERE sysdate >= stvterm_start_date
    AND sysdate <= stvterm_end_date)
    ELSE
    (SELECT min(stvterm_code)
    FROM stvterm
    WHERE stvterm_start_date > sysdate)
    END cur_term
    FROM dual),
    b AS (
    SELECT
    CASE
    WHEN (SELECT substr(cur_term,5, 2) FROM a) = '60' OR (SELECT substr(cur_term,5, 2) FROM a) = '40'
    THEN (SELECT substr(cur_term,0, 4)||'20' FROM a)
    WHEN (SELECT substr(cur_term,5, 2) FROM a) = '20'
    THEN (SELECT to_char(to_number(cur_term)-100) FROM a)
    END endof_prior_aidy_term
    FROM dual
    CREATE OR REPLACE VIEW jbartling.current_term AS
    SELECT cur_term, endof_prior_aidy_term
    FROM a,bHowever, I get the error ORA-00928: missing SELECT keyword. Is it possible to use WITH like this in creating a view? If not can someone show me another way to accomplish what I'm trying to do?

    Hi,
    You need to put the CREATE at top, i.e
    CREATE OR REPLACE VIEW jbartling.current_term AS
    WITH a
    SELECT ..  FROM a,bRegards
    Peter

  • Excel using PivotCaches.Create from recorded macro

    I am trying to create a pivot table. Using the record macro function I created a small pivot table, however when I try to adjust the code from the recorded macro I get an error (Type mismatch).
    The recorded macro looks as follows:
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "tadasEquities_20150223133033!R1C1:R780C71", Version:=xlPivotTableVersion14). _
    CreatePivotTable TableDestination:="Sheet52!R3C1", TableName:= _
    "PivotTable32", DefaultVersion:=xlPivotTableVersion14
    Sheets("Sheet52").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable32").PivotFields("Research type")
    .Orientation = xlRowField
    .Position = 1
    End With
    This is the part of the code I adjust.
    Worksheets("Pivot Table").PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    rngData, Version:=xlPivotTableVersion14). _
    CreatePivotTable TableDestination:=Worksheets("Pivot Table").Cells(1, 1), TableName:= _
    "PivotTable", DefaultVersion:=xlPivotTableVersion14
    rngData is defined as:
    Set wsData = Worksheets(1)
    Set rngData = wsData.Range(Worksheets(1).Cells(1, 1), Worksheets(1).Cells(downlast, rightlast))
    Worksheet("Pivot Table") is
    Worksheets.Add(After:=Worksheets(1)).Name = "Pivot Table"
    where rightlast and downlast are the last cells of a table.
    As you can see I only adjust SourceData and TableDestination and use Worksheets instead of ActiveWorkbook. Could someone tell me what I am doing wrong?

    Hi sakew,
    The PivotCaches method is in workbook object instead of worksheet, there isn’t that method or property in worksheet object. The workbook and worksheet are different object.
    More information, please refer to:
    # Workbook.PivotCaches Method
    https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.pivotcaches.aspx
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to use POV values from one worksheet in functions?

    I have a Smart View free-form Excel report based on an Essbase cube with 13 dimensions.
    Am using 1 dimension in columns, 3 in rows, 5 as page dimensions, and 4 in the POV. The member values in the rows, columns, and page dimensions are "fixed" in the layout of the free-form report.
    The 4 four dimensions in the POV need to have changeable member values.
    This layout works fine on the worksheet where it is built, where there are over 20 columns and 150 rows.
    However, within that large grid (20 columns x 150 rows), there are about 60 individual cells where I need to use a different value (not the one that would be retrieved based on the row/column dimensions for that cell in the grid).
    I think that I can use functions to obtain the values for these 60 cells, but cannot figure out how to update the formulas/functions based on the values for the 4 dimensions in the POV that are changeable -- it seems as if my functions are "fixed." (In my functions, I am listing all 13 dimensions as: Dimension#Member.)
    I read in the user guide that I could not list all 13 dimensions and the default for any unspecified dimensions would be the value in POV Manager. But as far as I understand it, POV Manager does not have the same values I see in the POV menu/toolbar on screen where member values are selected.
    Any help would be appreciated -- am a new Smart View user. Thanks.
    Edited by: user3588870 on Oct 14, 2008 1:54 PM

    Hi Edvard
    Welcome to the forum.
    +Menu > Format > Import Styles… > browse to other document > select the styles+
    Peter

  • How to use return value from TestComplete ( using COM) as a variable in the conditional statement (e.g. while loop) in TestStand

    Hi,
    I have setup a COM interface for TestStand(TS) to run certain scripts in TestComplete (TC).  Normally, when TestComplete finishes executing the script, it returns a 0 or 1 to denote pass/fail in the TestStand step (e.g String value test step).  This worked fine.
    However, now I need TestComplete to return a vaule( e.g 32) to TS, and TS need to evalue this value in a while statement. So if TC return value is 32, I'd have some statement in TS ike :                                                                                                 
    While (return value != 30)
    Do something..
    Thanks,
    Solved!
    Go to Solution.

    There are a hundred ways to implement what you are asking.  The hard part is deciding which one would be the best for you.
    What adapter are you using to communicate with TestComplete?  ActiveX?  Is TestComplete running asynchronously (in parallel)?  If so then how is the data getting back to TestStand?
    So here are some options:
    1. You can use the While Step type.  It's in the Flow Control folder in your Step Types pallette.  Look in your examples under UsingFlowControlSteps.seq in the SequenceFlow
    2. You can loop on a step and have the termination for the loop be (return value == 30).  Look in the Step Properties under Looping.  Also in the TestStand help
    3. You could do Post Actions based on a condition and have it jump to another step.  Read about it in the TestStand Reference Manual.
    4. You could use a GoTo step.  I don't really recommend this one.  It makes code hard to maintain.  Also an example in SequenceFlow called gotobeep.seq.
    Hopefully this gets you thinking.  Let me know if you have specific questions about any of these methods.
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Assigning a password to PDF, using dynamic value from query

    I have a report that bursts through bi publisher, and i would like to dynamically protect each pdf that is generated by using something that is unique to the report, like an office id from the query. I know how to set a static password from the template properties, and i understand how to use the api if i wanted to write my own routine to run the report, i just dont want to do that. i just want to dynamically set the password, while the job runs inside the bipublisher environment as a scheduled job. can this be done? are there ways to embed java api calls/code in the report and have it run inside bipublisher, instead of having to call a webservice?

    You have to do the same way you do for static password,
    instead of typing the password, you refer an element from xml or concat some elements and form a password.
    {/fromROOT/password}

  • How to use time values from graph or chart for other calculations

    iam generating an ultrasonic signal of frequency 500k. In the equation i need the values of time axis of the graph or chart for calculationg the envelope of the graph. please help me how to use the x-axis time values.I have tried by writing in spread sheeet or by using arrays. here iam not able to get only 1 dim time values.
    AshwiniP

    Use a property node

Maybe you are looking for

  • Safari Won't Open Apple Store's Web Site

    I tried to go to Apple Store using Safari and wasn't able to get the page to load. I'd get the spinning beach ball every time. I disabled all plugins, input managers, turned off RSS support, tossed the Safari preferences, emptied the cache and cookie

  • I have many Apple IDs some i dont even remember, the problem is one of them still attach to my iphone.

    Hi , i have an iphone and yes i bought it! the problem as described above, is with all my Apple IDs, actual emails and devices i own. after upgrading the iphone to iOS 7 im stucked at the activation lock and im OK with that - i can see my email (i gu

  • Acrobat X Pro - Header & Footer content ? (web pages)

    We have thousands of Acrobat documents of converted web pages with this convention: Header (L-R): Title - [empty] - Date Footer: URL - [empty] - Page number This convention needs to be retained, but *many* web pages in Internet Explorer 10/11 simply

  • Using keynote on different machines

    I have keynote on my ipad2. 1.If I want to transfer the presentation to my macbook, do I need to purchase the app for the macbook? 2.If so, will that work correctly? 3.Can I transfer it through itunes? Thanks so much!

  • Entry from table crmd_orderadm_h not found in table DNOD_NOTIF_S

    Is it true that, whenever an entry is created in the crmd_orderadm_h, same entry is reflected in table DNOD_NOTIF_S with reference as field GUID ? If not, when a entry is created with reference from same GUID in table DNOD_NOTIF_S w.r.t crmd_orderadm