How to write a cursor to check every row of a table which has millions of rows

Hello every one.
I need help. please... Below is the script (sample data), You can run directly on sql server management studio.
Here we need to update PPTA_Status column in Donation table. There WILL BE 3 statuses, A1, A2 and Q.
Here we need to update PPTA_status of January month donations only. We need to write a cursor. Here as this is a sample data we have only some donations (rows), but in the real table we have millions of rows. Need to check every row.
If i run the cursor for January, cursor should take every row, row by row all the rows of January.
we have donations in don_sample table, i need to check the test_results in the result_sample table for that donations and needs to update PPTA_status COLUMN.
We need to check all the donations of January month one by one. For every donation, we need to check for the 2 previous donations. For the previous donations, we need to in the following way. check
If we want to find previous donations of a donation, first look for the donor of that donation, then we can find previous donations of that donor. Like this we need to check for 2 previous donations.
If there are 2 previous donations and if they have test results, we need to update PPTA_STATUS column of this donatioh as 'Q'.
If 2 previous donation_numbers  has  test_code column in result_sample table as (9,10,11) values, then it means those donations has result.
BWX72 donor in the sample data I gave is example of above scenario
For the donation we are checking, if it has only 1 previous donation and it has a result in result_sample table, then set this donation Status as A2, after checking the result of this donation also.
ZBW24 donor in the sample data I gave is example of above scenario
For the donation we are checking, if it has only 1 previous donation and it DO NOT have a result in result_sample table, then set this donation Status as A1. after checking the result of this donation also.
PGH56 donor in the sample data I gave is example of above scenario
like this we need to check all the donations in don_sample table, it has millions of rows per every month.
we need to join don_sample and result_sample by donation_number. And we need to check for test_code column for result.
-- creating table
CREATE TABLE [dbo].[DON_SAMPLE](
[donation_number] [varchar](15) NOT NULL,
[donation_date] [datetime] NULL,
[donor_number] [varchar](12) NULL,
[ppta_status] [varchar](5) NULL,
[first_time_donation] [bit] NULL,
[days_since_last_donation] [int] NULL
) ON [PRIMARY]
--inserting values
Insert into [dbo].[DON_SAMPLE] ([donation_number],[donation_date],[donor_number],[ppta_status],[first_time_donation],[days_since_last_donation])
Select '27567167','2013-12-11 00:00:00.000','BWX72','A',1,0
Union ALL
Select '36543897','2014-12-26 00:00:00.000','BWX72','A',0,32
Union ALL
Select '47536542','2014-01-07 00:00:00.000','BWX72','A',0,120
Union ALL
Select '54312654','2014-12-09 00:00:00.000','JPZ41','A',1,0
Union ALL
Select '73276321','2014-12-17 00:00:00.000','JPZ41','A',0,64
Union ALL
Select '83642176','2014-01-15 00:00:00.000','JPZ41','A',0,45
Union ALL
Select '94527541','2014-12-11 00:00:00.000','ZBW24','A',0,120
Union ALL
Select '63497874','2014-01-13 00:00:00.000','ZBW24','A',1,0
Union ALL
Select '95786348','2014-12-17 00:00:00.000','PGH56','A',1,0
Union ALL
Select '87234156','2014-01-27 00:00:00.000','PGH56','A',1,0
--- creating table
CREATE TABLE [dbo].[RESULT_SAMPLE](
[test_result_id] [int] IDENTITY(1,1) NOT NULL,
[donation_number] [varchar](15) NOT NULL,
[donation_date] [datetime] NULL,
[test_code] [varchar](5) NULL,
[test_result_date] [datetime] NULL,
[test_result] [varchar](50) NULL,
[donor_number] [varchar](12) NULL
) ON [PRIMARY]
---SET IDENTITY_INSERT dbo.[RESULT_SAMPLE] ON
---- inserting values
Insert into [dbo].RESULT_SAMPLE( [test_result_id], [donation_number], [donation_date], [test_code], [test_result_date], [test_result], [donor_number])
Select 278453,'27567167','2013-12-11 00:00:00.000','0009','2014-01-20 00:00:00.000','N','BWX72'
Union ALL
Select 278454,'27567167','2013-12-11 00:00:00.000','0010','2014-01-20 00:00:00.000','NEG','BWX72'
Union ALL
Select 278455,'27567167','2013-12-11 00:00:00.000','0011','2014-01-20 00:00:00.000','N','BWX72'
Union ALL
Select 387653,'36543897','2014-12-26 00:00:00.000','0009','2014-01-24 00:00:00.000','N','BWX72'
Union ALL
Select 387654,'36543897','2014-12-26 00:00:00.000','0081','2014-01-24 00:00:00.000','NEG','BWX72'
Union ALL
Select 387655,'36543897','2014-12-26 00:00:00.000','0082','2014-01-24 00:00:00.000','N','BWX72'
UNION ALL
Select 378245,'73276321','2014-12-17 00:00:00.000','0009','2014-01-30 00:00:00.000','N','JPZ41'
Union ALL
Select 378246,'73276321','2014-12-17 00:00:00.000','0010','2014-01-30 00:00:00.000','NEG','JPZ41'
Union ALL
Select 378247,'73276321','2014-12-17 00:00:00.000','0011','2014-01-30 00:00:00.000','NEG','JPZ41'
UNION ALL
Select 561234,'83642176','2014-01-15 00:00:00.000','0081','2014-01-19 00:00:00.000','N','JPZ41'
Union ALL
Select 561235,'83642176','2014-01-15 00:00:00.000','0082','2014-01-19 00:00:00.000','NEG','JPZ41'
Union ALL
Select 561236,'83642176','2014-01-15 00:00:00.000','0083','2014-01-19 00:00:00.000','NEG','JPZ41'
Union ALL
Select 457834,'94527541','2014-12-11 00:00:00.000','0009','2014-01-30 00:00:00.000','N','ZBW24'
Union ALL
Select 457835,'94527541','2014-12-11 00:00:00.000','0010','2014-01-30 00:00:00.000','NEG','ZBW24'
Union ALL
Select 457836,'94527541','2014-12-11 00:00:00.000','0011','2014-01-30 00:00:00.000','NEG','ZBW24'
Union ALL
Select 587345,'63497874','2014-01-13 00:00:00.000','0009','2014-01-29 00:00:00.000','N','ZBW24'
Union ALL
Select 587346,'63497874','2014-01-13 00:00:00.000','0010','2014-01-29 00:00:00.000','NEG','ZBW24'
Union ALL
Select 587347,'63497874','2014-01-13 00:00:00.000','0011','2014-01-29 00:00:00.000','NEG','ZBW24'
Union ALL
Select 524876,'87234156','2014-01-27 00:00:00.000','0081','2014-02-03 00:00:00.000','N','PGH56'
Union ALL
Select 524877,'87234156','2014-01-27 00:00:00.000','0082','2014-02-03 00:00:00.000','N','PGH56'
Union ALL
Select 524878,'87234156','2014-01-27 00:00:00.000','0083','2014-02-03 00:00:00.000','N','PGH56'
select * from DON_SAMPLE
order by donor_number
select * from RESULT_SAMPLE
order by donor_number

You didn't mention the version of SQL Server.  It's important, because SQL Server 2012 makes the job much easier (and will also run much faster, by dodging a self join).  (As Kalman said, the OVER clause contributes to this answer).  
Both approaches below avoid needing the cursor at all.  (There was part of your explanation I didn't understand fully, but I think these suggestions work regardless)
Here's a SQL 2012 answer, using LAG() to lookup the previous 1 and 2 donation codes by Donor:  (EDIT: I overlooked a couple things in this post: please refer to my follow-up post for the final/fixed answer.  I'm leaving this post with my overlooked
items, for posterity).
With Results_Interim as
Select *
, count('x') over(partition by donor_number) as Ct_Donations
, Lag(test_code, 1) over(partition by donor_number order by donation_date ) as PrevDon1
, Lag(test_code, 2) over(partition by donor_number order by donation_date ) as PrevDon2
from RESULT_SAMPLE
Select *
, case when PrevDon1 in (9, 10, 11) and PrevDon2 in (9, 10, 11) then 'Q'
when PrevDon1 in (9, 10, 11) then 'A2'
when PrevDon1 is not null then 'A1'
End as NEWSTATUS
from Results_Interim
Where Test_result_Date >= '2014-01' and Test_result_Date < '2014-02'
Order by Donor_Number, donation_date
And a SQL 2005 or greater version, not using SQL 2012 new features
With Results_Temp as
Select *
, count('x') over(partition by donor_number) as Ct_Donations
, Row_Number() over(partition by donor_number order by donation_date ) as RN_Donor
from RESULT_SAMPLE
, Results_Interim as
Select R1.*, P1.test_code as PrevDon1, P2.Test_Code as PrevDon2
From Results_Temp R1
left join Results_Temp P1 on P1.Donor_Number = R1.Donor_Number and P1.Rn_Donor = R1.RN_Donor - 1
left join Results_Temp P2 on P2.Donor_Number = R1.Donor_Number and P2.Rn_Donor = R1.RN_Donor - 2
Select *
, case when PrevDon1 in (9, 10, 11) and PrevDon2 in (9, 10, 11) then 'Q'
when PrevDon1 in (9, 10, 11) then 'A2'
when PrevDon1 is not null then 'A1'
End as NEWSTATUS
from Results_Interim
Where Test_result_Date >= '2014-01' and Test_result_Date < '2014-02'
Order by Donor_Number, donation_date

Similar Messages

  • How to write a cursor for mutiple columns in forms urgent required.........

    i created one table rk with 8 columns and that i designed in forms.
    but i have another table grk with 4 columns.
    this grk contains data.
    this grk 4 columns data i have to retrive in rk table in froms by multiple records.
    the both column names are same in the both tables.
    because by seeing this 4 columns data i will insert remaining 4 column by entering in rk table in form.
    i known that i have to write cursor to retrive the 4 columns data for multiple record from grk table and in trigger i have to produce to rk table.
    i have worked but it is not working.
    can any body help me out how to write a cursor for 4 column to retrive multple records in form

    Hi,
    Try,
    DECLARE
            CURSOR Cur_Test IS SELECT <field_1>, <field_2>, <field_3>, ... <field_n> FROM <table_name> WHERE <condition>;
    BEGIN
            OPEN Cur_Test;
            LOOP
                    FETCH Cur_Test INTO <items_or_variables>;
                    EXIT WHEN Cur_Test%NOTFOUND;
            END LOOP;
            CLOSE Cur_Test;
    END;Regards,
    Manu.

  • How to write export dump commad with no datable data only table structure.

    How to write export dump commad with no datable data only table structure will there and command for hole schma.
    e.g. export dump command for scott schema and all table within scott schema in it no table data should be exported.

    If I understand the question, it sounds like you just need to add the flag "ROWS=N" to your export command (I assume that you're talking about the old export utility, not the Data Pump version).
    Justin

  • How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    How can I change the font in the "Add Text Comment" tool, which has Helvetica as default?

    Is this for the ADD TEXT COMMENT tool?  How do you change the default font for the ADD TEXT (EDIT TEXT) TOOL?

  • How to find tables which has more than 1000 Partitions

    Hi All,
    Is there any other way to find out the tables which has more than 1000 Partitions ?
    Apart from SAP report RSDD_MSSQL_CUBEANALYZE. Because this report is not working for me as job getting cancel again and again with ABAP dump DBIF_DSQL2_SQL.I already check SAP Note 1309838, but itu2019s not applicable for us because we are on highest support package level SAP_BW 701 SP06.
    Thanks,
    Harshal

    If you are running SQL Server as your database platform run this query:
    select o.object_id,o.name,p.Partition_count from sys.objects o
    inner join
    (select object_id,count(distinct partition_number) as Partition_count
    from sys.partitions
    group by object_id)
    p
    on o.object_id = p.object_id
    where o.type = 'U'
    order by p.Partition_count desc

  • How to find table which has no index?

    Hi,
    How to find a table which has no index?
    Please provide the query to find the above.
    Thanks
    Jafar

    select owner,
           table_name
      from dba_tables dt
    where not exists(select 'x'
                        from dba_indexes di
                       where dt.owner=di.table_owner
                         and dt.table_name = di.table_name)

  • How to write a cursor in a cursor

    Hi,
    I need to find out all the columns,corresponding tables in a specific schema that has the data pattern 'A100%'
    Alogorithm : loop dba_tables where owner = 'ADMIN', then loop for each column, ie select column_name from table_name where column_name like 'A100%'; then add any result to a new table.
    How can covert it into a pl/sql blcok..
    Pleae help me out..
    Regards,
    Ravi

    First off, this seems like a rather hideous thing to be doing... Updating an unknown number of columns in an unknown number of tables to replace all instances of a particular string would seem to imply that you have a totally broken data model. Whatever A100 and S100 represent to the business, you should only need to update 1 row in 1 table to make that change across the board. Addressing the data model issue would seem to be a priority before things spin any further out of control.
    Can you write the update query to update a single static column in a single static table? If you can do that, you should be able to take the dynamic SQL I posted above and just replace the dynamically generated SELECT statement with the dynamically generated UPDATE using the same basic pattern.
    Justin

  • How to write a procedure to load the data into a table using xml file as input to the procedure?

    Hi,
    Iam new to the xml,
    can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
    <?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>.
    Regards,
    vikram.

    here is the your XML parse in 11g :
    select *
      from xmltable('//Entity' passing xmltype
    '<?xml version="1.0"?>
    <DiseaseCodes>
    <Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    <Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
    </DiseaseCodes>
    ') columns
      "dcode" varchar2(4000) path '/Entity/dcode',
      "ddesc" varchar2(4000) path '/Entity/ddesc',
      "reauthflag" varchar2(4000) path '/Entity/reauthflag'
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    Using this parser you can create procedure as
    SQL> create or replace procedure myXMLParse(x clob) as
      2  begin
      3    insert into MyXmlTable
      4      select *
      5        from xmltable('//Entity' passing xmltype(x) columns "dcode"
      6                      varchar2(4000) path '/Entity/dcode',
      7                      "ddesc" varchar2(4000) path '/Entity/ddesc',
      8                      "reauthflag" varchar2(4000) path '/Entity/reauthflag');
      9    commit;
    10  end;
    11 
    12  /
    Procedure created
    SQL>
    SQL>
    SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
    PL/SQL procedure successfully completed
    SQL> select * from MYXMLTABLE;
    dcode                                                                            ddesc                                                                            reauthflag
    0                                                                                (I87)Other disorders of veins - postphlebitic syndrome                           0
    0                                                                                (J04)Acute laryngitis and tracheitis                                             0
    0                                                                                (J17*)Pneumonia in other diseases - whooping cough                               0
    SQL>
    SQL>
    Ramin Hashimzade

  • How to write formulas based on text of columns in another table

    We have thousands of formulas stored in a table 'Formulas'. How can we calculate values from a data table 'D1' based on the formulas in 'Formulas'
    Table 'D1' has columns:
    V1 V2 V3 V4 V5
    with standard numeric data.
    Table 'Formulas' has columns Date and F1 with value such as
    Date  F1
    2013 'v1=v2+v3'
    2014 'v1=v2*v5'
    The formulas in 'Formulas' are date-specific and also can change over time, so the solution must be dynamically generated during execution.
    Thanks!

    If the table is relatively small, you may try:
    IF object_id(N'TempDB..#D1') IS NOT NULL
    DROP TABLE #D1;
    CREATE TABLE #D1 (
    Id INT identity(1, 1) PRIMARY KEY
    ,v1 DECIMAL(10, 2)
    ,v2 DECIMAL(10, 2)
    ,v3 DECIMAL(10, 2)
    ,v4 DECIMAL(10, 2)
    ,v5 DECIMAL(10, 2)
    ,formula VARCHAR(200)
    INSERT INTO #D1 (
    v1
    ,v2
    ,v3
    ,v4
    ,v5
    ,formula
    VALUES (
    10
    ,12
    ,14
    ,8
    ,3
    ,'v1=v2+v3'
    7
    ,5
    ,3
    ,9
    ,4
    ,'v5=v1*v2'
    DECLARE @sql NVARCHAR(max)
    SET @sql = stuff((
    SELECT ' UNION ALL
    SELECT Id, ' + quotename(formula, '''') + ' AS Formula, ' + CASE left(formula, 3)
    WHEN 'v1='
    THEN substring(formula, 4, len(formula))
    ELSE cast(v1 AS VARCHAR(30))
    END + ' AS v1,' + CASE left(formula, 3)
    WHEN 'v2='
    THEN substring(formula, 4, len(formula))
    ELSE cast(v2 AS VARCHAR(30))
    END + ' AS v2,' + CASE left(formula, 3)
    WHEN 'v3='
    THEN substring(formula, 4, len(formula))
    ELSE cast(v3 AS VARCHAR(30))
    END + ' AS v3,' + CASE left(formula, 3)
    WHEN 'v4='
    THEN substring(formula, 4, len(formula))
    ELSE cast(v4 AS VARCHAR(30))
    END + ' AS v4,' + CASE left(formula, 3)
    WHEN 'v5='
    THEN substring(formula, 4, len(formula))
    ELSE cast(v5 AS VARCHAR(30))
    END + ' AS v5
    FROM #D1 WHERE ID =' + cast(Id AS VARCHAR(30))
    FROM #D1
    FOR XML PATH('')
    ,TYPE
    ).value('.', 'varchar(max)'), 1, 12, '')
    PRINT @SQL
    EXECUTE (@SQL)
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How to Set Position Cursor Option to Non key fields in Table Maintenance .

    Hi,
    I have created a Ztable and i am using table maintenance for that table. In TMG ,by default  we have position cursor option to key fields only . User wants that position cursor option for non key fields also. Please help me out of this issue .
    How to provide Position Cursor option to Non key fields.
    Thanks & Regards,
    Prasad.

    Hi Nabheet,
    I tried using TYPE S DISPLAY LIKE E and am setting vim_abort_saving as X and sy-subrc as 4. However, this is also not enabling the fields. In this case, the first 2 fields - key fields are getting enabled but not the required ones. The above snapshot is for the same.
    lv_date1 = table1-date1.
       lv_date2 = table1-date2.
       lv_diff = lv_date2 - lv_date1.
       IF lv_diff LT 0.
         CLEAR: lv_err_msg.
         lv_err_msg = text-005.
         MESSAGE lv_err_msg TYPE 'S' DISPLAY LIKE  lc_e.
         vim_abort_saving = lc_x.
         sy-subrc = 4.

  • How much time it take to rebuild an index for a table with 20 millions rows

    Hi all,
    i need to rebuild the index of a table containing 20 000 000 row (i don't know why the other people working on this didn't think of rebuilding the index regularly, because i asked and apparently it has never been done :cry: :cry:) i am not a sql developper nor a DBA so i can't mesure how long it take to rebuild the index, does any one have an idea (aproximativly of course :aie:), the other question is there any formula to use in order to calculate how often to rebuild the indexes (i can for example retieve how much rows are delated or inserted daily ...)
    Thanks again
    Taha

    taha wrote:
    :aie: that's why i am asking because i don't know (and to be sure which solution is best)
    so the table is like this (the columns) :
    45 varchar2, 5 timestamp, 30 Number no LOB columns, (15 indexes : 5 unique indexes and that those indexes uses at a maximum 4 columns)15 indexes - 100,000 deletes: this could mean 1,500,000 block visits to maintain index leaf blocks as the table rows are deleted. If you're unlucky this could turn into 1,500,000 physical block read requests; if you're lucky, or the system is well engineered this could be virtually no physical I/O. The difference in time could be huge. At any rate it is likely to be 1,500,000 redo entries at 250 - 300 bytes per entry for a total of about 400MB of redo (so how large are your redo logs and how many log switches are you going to cause).
    yes the tables is used by an application so (update, insert ) can take place at any time
    for the deletion , there is the batch which does a mass delete on the table ( 4 or 5 time each day)
    You haven't answered the question - how long does it take to do a sample batch delete.
    If you can enable SQL tracing, or take a before/after snapshot of v$sesstat or v$session_event for the session as it does the delete then you can get some idea of where the time is going - for all you know it might be spending most of its time waiting for a lock to do away.
    >
    "How many leaf blocks are currently allocated to the index(es) ?" how can i answer to this question ? may be if i check the all_objects table ?
    If you keep your statistics up to date then dba_indexes is a good place, cross-checked with dba_segments, and you can use the dbms_space package for more detail. I have a code sample on my blog which allows you to compare the current size of your indexes with the size they would be if rebuilt at some specific percentage: http://jonathanlewis.wordpress.com/index-sizing/ (It's such good code that Oracle Corp. has copied it into MOS note 989186.1)
    Regards
    Jonathan Lewis

  • How do I filter on multiple values / labels within a Pivot Table which points to a Power Pivot Model

    Hi,
    How do I filter on multiple values / labels within a large data set within a Pivot Table which points to a Power Pivot Model. I am current using Excel 2010 64 bit. I intend to empower users to achieve this by simply using the Excel user interface, not by
    using Excel formula or DAX. Please find the attached screen shot as a worked example, also in my real life example not all the values are available in the drop down. You can't use a slicer for the same reason as you can't use a drop down. I guess what I was
    hoping for is for the user to be able to enter AND or OR within the associated dialog box. Is there any way around this?
    Kind Regards,
    Kieran.
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Hi
    This is the forum to discuss questions about Microsoft Excel develop (VBA, Automation). For your question is more about pivot table features  for Excel, I will move
    this thread to the TechNet forum for Excel.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share
    their knowledge or learn from your interaction with us.
    Thank you for your understanding.
    Best Regards
    Lan
    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 get Tcode for table which has a table maintenance done

    Hi Friends,
    I have one issue.
    How to get the specific Tcode again for the table  to which i have used table maintenance .
    I have generated table maintenance for many tables inside my package.
    If i want specific Tcode for that particular table how do i find it...Is there any way to get that
    Thanks in advance.
    Regards
    kishore

    Hi Gautham,
    I am still having problem... If i give Z* it shows all the Tcodes created with Z.
    For that i will click Display object list and get my Tcodes inside my package..
    But that is not my issue...
    I am sorry if i didn get you properly
    But still i didn find any way for that.
    Will give one sample table which is Ztest. Ihave tcode ztest1.
    Now as u said if i give Z* i will get all Z* tcodes ..In TSTCP table if i execute iam getting only the Tcode fields
    lot of Z names(tcodes) are there. In that how will i find which is mine.I am not getting any parameter fied in output and all..
    please help me.
    Regards
    kishore

  • How do I send my photos to iCloud on my iPhone 3, which has the latest upgrade. I cannot find the option.

    How do I send my photos on my iPhone 3, which has the latest upgrade, to iCloud? I cannot find an option.

    You can only view your photo stream photos from a device or computer that is signed into your account with photo stream enabled, not from icloud.com.  If you backed up your phone, the camera roll photos on your phone would be included in the backup, but cannot be seen unless you restore the backup to your phone.
    However, you shouldn't try to use iCloud to back up your photos.  Photo stream photos only remain in iCoud for 30 days.  And if you back up yoru phone to iCloud, then delete your photos, you next backup will overwrite the backup that contains the photos you deleted and they would be lost.
    To back up your photos, import them to your computer using your usb cable as explained here: http://support.apple.com/kb/HT4083.

  • How to write REF-CURSOR Query in Oracle Reports

    Hello Guys!!
    I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
    The issue I have is with the query inside the Oracle reports(attached to this file).
    The query works fine until the last two EXISTS conditions.
    IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.
    Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
    appreciated.
    Thanks,
    Vishal
    -------------------------------------------------------Query in Oracle Reports---------------------------------------------------------
    select c.key_segment, p.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
    sum(a.ext_price) sales_dols,
    sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
    a.doc_dt, a.ext_price, a.units)) cust_reb_dols,
    sum(a.units) units,
    sum(a.ext_cost) cost_dols
    from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
    where a.doc_dt between :in_start_dt and :in_end_dt
    and a.customer_oc = h.control_loc_id
    and a.sold_to_customer_id = h.sold_to_cust_id
    and a.ship_to_customer_id = h.ship_to_cust_id
    and ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
    and a.product_id = p.product_id
    and p.product_gl_class_cd = 'CHEM'
    and p.product_legal_name = c.product_legal_name
    and c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
    -- and (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
    -- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
    and a.sale_type_cd in ('02','08')
    and a.document_type_cd in ('I','C','D')
    and (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
    and a.units <> 0
    and a.unit_cost <> 0
    and a.unit_price <> 0
    -- NEW FILTERS ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
    and ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='LOCATION_TYPE')))
    and ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
    and ((:in_sales_rep = 'ALL') or (nvl(a.territory_id,'<blank>') in (SELECT param_value
    FROM report_param
    WHERE report_id = :IN_REPORT_ID
    AND session_id= :IN_SESSION_ID
    AND USER_ID = :IN_USER_ID
    AND param_name='SALES_REP_TYPE')))
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'REGION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    and EXISTS
    (SELECT '1'
    FROM locations l, report_param rp
    WHERE rp.report_id = :IN_REPORT_ID
    AND rp.session_id= :IN_SESSION_ID
    AND rp.user_id = :IN_USER_ID
    AND rp.param_value = l.region
    AND rp.param_name = 'DIVISION_TYPE'
    AND a.warehouse_id = L.ARS_LOCATION)
    group by c.key_segment, P.supplier_id,
    decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))

    Hi,
    I need your help to create a report using Ref-Cursor. please see the below thread
    Report using ref cursor or dynamic Sql

Maybe you are looking for

  • Is there a way to create a picture from a video clip in Imovie?

    Hello everyone, I want to take a part of the video and make it a picture (jpeg) or anything like that. Is it possible in Imovie or other programs? Thanks Gregg

  • How to call 2 transactions in a single screen

    Hi All, I need to call 2 Standard transaction in a single screen. ie: 1 transaction should be displayed in first half of the sceen and another transaction should be in the next half. How we can do this. Thanks Partha.

  • Installed splashy and now I just get a black screen

    Hi everyone. I am fairly new to Arch (just installed it last week) and just messed up my computer... please bear with me. I wanted to install a splash screen so I installed splashy. I might have been a little reckless with the installation which resu

  • Problems with Transport Management System

    Hi All, i seem to be having some issues with my Transport Management System, we have a two system landscape DEV & PRD, the operating system is windows 2003 server. i am trying to access the usr/sap/trans on the transport host (DEV) from the PRD syste

  • IPhoto Library file "grayed out"

    When I start up iPhoto, it prompts me to choose a library. My library file is "grayed out", not letting me choose it. Any help? I'd like to try and keep all my albums if I can. Thanks!