473,625 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to modify stored proc for crystal report. Important.

24 New Member
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 1499
amitpatel66
2,367 Recognized Expert Top Contributor
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
9963
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
8427
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 together. I have two Crystal.NET and two ASP.NET books. None give a complete example. This is just crazy! The GUI approach does not seem to work with stored procedures that have parameters. Or maybe it's this damn SQL2004 beta. Anyway, all I want...
1
2273
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 grid i see the data in the front. So
1
1422
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 results in the Crystal Reports in the front. Our client would like to be exported to a .rtf file when an Export button is clicked on. I have no problem exporting it to(actually there was a problem converting to .pdf or Excel, it goes to the...
0
2849
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 "Date Range" and then pass the lower and upper date values to the @StartDate and @EndDate of my SPROC's range. Unfortunately when I try to build a report off of a SPROC havng two
2
4763
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. In two columns I have to make minor changes i.e put and = operator. I am encountering following problem: 1. When I open the report using Seagate crystal report for rational / 32 bit crystal Report Designer there are three columns which are...
0
1118
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
2665
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 READ ONLY transaction" In my proc i have insert ,update and delete statements. When i checked this error in google i got Check SET TRANSACTION ON in my crystal reports.
0
1982
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 contents of which comprise the call to a stored proc
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.