Frequency Based Records

Hi All
A little overview
we have a intake system where users submit requests and we process them . Some of our requests are recurring which means after we get the original request we create manual requests for that recurring request and process them until the original request expires
Lets assume all original requests are stored in Table A,Table B and Table C
Manual requests are going to be steored in Table D.
We have created a process to generate automatic requests in Table D based on original Request information from Tables A,B,C . I was using a cursor logic which was working fine for generating requests where the recurring frequency selected was Monthly and
Quaterly. I needed help in the query to generate records when the original requests came with frequency selected as Weekly or Bi weekly and got help from a differant thread where it was suggested to create a calendar table and then start using the calendar
table to generate records irrespective of the frequency and it worked with sample data.
Below is the Query
Declare @Sample Table(Requestid int, Receiveddate smalldatetime, frequency varchar(10), assignedanalystid int, requesttypeid int, CustomerName varchar(50), CompletedDate smalldatetime, ExpirationDate smalldatetime)
Insert @Sample(Requestid, Receiveddate, frequency, assignedanalystid, requesttypeid, CustomerName, CompletedDate, ExpirationDate)
Select 123456, '12/31/2013', 'Monthly', 123, 34, 'Testing Company', '1/15/2014', '12/31/2014'
Union All Select 123654, '12/31/2013', 'Weekly', 123, 34, 'Testing Company', '1/15/2014', '12/31/2014'
Union All Select 125000, '12/31/2013', 'Bi-Weekly', 123, 34, 'Testing Company', '1/15/2014', '12/31/2014';
Select s.Requestid + Row_Number() Over(Partition By s.Requestid Order By c.dt) As Requestid,
Cast(c.dt As smalldatetime) As ProductionMonth,
s.assignedanalystid As AssignedAnalyst,
s.frequency As freqcd,
Cast(c.dt As smalldatetime) As EnteredDate,
s.requesttypeid As rptdesc,
s.CustomerName As groupname,
s.Requestid As originalrequestid
From @Sample s
Inner Join dbo.Calendar c On c.dt Between s.CompletedDate And DateAdd(month, 1, s.ExpirationDate)
Where (s.frequency = 'Monthly' And c.D = 1)
Or (s.frequency = 'Weekly' And DateDiff(day, s.CompletedDate, c.dt) % 7 = 0 And c.dt > s.CompletedDate And c.dt <= DateAdd(week, 1, s.ExpirationDate))
Or (s.frequency = 'Bi-Weekly' And DateDiff(day, s.CompletedDate, c.dt) % 14 = 0 And c.dt > s.CompletedDate And c.dt <= DateAdd(week, 2, s.ExpirationDate))
Order By originalrequestid, Requestid;
Original Thread
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/430bcb7d-1ee9-400b-b29a-9db8c2672cf1/generating-records-based-on-frequency?forum=transactsql
How should i modify the above so that i use a requestid from Table A,Table B,Table C and generate its relevant requests in Table D
My Original Post
SET NOCOUNT ON
GO
declare @num_of_times int
declare @count int
declare @frequency varchar(10)
declare @num_of_times1 int
DECLARE @oldrequestid varchar(50),@newrequestid varchar(50)
DECLARE db_cursor CURSOR FOR
SELECT Requestid from Request_Customer where requestid in (149016)
OPEN db_cursor  
FETCH NEXT FROM db_cursor INTO @oldrequestid
WHILE @@FETCH_STATUS = 0  
BEGIN 
  --do
work here   
 SET
@num_of_times = NULL
select @num_of_times=datediff(month, receiveddate,expirationdate) from Request_Customer where requestid in (@oldrequestid)
SET @num_of_times1 = @num_of_times+1
set @count=0
WHILE @count < @num_of_times1
BEGIN
 update
table_keys
set key_id = key_id + 1
where table_name = 'adhoc'
Select @newrequestid = key_id from table_keys where table_name = 'adhoc'
INSERT INTO [dbo].[renoffcyc]
([roc_id]
,[prodmth]
,[opa_id]
,[freqcd]
,[entereddt]
,[rptdesc]
,[groupname]
,[origrequestid]
SELECT @newrequestid
,convert(varchar(30),DATEADD (month , @count+1 ,RR.Receiveddate))
,SR.Assignto
,RR.defineschedule
,convert(varchar(30),DATEADD (month , @count+1 ,RR.Receiveddate))
,SR.rptdesc
,RR.CTNAME
,@oldrequestid
FROM dbo].[Request_Customer] RR INNER JOIN SELECTED_CUSTOMER SR
ON RR.requestid = SR.requestid
where RR.requestid = @oldrequestid
set @count=@count+1
END
FETCH NEXT FROM db_cursor INTO @oldrequestid
END 
-- Cursor loop
Example:
So for example a request comes in Jan 2014 with frequency selected as monthly and the expiration date is Dec 2014. we
have to send the user monthly reports until Jan 2015 for which my monthly logic submits requests and one of our team member uses that automatic request generated by the query to process them monthly.
Sample Data
Original Request
Requestid Receiveddate frequency assignedanalystid requesttypeid CustomerName CompletedDate ExpirationDate
123456 12/31/2013 Monthly 123 34 Testing Company 1/15/2014 12/31/2014
Monthly Offcycles for original request 123456
Roc_id ProductionMonth AssignedAnalystid freqcd entereddt rptdesc groupname origrequestid
123457 2/1/2014 123 Monthly 2/1/2014 34 Testing Company 123456
123458 3/1/2014 123 Monthly 3/1/2014 34 Testing Company 123456
123459 4/1/2014 123 Monthly 4/1/2014 34 Testing Company 123456
123460 5/1/2014 123 Monthly 5/1/2014 34 Testing Company 123456
123461 6/1/2014 123 Monthly 6/1/2014 34 Testing Company 123456
123462 7/1/2014 123 Monthly 7/1/2014 34 Testing Company 123456
123463 8/1/2014 123 Monthly 8/1/2014 34 Testing Company 123456
123464 9/1/2014 123 Monthly 9/1/2014 34 Testing Company 123456
123465 10/1/2014 123 Monthly 10/1/2014 34 Testing Company 123456
123466 11/1/2014 123 Monthly 11/1/2014 34 Testing Company 123456
123467 12/1/2014 123 Monthly 12/1/2014 34 Testing Company 123456
123468 1/1/2015 123 Monthly 1/1/2015 34 Testing Company 123456
Below is sample data for original request and the off cycles that I would like help to generate weekly offcycles and Bi weekly Offcycles
Original Request
Requestid Receiveddate frequency assignedanalystid requesttypeid CustomerName CompletedDate ExpirationDate
123654 12/31/2013 Weekly 123 34 Testing Company 1/15/2014 12/31/2014
Weekly Offcycles for original request 123456
Roc_id ProductionMonth AssignedAnalystid freqcd entereddt rptdesc groupname origrequestid
123655 1/22/2014 123 Weekly 1/22/2014 34 Testing Company 123654
123656 1/29/014 123 Weekly 1/29/014 34 Testing Company 123654
123657 2/4/2014 123 Weekly 2/4/2014 34 Testing Company 123654
123658 2/11/2014 123 Weekly 2/11/2014 34 Testing Company 123654
123659 2/18/2014 123 Weekly 2/18/2014 34 Testing Company 123654
123660 2/25/2014 123 Weekly 2/25/2014 34 Testing Company 123654
123661 3/4/2014 123 Weekly 3/4/2014 34 Testing Company 123654
123662 3/10/014 123 Weekly 3/10/014 34 Testing Company 123654
123663 3/17/2014 123 Weekly 3/17/2014 34 Testing Company 123654
123664 3/24/2014 123 Weekly 3/24/2014 34 Testing Company 123654
123665 3/31/2014 123 Weekly 3/31/2014 34 Testing Company 123654
123666 4/7/2014 123 Weekly 4/7/2014 34 Testing Company 123654
123667 4/11/2014 123 Weekly 4/11/2014 34 Testing Company 123654
123668 4/18/2014 123 Weekly 4/18/2014 34 Testing Company 123654
123669 4/25/2014 123 Weekly 4/25/2014 34 Testing Company 123654<//span>
Thanks
Vamsi

Just a comment for anyone who works on this who did not see the original post - Vamsi's system uses SQL 2005.
Tom

Similar Messages

  • To modify a field in a database table based record identification by primar

    hi
    i want to to modify a field in a database table based record identification by primary key filed and two more fields
    ie customer (primary key
    i want to modify record from intenal table the record existing with primary key field customer
    the status field needs to be mofied as " value rolled"
    the below code is happening
    loop at it_record into wa_Record
    wa_inv-customer (primary key) = wa_Record=custome
    wa_inv-date = wa_Record-date
    ...so one
    append wa_inv to it_invest
    clear wa_inv
    endloop.
    if not it_invest  is initial
    modify TABle1 ( this table is data base table which needs to be mofified) based on the primary key field
    and also date field and status field which is not primary key.
    regards
    arora

    Hi there.
    Your requirement is to update a Z Database table from your internal table, right? You have several options:
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable
         SET date = wa_inv-date
       WHERE prim_key = wa_inv-prim_key
         AND any_field = wa_inv-any_field.
    ENDLOOP.
    or
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable FROM wa_inv. "if wa_inv of same type of dbtable
    ENDLOOP.
    In the first example, I wrote any field because you can update dbase table, filtering for fields that don't belong to the primary key. However, remember that you will change all records that respect the key you used (so, in your case, use the primary key).
    Regards.
    Valter Oliveira.

  • Condition based records sent to proxy

    Hi all,
    My interface is a File(FCC)-Proxy in PI7.0. I get 100s of records from the source and there are fields ID and LOC.
    Fields which has ID=2 and LOC=US or UK, only those particular records should be sent to the proxy. Please help.
    Thanks,
    Chaitanya

    hi chaitanya,
       "Condition based records sent to proxy"  
       Based on condition you sent records, in interface determination we have condition option there you define the condition .Based on payloda values we send it.
    1)   left operand : ID = Right operand : 2
    2) Left Oreand :LOC  = Right Operand : US OR(Insert Group We select Operation OR)
         Left Oreand :LOC  = Right Operand : UK
      regards,
    ganesh.n

  • Cisco QM/Calabrio - server based recording - how many NICs?

    I'm looking to replace a Verint system that is doing server-based recording with Call Mgr 4.1.3. We are going to upgrade to 7.1.x soon.
    My customer is a CCX CAD/Citrix environment. I see that QM/Calabrio also supports server-based recording.
    We have a number of subnets that we need to SPAN. I have a couple of questions:
    1) How many recording NICs can be in one QM recording server? Verint can do 4 plus a management NIC.
    2) How many recording servers can be supported? We also have a remote WAN location that needs a recording server.
    3) Does QM require an MCS server to run, or will it install on general server hardware (we are an IBM shop and have the servers.)
    Thanks.

    Questions about Cisco Call recording and Quality Management or Workforce management should be posted
    under the Contact Center Applications at https://www.myciscocommunity.com/community/partner/collaboration/contactcenter/apps
    I am checking some of the details for question 1 & 2  and will respond to your questions in a few hours
    for 3 The QM application can be deployed on MCS or MCS equivelent servers as determined by the partner/customer

  • How to get the record selected in ztable based record in the output of alv

    Hi All,
    I have developed a report, it is displaying the output in ALV format.The list contained some 20 fields along with MATERIAL and BATCH. I have provided menu bar as extras -> ztable(it also contained MATERIAL and BATCH). But I have some issue when I select any record in the output then go to
    path extras -> ztable, it has to select the record in ztable based MATERIAL and BATCH which i have selected in the output, then can you please provide solution for the above problem.
    Thanks in advance

    Hi Dolly,
    you can do this by,
    data: index_rows type lvc_t_row,
          index like line of index_rows.
    * Get Selected rows from alv grid
      clear index_rows.  refresh index_rows.
    "When you choose extras->ztable
      call method alv_grid->get_selected_rows
               importing
                     et_index_rows = index_rows.
    * Now delete those rows from the ALV grid
      loop at index_rows into index.
        read table itab index index-index. "Lets say itab is the table you are displaying
        if sy-subrc = 0.
         perform bdc_sm30. "do simple bdc for sm30 with tab name and selected values
        endif.
      endloop.
    Regards,
    Manoj Kumar P
    Edited by: Manoj Kumar on Feb 23, 2009 2:49 PM

  • User role based records displaying in datamanager

    Dear Expert,
    I am having issue of displaying total numbers of records showing in MDM (7.1 SP06) data manager. If I open data manager with Admin ID, it is showing me the complete records available in data manager. But if I open data manager with specific user ID, it is only showing records related to his work area (plants based material or zone based customers). If I provide u2018adminu2019 rights to his ID, then complete set of records are showing to his ID also in data manger. So itu2019s a role based issue.
    Can anybody know which object role control this scenario in console roles?
    Kindly help in this issue.
    Regards,
    Gaurang

    Hi,
    Just to make sure that your requirement is :
    For any user , all the records should be displayed. There is no creteria/filter to any user
    If this is the case, NO need to have any masks or Named Searches.
    Open Console and check whether the Constraints is selected as "ALL" for all the roles which you are using
    If you have already added the records in to any existing masks, remove it from masks.
    Perform this for each role if you have already added records in to masks
    Kindly revert if it helps
    Regards,
    Antony

  • Logic cuts low frequencies when recording audio?

    I am using a Lexicon Lambda interface and a iMac running Logic Pro 9, when i try to rip vinyl from a single turntable or record a mix from my mixer logic cuts most of the low frequencies leaving a tinny sounding recording, i have tried recording using the same interface with a Acer laptop running both Cubase and Soundforge and all is fine, so it must be something in Logic's settings, probably something simple that i have missed most likely, anyone know what to do to stop this?

    Sounds as though you are hearing the effect of the RIAA EQ curve (bass cut and treble boost) applied at the cutting stage to keep the cutter head excursion within manageable bounds. If you connect a deck directly to your computer, this is to be expected. However, a DJ mixture should correct for the EQ. Does it have more than one output? If so, see if changing output affects the sound. If not, does your interface have a 'phono' input? If so, this should provide the required compensation. Failing that, does anyone have a Linear Phase EQ preset to deal with the RIAA curve?

  • Logic Pro Based recording studio

    Hi all, I am intending on building a smallish recording studio around Logic Pro - I need your experience and expertise!
    My imagined setup is based on a hefty Mac Pro, using Apogee Symphony Cards as Audio inputs. I considered using Motu or M-Audio..any thoughts?
    My big Questions:
    1. Mixing Desk/Control Surface
    Firstly do I need a separate Mixing desk? or will a digital control surface do? Can all the audio go straight to the Mac through the interface? or does it need to go through a desk for monitoring etc?
    2. Control Surface
    I would very much like to find a decent control surface of the digidesign C24/C20 style, but I don't seem to be able to find anything with more than 8 channel strips that says its compatible with Logic Pro - these all seem targeted at the prosumer/home user category of artist - Any thoughts?
    Thanks for your help all,
    Ed

    No software program is truly bug-free. The issue with Logic and the most current OS (10.5.2) is that these bugs are not being addressed... at all. Logic 8 has been around for 8 months or so and so far there have been no major updates to improve stability, core audio issues on the OS, etc.
    Basically Logic is $500 because there is no support - you're buying only software.
    Avid, Ableton, Cakewalk and the like are primarily software companies and they thrive on constantly updating their apps. Apple Inc, is not a software company. So you proceed at your own risk when it comes to Apple "solutions".
    And keep in mind there is no such thing as a "solution"! Only tools, craftsmanship and love of music.
    Your other question I believe about an external mixer, there are two simple descriptions: ITB & OTB.
    In the box & Out of the box, respectively. Of course these two worlds overlap and arguably, one is not better than the other. I'd suggest looking for those terms on other forums. Tapeop.com, gearslutz.com, soundonsound.com, there are hundreds, I'm sure.
    One last thing and it's a bit of a gripe: But Apple has also taken the liberty to arbitrarily remove certain features and/or consolidate features that were special components to Emagic's program... many of these features will be missed, ie, syncing Logic to an external MIDI clock. R.I.P. external MIDI clock...
    Have fun.

  • UCCX7 Server based recording/monitoring

    I have looked and looked and I can't find a single bit of documentation that has all the steps for setting this up?? Is there such a thing can anyone point me in the right direction?
    Thanks!!

    To let the UCCX server do all the recording do the following:
    1. Enable the 2nd NIC on the UCCX server.
    2. Setup a SPAN port on the switch that you will plug this 2nd NIC into and let the SPAN port monitor the voice VLAN.
    3. Plug in the 2nd NIC into the SPAN port.
    4. Run c:\program files\cisco\desktop\bin\postinstall.exe on the UCCX server.
    5. In the VoIP monitor service section Select the 2nd NIC from the dropdown when it asks which NIC should be used for monitoring and recording. Then apply and exit.
    6. Restart the VOIP Monitor Service.
    7. In the Desktop Administrator. Set the default VoIP Monitor server to the local UCCX server. (In V7 of UCCX this is done in the web browser desktop admin tool)
    Recall that SPAN is local to the switch and/or layer 2 LAN that the switch is connected to. You may need to enable RSPAN if you have a layer 3 link. For best results, put the UCCX server and the agents are on the same layer 2 LAN / VLAN.

  • New to computer based recording - have a basic question

    Hello all,
    I have been recording on a stand alone multi-track machine for some time. I'm wanting to expand how many tracks I have and utilize the editing possibilities of Garageband 3. So, here's my basic question. I already have some songs recorded on the multi-tracker. The unit has the ability to export each track as a wav. file to the computer. I'm trying to find a fairly simple computer program that will allow me to import each track, remain in sync, and continue adding new tracks from the stand alone. For example, say I record 14 tracks on the stand alone and I still need another 10 tracks. I loathe bouncing because of the loss of control. Using Garageband 3, can I import the 14 tracks to a separate track each, record another 10 tracks on the stand alone, import those 10 tracks into the same project as the other 14 tracks, remain in sync, and then be able to edit, sweeten, etc all of the tracks? I have no real desire to record direct to the computer since I have a really nice set up already. I just want more tracks and the ability to edit them better than on the stand alone. Any help with this would be greatly appreciated.
    Randy

    Hi,
    Yes, you can, as long as all your Tracks have the same Start point.
    WH

  • Continuous Sound Processing & Event Based Recording

    I would like to continuously sample the PC sound card and perform processing to find certain signal characteristics in the incoming data.  When these characteristics are found (I'll call this an event), I'd like to then record the incoming data to a fixed length WAV file.  I can do all of this today with no problem. 
    However, what I'd really like to be able to do is to continue to sample and process the incoming data while recording.  If another event occurs while recording, I'd want a second (or third or fourth or fifth) file to start recording at the same time.
    I'm pretty sure this is doable given the parallel capabilities of LabView, but I'm having some trouble coming up with a program architecture that allows it.  Any suggestions on how to set this up would be appreciated.
    Thanks,
    Andy

    Kristen,
    Thanks, I think the Master/Slave arrangment might work.  I could have a master checking for events and then multiple slaves, one for each simultaneous recording.  I'd be limited by the number of slaves, but that might not be a crippling limitation.  
    Serge,
    I think you're right about multiple processes in several threads.  I'm not exactly sure how to call multiple instances of a template as you're describing without using a Master/Slave arrangement as Kristen suggested.  Do you have an example you could share?
    Thanks,
    Andy

  • Time based recording

    I want to record data to a file while the measured values are running,going on screen.For now I only successed to record data for a specific time period but also the measurement loop stops when the record time stops.How can I do a vi in which the measurement goes on without depending on time and whenever I want to start the recording I push  a button and the recording for a specific time period starts?Please help I feel desperate
    Attachments:
    Encoder_30.05.2014_deneme.vi ‏114 KB

    The code has a number of issues, like the express VIs and using the wrong timing functions, but beyond that it looks like you are wanting to read a new data point every 100ms for some period of time and then stop. Yes?
    Why are you reading the points individually? 100ms equates to a 10 Hz sample rate. Assuming you are wanting to acquire data for 10 seconds, that's 1000 datapoints. So configure the daq to acquire 1000 points at a 10 Hz sample rate, and you're done -- the timing is exact, and no loops.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Traversing to VA02 based records selected in alv

    Hi All,
    I have an ALV which displays
    VBELN POSNR Order Incompletion Reason
    34     010     Plant
    34     020     Price
    35     030     Reason3
    38     040     Reason4
    39     050     Plant.
    The user clicks on record that corresponds to say Sales order 34 and POSNR 10
    it should lead the user to transaction VA02 and the cursor must be positioned
    in the field that corresponds to Incompletion reason 'plant'.
    Its the positioning of the cursor which is posing the problem.
    The navigation should mimic transaction V.02
    Any help in this regard is welcome.
    Helpful answers would be Awarded for sure.
    Thanks

    Hi kiran,
    By recording and doing BDC is not possible.. since the cursor field changes..
    Try with this...
    1. Do the normal recording of VA02 for record -- 34 010 Plant
    2. placing the cursor on PLANT and record.
    3. U do mentain an internal table with
       reason and screen filed in it.
    4. populate the internal table with
       <b>reason       screen-field</b>   
        plant       VBAP-WERKS
        net price   VBAP-NETPR
    5. Now in coding for BDC.. for the last cursor field
       u read and assign for the internal table..
    note: ITs just a rough idea ... try .
    Sathosh

  • SQL solution for timestamp range based records

    Hi, lets say I have a record on 10.2 Oracle database:
    2011-08-18 12:53:35     2011-08-20 02:53:35
    I want to retrieve via single SQL three records from this record like:
    2011-08-18 12:53:35     2011-08-19 00:00:00
    2011-08-19 00:00:00     2011-08-20 00:00:00
    2011-08-20 00:00:00     2011-08-20 02:53:35
    Is this possible, thanks & regards.

    WITH DATA AS (SELECT TO_DATE('2011-08-18 12:53:35','YYYY-MM-DD HH24:MI:SS') df, to_date('2011-08-20 02:53:35','yyyy-mm-dd hh24:mi:ss') dt from dual)
    select greatest(df,trunc(df) + (rownum-1)) date_from
    ,least(dt,trunc(df) + (rownum) - 1/86400) date_to
    from data
    connect by rownum <= (trunc(dt+1) - trunc(df))
    hth

  • Commit after every 1000 records

    Hi dears ,
    i have to update or insert arround 1 lakhs records every day incremental basis,
    while doing it , after completing all the records commit happens, In case some problem in between all my processed records are getting rollbacked,
    I need to commit it after every frequency of records say 1000 records.
    Any one know how to do it??
    Thanks in advance
    Regards
    Raja

    Raja,
    There is an option in the configuration of a mapping in which you can set the Commit Frequency. The Commit Frequency only applies to non-bulk mode mappings. Bulk mode mappings commit according the bulk size (which is also an configuration setting of the mapping).
    When you set the Default Operating Mode to row based and Bulk Processing Code to false, Warehouse Builder uses the Commit Frequency parameter when executing the package. Warehouse Builder commits data to the database after processing the number of rows specified in this parameter.
    If you set Bulk Processing Code to true, set the Commit Frequency equal to the Bulk Size. If the two values are different, Bulk Size overrides the commit frequency and Warehouse Builder implicitly performs a commit for every bulk size.
    Regards,
    Ilona

Maybe you are looking for

  • Adobe Media Encoder and .TS files

    After updating the Adobe Media Encoder to the 2014.1 Release, every time I try to encode (convert) a .ts file I get audio issues post render no matter what I render out to.  It's only an issue when encoding (converting) .ts files.  I can convert an .

  • DisplayPor​t Question

    Hi guys, Question about the DisplayPort connector. I currently have 2 external monitors and am using the VGA port to send the signal from my Lenovo T520 to one monitor while the other is idle. I just found out about the DisplayPort plugin, but I want

  • Invoking custom object method

    Hi to everybody. I'm looking for a solution to my problem and I hope someone could help me. My classes are the following: public class sharedFunc { public int getMyValue() return 10; public class midClass { public sharedFunc A; public class Main { pr

  • Mac Mini not starting up

    When starting the computer, it stops at a gray screen and doesn't go any further. I have ran the hardware disc utility multiple times. When I click the verify disk it says that 1 volume needs to be repaired. When I click repair disk, it says that the

  • NLS in a Web archtecture

    I'm building a Web application that will have to support the Western European character set to accomodate French, Italian, Spanish, and German. How/where do I set the client NLS vars to display the proper locale settings? Clients from all countries w