How to access Previous Records' Data from within a Query?

Hi All,
I am making a report in which I need to compare my "Registration Start Date" with "Registration End Date" of previous registration of same customer. This is to check if there are gaps between any customer's registrations.
In scenario shown below, I want to filter out RegID '1' as it comes after a gap from previous registration(RegID '3') of the same customer.
RegID CustID Registration Start Registration End
1 1 01/04/2005 07/04/2005
2 2 01/03/2005 29/05/2005
3 1 21/03/2005 29/03/2005
4 1 01/03/2005 21/04/2005
I created the join of this table with itself to pick previous records. it is something like:
Current_Rec.Cust ID = Prev_Rec.CustID AND
Current_Rec.RegStart > Prev_Rec.RegEnd
But this gives wrong data if customer has 3 back-to-back registrations. i.e. Shows last registration in query results as their is a gap between 3rd and 1st registration. But ofcourse there was another record between these two(which was 2nd registration).
It would be so nice of you guys if you can suggest a solution to this. Any oracle function?
Thanks & Regards,
Ahsan

I Assume the following is your sample data
Table Name: Tab1
RegID CustID Registration_Start      Registration_End
1      1      01/04/2005           07/04/2005
2      2      01/03/2005           29/05/2005
3      1      21/03/2005           29/03/2005
4      1      01/03/2005           21/03/2005
Note : For the Regid "4" I have changed the Registration_End to 21/03/2005. It was earlier 21/04/2005.
Coming to the query, you need to generate the list of regid that have gaps.
Try the following query:
SELECT c.*
FROM tab1 c
WHERE c.reg_id NOT IN (
SELECT a.reg_id
FROM tab1 a, tab1 b
WHERE a.cust_id = b.cust_id
AND a.registration_end = b.registration_start
Note: I am sorry I didn't have access to the data base to execute my query. Correct me if I am wrong.
Regards,
Somu

Similar Messages

  • How to access internal table data from webdynpro to Flex application.

    Hi Connoisseur
    The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and  Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
    There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
    i tried to do pass internal table value  to flex-datagrid.but its not work.
    i would like to know
    1.how to access internal table data from webdynpro to Flex application.
    2.how to pass the internal table to flex-datagrid.
    2.how to pass dynamically in ADOBE flex.
    3. how to do Flex is receiving the wd context data?
    4. how can we update WD context with FLEX data.
    Ple give me sample example and step by step procedure.
    Regards
    laxmikanth

    Hi Laxmikanth,
    Please refer this...
    Flash island: update complex type from flex
    Cheers..
    kris.

  • Accessing Datagrid row data from within an itemRenderer

    I would like to know how I can access another row's data from within an itemRenderer.  I need to do some formatting of my cells based on other row data. Here's what I mean... I have a datagrid and in row 0 col 2's itemRenderer I would like to access row 1 col 1's data in order to do a comparison so I can determine how to format row 0 col 2's data and so on.  Is there a way from within the item renderer to reach into another row and access the data?  I can't seem to find a clear answer so I thought I'd go to the pro's.
    Thanks!!

    You can use this code to get to the dataProvider of the grid.
    var o:Object = this.parent.parent;
    var dp:Object = o.dataProvider;

  • How to access Sybase IQ data from SAP BW

    Hi,
    I read from Sybase website that we can access Sybase IQ data from SAP BW using Remote Cube through JDBC driver.
    Is there any documentation on how to configure that?
    Thanks in advance for your help.
    Our BW version is 7.01
    Sybase IQ is 15.4
    Thanks,
    CH

    Hi,
    The two files that are created are one is Control File ( will save as filename_s ) and other is data file. The control file will give you the details of your fields in your Infospoke
    regards
    Srini
    Message was edited by:
            Srinivas

  • How to access listbox binding data from a button which is not part of listbox in xaml page

    Hi
    I have the below listbox and its bdining as below
     <ListBox x:Name="listMyPosts" ItemsSource="{Binding Path=MyPostsDataSource}" Grid.Row="0"  >
               <ListBox.ItemTemplate >
                          <DataTemplate >                                      
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding
    NewPostText ,Mode=TwoWay}"/>
                                            <TextBlock Text="{Binding
    NewPostSender}"/>
                                        </StackPanel>                                      
                                </DataTemplate>
                </ListBox.ItemTemplate>
               <Button content="Send Post" command ="Binding SendClickCommand} />
      </ListBox>
    And i am assining postsViewmodel
    private PostsViewModel _PostsViewModel ;
    public Conversation()
    InitializeComponent();
    _PostsViewModel = new PostsViewModel ();
    this.DataContext = _PostsViewModel ;
    public ObservableCollection<PostsModel> MyPostsDataSource
    get
    if (_MyPostsDataSource== null)
    _MyPostsDataSource= GetMyPosts();
    return _MyPostsDataSource;
    set
    this._MyPostsDataSource = value;
    RaisePropertyChanged("MyPostsDataSource");
    is that possible to access listbox binding data from the ViewModel's SendClickCommand property ?
    Krrishna

    If you need to pass to the command selected item, try this
    <Button Сontent="Send Post"
          Сommand ="{Binding SendClickCommand}"
          CommandParameter={Binding ElementName=listMyPosts,
    Path=SelectedItem}/>
    msdn

  • Cannot access previous backup data from Time Capsule.

    I have had a Time Capsule running for over a year and, from what I can tell, it has been working properly. There have been a few occasions where I have needed to restore old data and was able to do so from a previous backup in Time Machine stored on the Time Capsule.
    I noticed last week that my MacMini and iMac were taking an unusually long time to run the routine periodic backup process and never seemed to finish, so I used "Stop Back Up" and attempted to enter Time Machine. When I go to "Enter Time Machine", my Time Capsule mounts and, after what seems like an unusually long time, I finally get the expected Time Machine window to appear.
    The problem is that there are no previous backups to access for either computers. It seems like I have lost all my old backup data. Yet, my 1T Time Capsule shows that it is only about 50% full. So it makes me wonder what is on the TC.
    It would seem that the data must be on the Time Capsule but for some reason Time Machine cannot locate/access it. I have not altered any preferences nor configurations.
    Any ideas as to what may have happened and how to go about fixing it would be greatly appreicated.
    Thank you,
    Marcantonio

    It sounds like the backups may be damaged/corrupted.  Repair them per #A5 in Time Machine - Troubleshooting.
    If that doesn't help, see #E4 there.

  • How to get previous month data from current month values

    Hi Experts,
    I have made one universe from BW Query in which Fiscal year period is entered in interval.
    I have made a universe from that and want to develop webI reports on top of that.
    In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
    Requirement:
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Jan'09         Sales of Feb'0f         and so on....
    I am getting this.
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Feb'09         Sales of Mar'09         and so on....
    I hope i have clear my requirements.
    Please help as soon as possible.
    Thanks in Advance,
    Rishit

    Hi Rishit,
    Follow the below steps to get the desired result.
    Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
    to_date('substr('009.2009',2)','mm.yyyy')
    you will get the result 01 sep 2009
    Step2: Convert this format to 01/09/2009 by using date functions.
    Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
    Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
    you should get the following result.
    01/02/2009 01/03/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Step5: Use the following formula in your Column (date) formula bar.
    =(<date>-1)-DayNumberOfMonth(<date>-1)+1
    You will get the following result:
    01/01/2009 01/02/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Format the cell according to your reruirement.
    Let me know if you will get any break in the above steps.
    Regards,
    Swati.

  • How to access the record data send by a procedure

    Hi I have a procedure with below code snippet..
    create package pkg
    type t_rec is recod (id number,id_name varchar2(10));
    type t_data is table of t_rec index by binary_integer;
    act_data t_data;
    procedure return_data is (o_rec out t_data,dept in number,region in number) ;
    create package body pkg
    procedue return_data is (o_rec out t_data,dept in number,region in number) is
    p_cur sys_refcursor;
    l_text varchar2(100);
    indx number:=0;
    begin
    open p_cur for 'select id,id_name from tab1'||l_text';
    loop
    fetch p_cur into o_rec(indx).id,o_rec(indx).id_name;
    exit when p_cur%notfound; --p_cur.count=0 giving error
    dbms_output.put_line('id is '||o_rec(indx).id); ---- 4
    indx:=indx+1;
    end loop;
    close p_cur;
    exception ....
    end pkg;Now ---4 is giving me values when i put value to id and id_name parameter.
    Then i try to fetch the returned value by below code
    DECLARE
    bk_data PKG.T_DATA;
    BEGIN
    PKG.RETURN_DATA(bk_data, 'parameter.pm1', 'parameter.pm2');
    dbms_output.put_line('id is '||bk_data(1).id);
    end;But it is not giving me any data and thowing error " no data found "
    Please help me how i can fetch and se the the data returned by PKG.RETURN_DATA
    Thanks in advance.
    Edited by: bp on May 31, 2012 2:56 PM

    >
    I have corrected my code as below.
    >
    No you haven't. You didn't fix the errors I mentioned.
    Worse you added new lines that have new errors.
    t_data:=&t_data -- i passed 10
    dept :&dept -- ipassd 10You added substitution variables to the package code; those are for sql*plus - not PL/SQL.
    >
    Can ypu please post the sample code that is giving you data for the sample package pkg .
    >
    If you aren't willing to post sample code why should we? The code you posted won't even compile so it can't possibly be the code you are actually using that purportedly has an error.
    exception ....That is invalid code as you undoubtedly know so what does it accomplish by adding it other than making people think your actual code was removed. But that means that the code you removed could have a problem in it that we can't see. And that means we have no hope of finding your problem because we can't see all of the code that might be causing it.
    >
    Please ignore spelling mistakes.
    >
    We can't ignore them if the code you post won't compile with them in it. The word 'procedue' you provided in the original question isn't a spelling mistake; it's because you did not cut & paste your actual code. It means that instead you manually entered text that is not code you are actually using.
    If you really want help with your problem you need to post the code that you are actually using and that is giving you the problem you are reporting.
    >
    l_text varchar2(1000):=null; -- i have built some dynamic whee clause in this variable
    >
    But are you using NULL for this value when you run your test? If not then maybe the problem is in the value that you are using. How could we possibly tell when you don't post what you are using?
    Post the code you are actually using. If you can't do that for proprietary reasons then modify it to remove the sensitive code. But the code you post has to be the code you are using and the code that is giving the problem.

  • Order by problem.......how to Ascending order by date from the following query

    hi
    i have following query to show the monthly sales after summing up monthly sales total but i have facing a problem this query is not properly perform order by clause according to the months like jan,feb,mar etc... please tell me where i made mistake
    SELECT     CashName AS AccountName, LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate) AS Months, SUM(Total) AS NetSales
    FROM         dbo.CashSales
    GROUP BY LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate), CashName

    Select AccountName, Months, NetSales from
    (SELECT CashName AS AccountName, LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate) AS Months, SUM(Total) AS NetSales,
    DATEADD(month, DATEDIFF(month, 0, CashDate), 0) as dt
    FROM dbo.CashSales
    GROUP BY LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate), CashName, DATEADD(month, DATEDIFF(month, 0, CashDate), 0)
    t
    Order By dt

  • How can i store the data from the list to MS-Access?

    Hi all,
    We all know that from alv it is possible to export data to Ms-excel or word or text file. Can anyone tell me how can i store the data from alv or reports to Ms-Access?
    Thanks in Advance,
    Abhijit

    Hi,
    If you want that without code, i suppose there is a option in MS-Access to import data from Excel, so you have to first export to excel and then import to Access.
    If you want to code it yourself then have a look at FM TABLE_EXPORT_TO_MSACCESS, as said in Exporting Data from R/3 to MS ACCESS
    You can also see the search results in SCN for [export data to MS-Access (45 Results)|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=exportdatato+MS-Access&cat=sdn_all].
    Regards
    Karthik D

  • How to access the Custom Data type variable given in Expression edit control To and From LabVIEW

    Hello, I would like to know how to access the custom data type variable given in the Espression Edit Control from LabVIEW and vice-versa
    Say, the FileGlobals.Reference_Handle (Custom Data Type Variable) contains the
    VISA I/O session (Which in turn contains VISA_DeviceName: String, Session: Number),
    Channel1: Number and
    Channel2: Number
    I am expecting the user to give FileGlobals.Reference_Handle as the input at the ExpressionEdit Control in the edit screen of the VI Call.
    I would like to know how to get the values of this custom data type to LabVIEW?
    Say, if I have the Cluster in LabVIEW like VISA I/O session (Deive Name and Session Number), Channel1 and Channel2
    how do i need to set this cluster to the Custom Data type variable in TestStand?
    Thanks and Regards
    Prakash 

    Hi,
    TestStand to LabVIEW: i didnt understand what you r trying to achieve. But if you are using references, Use Property nodes and Invoke nodes to achieve what you want in LabVIEW.
     LabVIEW to TestStand: check the image below: You need to click the button next to 'container'. I have used a cluster output in the VI.
    Hope this helps
    .......^___________________^
    ....../ '---_BOT ____________ ]
    ...../_==O;;;;;;;;_______.:/
    Attachments:
    1.JPG ‏187 KB

  • How can I enter the data from the recordset into your insert query

    Hi
    i would like to know how I can enter the data from the recordset into your insert query without using a  hidden field.
    thanks
    ------------------------------------------------------------------------------------Below is the code------------------------------------------------------------------------------------- -----
    <?php require_once('../../Connections/ezzyConn.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
       $theValue = function_exists("mysql_real_escape_string") ?  mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmpostComment")) {
       $insertSQL = sprintf("INSERT INTO comments (com_topic, com_user, title,  com_content, com_date, online_id) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['com_topic'], "int"),
                           GetSQLValueString($_POST['commentby'], "int"),
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['com_content'], "text"),
                           GetSQLValueString($_POST['com_date'], "text"),
                           GetSQLValueString($_POST['online_id'], "int"));
      mysql_select_db($database_ezzyConn, $ezzyConn);
      $Result1 = mysql_query($insertSQL, $ezzyConn) or die(mysql_error());
      $insertGoTo = "index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    $colname_rsCommentby = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsCommentby = $_SESSION['MM_Username'];
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsTopics = "SELECT topic_id, topic FROM topics ORDER BY topic_date DESC";
    $rsTopics = mysql_query($query_rsTopics, $ezzyConn) or die(mysql_error());
    $row_rsTopics = mysql_fetch_assoc($rsTopics);
    $totalRows_rsTopics = mysql_num_rows($rsTopics);
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsOnline = "SELECT online_id, `online` FROM `online` ORDER BY online_id DESC";
    $rsOnline = mysql_query($query_rsOnline, $ezzyConn) or die(mysql_error());
    $row_rsOnline = mysql_fetch_assoc($rsOnline);
    $totalRows_rsOnline = mysql_num_rows($rsOnline);
    $colname_rsCommentby = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsCommentby = $_SESSION['MM_Username'];
    mysql_select_db($database_ezzyConn, $ezzyConn);
    $query_rsCommentby  = sprintf("SELECT user_id, username FROM users WHERE username = %s",  GetSQLValueString($colname_rsCommentby, "text"));
    $rsCommentby = mysql_query($query_rsCommentby, $ezzyConn) or die(mysql_error());
    $row_rsCommentby = mysql_fetch_assoc($rsCommentby);
    $totalRows_rsCommentby = mysql_num_rows($rsCommentby);
    ?>
    <?php include("../includes/access.php"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ezzybay - easy click, ezzy shopping</title>
    <link href="../css/global.css" rel="stylesheet" type="text/css" />
    <link href="../css/navigation.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper">
      <?php include("../includes/top.php"); ?>
      <div id="content">
      <div id="pageTitle">
        <h2>CMS Section:</h2>
        <p>Comment Topics Page</p>
      </div>
      <?php include("../includes/leftnav.php"); ?>
        <div id="mainContent">
          <form action="<?php echo $editFormAction; ?>" method="post" name="frmpostComment" id="frmpostComment">
            <table align="center">
            <caption>Post Comment</caption>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Topic:</td>
                <td><select name="com_topic" class="listbox" id="com_topic">
                  <?php
    do { 
    ?>
                   <option value="<?php echo  $row_rsTopics['topic_id']?>"><?php echo  $row_rsTopics['topic']?></option>
                  <?php
    } while ($row_rsTopics = mysql_fetch_assoc($rsTopics));
      $rows = mysql_num_rows($rsTopics);
      if($rows > 0) {
          mysql_data_seek($rsTopics, 0);
          $row_rsTopics = mysql_fetch_assoc($rsTopics);
    ?>
                </select></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Title:</td>
                <td><input name="title" type="text" class="textfield" value="" size="32" /></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right" valign="top">Comment:</td>
                <td><textarea name="com_content" cols="50" rows="5" class="textarea"></textarea></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">Status:</td>
                <td><select name="online_id" class="smalllistbox">
                  <?php
    do { 
    ?>
                   <option value="<?php echo $row_rsOnline['online_id']?>"  <?php if (!(strcmp($row_rsOnline['online_id'], 2))) {echo  "SELECTED";} ?>><?php echo  $row_rsOnline['online']?></option>
                  <?php
    } while ($row_rsOnline = mysql_fetch_assoc($rsOnline));
    ?>
                </select></td>
              </tr>
              <tr> </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right"> </td>
                <td><input type="submit" class="button" value="Insert record" /></td>
              </tr>
            </table>
            <input name="commentby" type="hidden" id="commentby" value="<?php echo $row_rsCommentby['user_id']; ?>" />
            <input type="hidden" name="com_date" value="<?php echo date("d/m/y : H:i:s", time()) ?>" />
            <input type="hidden" name="MM_insert" value="frmpostComment" />
          </form>
        </div>
      </div>
    <?php include("../includes/footer.php"); ?>
    </div>
    </body>
    </html>
    <?php
    mysql_free_result($rsTopics);
    mysql_free_result($rsOnline);
    mysql_free_result($rsCommentby);
    ?>

    I'll keep it simple and only use the date as an example. Hopefully you get the concept from the example. Basically you create a recordset and insert the recordset value instead of the POST value into your insert query. In the example below I declared a variable for $the_date and entered the variable into the INSERT query instead of the hidden POST field.
    <?php require_once('../../Connections/ezzyConn.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
       $theValue = function_exists("mysql_real_escape_string") ?  mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $the_date = date("d/m/y : H:i:s", time());
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmpostComment")) {
       $insertSQL = sprintf("INSERT INTO comments (com_topic, com_user, title,  com_content, com_date, online_id) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['com_topic'], "int"),
                           GetSQLValueString($_POST['commentby'], "int"),
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['com_content'], "text"),
                           GetSQLValueString($the_date, "text"),
                           GetSQLValueString($_POST['online_id'], "int"));
      mysql_select_db($database_ezzyConn, $ezzyConn);
      $Result1 = mysql_query($insertSQL, $ezzyConn) or die(mysql_error());
      $insertGoTo = "index.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>

  • How to access Revenue records

    <b>[This thread was migrated from the On Demand Developer Forum in the old Siebel Community] </b>
    algocode
    New Contributor
    I try connecting to Revenue records with web services using the same user
    ID with which I'm able to create Service Revenue Details information from
    the CRM OnDeman user interface but instead, I get an error message saying
    "Access denied.(SBL-DAT-00553)";(SBL-EAI-04376).
    Why can't the web service read the revenue records that I am able to
    create or update manually from the CRM OnDemand portal, with the same ID?
    Product: General: IT Organizations and Processes
    10-27-2006 11:25 AM
    Re: how to access Revenue records
    algocode
    New Contributor
    Inside a class extending System.Web.UI.Page, I use the
    secure.crmondemand.com/OnDemand/user/account.wsdl?WSDLOBJ=account web
    service to
    1. Create a list of accounts and specify the fields returned by the
    result set;
    2. Create an AccountWS_AccountQueryPage_Input object;
    3. Retrieve an AccountWS_AccountQueryPage_Output object;
    These are the three methods involved:
    protected void Page_Load(object sender, System.EventArgs e)
    Account1[] objListOfAccount;
    //Initialize the ListOfAccount Arrays and Sub-Arrays
    objListOfAccount = createListOfAccount("";
    //Specify the Account Search Criteria
    objListOfAccount[0].AccountName = "LIKE '" + data["Account"] + "*'";
    //Tell OnDemand What Account fileds should be returned in the result set
    objListOfAccount[0].AccountId = "";
    objListOfAccount[0].Location = "";
    //Tell OnDemand What fields to return on the Opportunity Child
    objListOfAccount[0].ListOfOpportunity[0].OpportunityId = "";
    objListOfAccount[0].ListOfOpportunity[0].OpportunityName = "";
    objListOfAccount[0].ListOfOpportunity[0].CurrencyCode = "";
    //Tell OnDemand What fields to return on the Opportunity Service Child
    objListOfAccount[0].ListOfRevenue[0].RevenueId = "";
    objListOfAccount[0].ListOfRevenue[0].OpportunityName = "";
    objListOfAccount[0].ListOfRevenue[0].NumberOfPeriods = "";
    objListOfAccount[0].ListOfRevenue[0].Frequency = "";
    objListOfAccount[0].ListOfRevenue[0].StartCloseDate = "";
    //Call the Account Query
    AccountWS_AccountQueryPage_Input objAccQryParam =
    new
    AccountWS_AccountQueryPage_Input();
    objAccQryParam.ListOfAccount = objListOfAccount;
    objAccQryParam.PageSize = "90";
    AccountWS_AccountQueryPage_Output objQryOutput =
    RetrieveQueryPageOutput(objAccQryParam, session);
    public Account1[] createListOfAccount(string pstrAccountDimensions)
    int intAccountCount = 1;
    int intOpportunityCount = 20;
    int intRevenueCount = 10;
    try
    Account1[] rtnListOfAccount = new Account1[intAccountCount];
    for (int intAccIdx = 0; intAccIdx < intAccountCount; intAccIdx++)
    rtnListOfAccount[intAccIdx] = new Account1();
    rtnListOfAccount[intAccIdx].ListOfOpportunity =
    new
    Opportunity[intOpportunityCount];
    rtnListOfAccount[intAccIdx].ListOfRevenue =
    new Revenue[intRevenueCount];
    for (int intOppIdx = 0; intOppIdx < intOpportunityCount;
    intOppIdx++)
    rtnListOfAccount[intAccIdx].ListOfOpportunity[intOppIdx] =
    new Opportunity();
    for (int intRevIdx = 0; intRevIdx < intRevenueCount; intRevIdx++)
    rtnListOfAccount[intAccIdx].ListOfRevenue[intRevIdx] =
    new Revenue();
    return rtnListOfAccount;
    catch (Exception objExcep)
    throw objExcep;
    public AccountWS_AccountQueryPage_Output RetrieveQueryPageOutput(
    AccountWS_AccountQueryPage_Input qpinput,
    Session session)
    AccountWS_AccountQueryPage_Output qpoutput = null;
    // instantiate the proxy service
    Account accountProxy = new Account();
    try
    // set up the target URL & set the session cookie
    accountProxy.Url = session.GetURL();
    accountProxy.CookieContainer = session.GetCookieContainer();
    qpoutput = accountProxy.AccountQueryPage(qpinput);
    catch (Exception e)
    Response.Write("<br/><br/>" + e.InnerException);
    Response.Write("<br/><br/>" + e.Message);
    Response.Write("<br/><br/>" + e.StackTrace);
    return qpoutput;
    10-27-2006 02:31 PM
    Re: how to access Revenue records
    algocode
    New Contributor
    I found another way to access Revenue records. Instead of accessing the
    ListOfRevenue field of the Account web service, I access the ListOfProduct
    field of the Opportunity web service. I also instantiate Opportunity2
    objects so that the code to get a list of opportunities and products
    (containing revenue fields) becomes
    Opportunity2[] rtnListOfOpportunity = new
    Opportunity2[intOpportunityCount];
    try
    for (int intOppIdx = 0; intOppIdx < intOpportunityCount;
    intOppIdx++)
    rtnListOfOpportunity[intOppIdx] = new Opportunity2();
    rtnListOfOpportunity[intOppIdx].ListOfProduct =
    new Product[intProductCount];
    for (int intProdIdx = 0; intProdIdx < intProductCount;
    intProdIdx++)
    rtnListOfOpportunity[intOppIdx].ListOfProduct[intProdIdx] =
    new Product();
    return rtnListOfOpportunity;
    10-28-2006 11:17 AM
    Re: how to access Revenue records
    Echo
    Valued Contributor
    Weird. I'm not a big C# programmer but the code looks right. I'm curious -
    could you post some soap loads of the request. I'm wondering if there's
    something weird going on with the proxy.
    10-31-2006 12:00 AM

    I Assume the following is your sample data
    Table Name: Tab1
    RegID CustID Registration_Start      Registration_End
    1      1      01/04/2005           07/04/2005
    2      2      01/03/2005           29/05/2005
    3      1      21/03/2005           29/03/2005
    4      1      01/03/2005           21/03/2005
    Note : For the Regid "4" I have changed the Registration_End to 21/03/2005. It was earlier 21/04/2005.
    Coming to the query, you need to generate the list of regid that have gaps.
    Try the following query:
    SELECT c.*
    FROM tab1 c
    WHERE c.reg_id NOT IN (
    SELECT a.reg_id
    FROM tab1 a, tab1 b
    WHERE a.cust_id = b.cust_id
    AND a.registration_end = b.registration_start
    Note: I am sorry I didn't have access to the data base to execute my query. Correct me if I am wrong.
    Regards,
    Somu

  • How to store data from a complex query and only fresh hourly or daily?

    We have a report which runs quite slow (1-2 minutes) because the query is quite complicate, so we would like to run this query daily only and store in a table so for those procedures that need to use this complex query as a subquery, can just join to this table directly to get results.
    However, I am not sure what kind of object I should use to store data for this complex query. Is data in global temp table only persist within transaction? I need something that can persist the data and be access by procedures.
    Any suggestions are welcome,
    Cheers

    Thank you for your reply. I looked at the materialized view earlier on, but have some difficulties to use it. So I have some questions here:
    1.The complex query is not a sum or aggregate functions, it just need to get data from different tables based on different conditions, in this case is it still appropriate to use meterialized view?
    2.If it is, I created one, but how to use it in my procedure? From the articles I read, it seems I can't just query from this view directly. So do I need to keep the complex query in my procedure and how the procedure will use the meterialized view instead?
    3. I also put the complex query in a normal view, then create a materialized view for this normal view (I expect the data from the complex query will be cache here), then in the procedure I just select * from my_NormalView, but it takes the same time to run even when I set the QUERY_REWRITE_ENABLED to true in the alter session. So I am not sure what else I need to do to make sure the procedure use the materialized view instead of the normal view. Can I query from the Materialized View directly?
    Below in the code I copied from one of the article to create the materialized view based on my normal view:
    CREATE MATERIALIZED VIEW HK3ControlDB.MW_RIRating
    PCTFREE 5 PCTUSED 60
    TABLESPACE "USERS"
    STORAGE (INITIAL 50K NEXT 50K)
    USING INDEX STORAGE (INITIAL 25K NEXT 25K)
    REFRESH START WITH ROUND(SYSDATE + 1) + 11/24
    NEXT NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 15/24
    enable query rewrite
    AS SELECT * FROM HK3ControlDB.VW_RIRating;
    Cheers

  • How to delete the duplicate data  from PSA Table

    Dear All,
    How to delete the duplicate data  from PSA Table, I have the purchase cube and I am getting the data from Item data source.
    In PSA table, I found the some cancellation records for that particular records quantity  would be negative for the same record value would be positive.
    Due to this reason the quantity is updated to target but the values would summarized and got  the summarized value  of all normal and cancellation .
    Please let me know the solution how to delete the data while updating to the target.
    Thanks
    Regards,
    Sai

    Hi,
    in deleting the records in PSA table difficult and how many you will the delete.
    you can achieve the different ways.
    1. creating the DSO maintain the some key fields it will overwrite the based on key fields.
    2. you can write the ABAP logic deleting the duplicate records at info package level check with the your ABAPer.
    3.you can restrict the cancellation records at query level.
    Thanks,
    Phani.

Maybe you are looking for

  • How to work so I can re-build from backed-up AVCHD files if I need.

    Trying a new title to see if anyone can help. I'm recording on an AVCHD card, and have two ways of capturing this to FCP and backing up. 1) USB - Log and Transfer straight from the camera. Then copy the card contents to a spare usb drive for storage.

  • What is the average lifespan of the mac book

    what is the average lifespan of the mac book

  • How much memory is allocated to windows in boot camp?

    I have a 2 GHz Intel Core Duo iMac running Snow Leopard with 2 GB of RAM (maxed) circa 2006, the last big white iMac.  It runs very well.  Since I need to use a Windows software program for a work function I installed Fusion and Windows XP a few year

  • How can I use a where in Select clause?

    How can I use a where in select clasue when the other part of the where I do not not. I mean that Select * from mara where MATNR = MT* That means it can have MTA, MTB, MTC....and so on I can I write this code. Regards, Subhasish

  • Post long text in ' F-65 '.

    Hi experts, I have a program to upload to ' f-65 ' tcode, from the flat file. i uploaded using bdc, there is an error in long text, as per my requirement it should be more than 200characters, but in the posting it accepting only 72characters only, if