473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need to modify stored proc for crystal report. Important.

Need to modify the stored proc where we can add the REP_NAME. to an existing crystal report.
I will also need to order by REP_NAME and group by REP_NAME.
Many customer id's can belong to one Sales REP. I need help first on modify the stored proc below.

I must modify the procedure below and the two tables attached as code snippet can help get the
REP_NAME.
================================================== =============================
Instead by Customer we will do by SALESREP.

All this is the same
Expand|Select|Wrap|Line Numbers
  1. PROCEDURE GetSalesReportBySalesRep(
  2.               pcCompanyId IN CUST_BAL_D.COMPANY_ID%TYPE,
  3.               pcYearNo        IN CUST_BAL_D.YEAR_NO%TYPE,
  4.               pcPeriodNo   IN COMPANY_DET.PERIOD_NO%TYPE,
  5.               pCurSalesReportByCust OUT tmcSalesReportByCust
  6. )
  7. IS
  8. cLastYearNo CUST_BAL_D.YEAR_NO%TYPE;
  9.  
  10.  
  11. BEGIN
  12.  
  13.        cLastYearNo := TO_NUMBER(pcYearNo) - 1;
  14.  
  15.   OPEN pCurSalesReportByCust FOR
  16.  
  17. ****************> Just this select statement needs to be modified.
  18.               SELECT CU.CU_CUST_CODE AS CU_CUST_CODE,
  19.                            CU.CU_NAME,
  20.                          CU.POSTAL_CODE,
  21.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,pcYearNo,pcPeriodNo,'MONTH'),0) AS CURRENT_MTD,
  22.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,pcYearNo,pcPeriodNo,'YTD'),0) AS CURRENT_YTD,
  23.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,cLastYearNo,pcPeriodNo,'MONTH'),0) AS LAST_MTD,
  24.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,cLastYearNo,pcPeriodNo,'YTD'),0) AS LAST_YTD
  25.                 FROM CUSTOMER_D CU
  26.                WHERE CU.COMPANY_ID = pcCompanyId
  27.                ORDER BY 5 DESC;
  28.  
  29.  
  30. END GetSalesReportBySalesRep;
  31.  
  32. ----------------------------------------------------------------------------------------
  33. PROCEDURE GetSalesReportByCustomer(
  34.               pcCompanyId IN CUST_BAL_D.COMPANY_ID%TYPE,
  35.               pcYearNo        IN CUST_BAL_D.YEAR_NO%TYPE,
  36.               pcPeriodNo   IN COMPANY_DET.PERIOD_NO%TYPE,
  37.               pCurSalesReportByCust OUT tmcSalesReportByCust
  38. )
  39. IS
  40. cLastYearNo CUST_BAL_D.YEAR_NO%TYPE;
  41.  
  42.  
  43. BEGIN
  44.  
  45.        cLastYearNo := TO_NUMBER(pcYearNo) - 1;
  46.  
  47.  
  48.        OPEN pCurSalesReportByCust FOR
  49.                SELECT CU.CU_CUST_CODE AS CU_CUST_CODE,
  50.                            CU.CU_NAME,
  51.                          CU.POSTAL_CODE,
  52.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,pcYearNo,pcPeriodNo,'MONTH'),0) AS CURRENT_MTD,
  53.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,pcYearNo,pcPeriodNo,'YTD'),0) AS CURRENT_YTD,
  54.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,cLastYearNo,pcPeriodNo,'MONTH'),0) AS LAST_MTD,
  55.                          NVL(GetColumnAmount(CU.COMPANY_ID,CU.CU_CUST_CODE,cLastYearNo,pcPeriodNo,'YTD'),0) AS LAST_YTD
  56.                 FROM CUSTOMER_D CU
  57.                WHERE CU.COMPANY_ID = pcCompanyId
  58.                ORDER BY 5 DESC;
  59.  
  60.  
  61. END GetSalesReportByCustomer;
  62.  
  63.  
  64.  
  65. ==================================================================================================
  66. CREATE TABLE CUSTOMERS_PURCHASES_DETAILS ( 
  67.   COMPANY_ID            CHAR (2)      NOT NULL, 
  68.   CUSTOMER_ID           CHAR (12)     NOT NULL, 
  69.   DISCOUNT_BASE         NUMBER (5,2)  NOT NULL, 
  70.   DISCOUNT_ADD          NUMBER (5,2)  NOT NULL, 
  71.   PERCENT_TRANSPORT     NUMBER (5,2)  NOT NULL, 
  72.   FOB_CODE              CHAR (12), 
  73.   DEFAULT_ORDER_STATUS  CHAR (2), 
  74.   COMMENTS_TERMS        CHAR (30), 
  75.   INTERNAL_COMMENTS     VARCHAR2 (500), 
  76.   SALE_REP_ID           CHAR (4), 
  77.   COMMISSION_PC         NUMBER (5,2)  DEFAULT 0    NOT NULL, 
  78.   CONSTRAINT PK_CUSTOMERS_PURCHASES_DETAILS
  79.   PRIMARY KEY ( COMPANY_ID, CUSTOMER_ID ) 
  80.     USING INDEX 
  81.      TABLESPACE JT_CORE PCTFREE 10
  82.      STORAGE ( INITIAL 2600K NEXT 512K PCTINCREASE 0 )) 
  83.  TABLESPACE JT_CORE
  84.    PCTFREE 10   PCTUSED 40
  85.    INITRANS 1   MAXTRANS 255
  86.  STORAGE ( 
  87.    INITIAL 2600K NEXT 512K PCTINCREASE 0
  88.    MINEXTENTS 2 MAXEXTENTS 2147483645 )
  89.    NOCACHE; 
  90.  
  91.  
  92. ==================================================================================================
  93. CREATE TABLE SALES_REP ( 
  94.   COMPANY_ID           CHAR (2)      NOT NULL, 
  95.   SALES_REP_ID         CHAR (4)      NOT NULL, 
  96.   REP_NAME             VARCHAR2 (30)  NOT NULL, 
  97.   BRANCH               CHAR (5), 
  98.   ACTIVE_YN            CHAR (1)      DEFAULT 'Y', 
  99.   INITIALS             CHAR (3), 
  100.   ADDRESS1             VARCHAR2 (30), 
  101.   ADDRESS2             VARCHAR2 (30), 
  102.   ADDRESS3             VARCHAR2 (30), 
  103.   ADDRESS4             VARCHAR2 (30), 
  104.   ADDRESS5             VARCHAR2 (30), 
  105.   POSTAL_CODE          CHAR (10), 
  106.   CITY_ID              NUMBER (4), 
  107.   TELEPHONE1           VARCHAR2 (20), 
  108.   TELEPHONE2           VARCHAR2 (20), 
  109.   FAX1                 VARCHAR2 (20), 
  110.   FAX2                 VARCHAR2 (20), 
  111.   PAGETTE              VARCHAR2 (20), 
  112.   MOBILE               VARCHAR2 (20), 
  113.   EMAIL                VARCHAR2 (100), 
  114.   CREATION_DATE        DATE, 
  115.   CREATION_USER_ID     CHAR (8), 
  116.   LAST_UPDATE          DATE, 
  117.   LAST_UPDATE_USER_ID  CHAR (8), 
  118.   PLANT_ID             CHAR (4)      DEFAULT 'MAIN'  NOT NULL, 
  119.   CONSTRAINT PK_SALES_REP
  120.   PRIMARY KEY ( COMPANY_ID, SALES_REP_ID ) 
  121.     USING INDEX 
  122.      TABLESPACE JT_CORE PCTFREE 10
  123.      STORAGE ( INITIAL 2600K NEXT 512K PCTINCREASE 0 )) 
  124.  TABLESPACE JT_CORE
  125.    PCTFREE 10   PCTUSED 40
  126.    INITRANS 1   MAXTRANS 255
  127.  STORAGE ( 
  128.    INITIAL 2600K NEXT 512K PCTINCREASE 0
  129.    MINEXTENTS 2 MAXEXTENTS 2147483645 )
  130.    NOCACHE;
  131.  
Dec 18 '07 #1
1 1485
amitpatel66
2,367 Expert 2GB
Please make use of CODE tags when ever you post any source code in this forum.

MODERATOR
Dec 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Lalit Parashar | last post by:
Hi, I am clueless on how to integrate stored procedure in Crystal Reports using C#. Any pointers please? Thanks Lalit
2
by: Craig in Boulder | last post by:
I have been trying for over a week to get data from my stored procedure into a Crystal Report in VS.NET 2003 with no luck. I have all sorts of code parts but nothing that tell me how then go...
1
by: Learner | last post by:
Hi Friends, I am building the dataset programmatically by calling the stored proc by passing a parameter and i am getting the data into the dataset. As a test when i bind this dataset to a...
1
by: Learner | last post by:
HI Friends, I am brand new to creating Crystal reports. But overcomed a lot of problems and so far happy what i could accomplish, calling a stored proc with a parameter in it. And i can see the...
0
by: ZRexRider | last post by:
Hi, I've written reports based on stored procedures that receive parameters and it usually seems straight forward. Today I would like to use Crystal Reports parameter interface t prompt for a...
2
by: microsoft . public . sqlserver | last post by:
I am a Web developer. I am new to VB 6.0 and Crystal Report. I have joined an organisation where there is an application running(developed in VB6 and crystal report 7). I have to modify one report....
0
by: balurajeev | last post by:
Hi friends , I want to create a Crystal report in C# using Parameterised Storred Procedure This is my Stored Procedure ALTER proc . ( @fname varchar(50), @lname varchar(50),
2
by: Srilathap18783 | last post by:
My stored proc is compiled and executed in Toad. But if i try to attach that in crystal report i am getting an error number as "ORA-01456: may not perform insert/delete/update operation inside a...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.