Solved

Crystal Reports and Stored Proc and Dynamic Data

Posted on 2011-03-02
8
325 Views
Last Modified: 2012-05-11
I wonder if this is possible and if yes, can anyone tell me know to do it?
I'm creating report based on Crystal reports.
I'm going to use one stored proc for three different reports, and their primary parameter is going to be different.

like
order_id for report a,
customer_id for report b
employee_id for report c

while they all have some common fields, rest will be different.
(i'm using if statement to bring out those place holderS)
for exmaple

if order_id = 2
major id = 2 then generation order_number, order_amount, order_tiem

if customer_id is 1
major id = 2  then customer_name, customer_phone, customer_email

if employee_id 1
major id = 2 employee_name, experience... something like this

do you see what i mean?

There are going to be some fields that are common, but not all the fields are going to be the same.
Is this possible?
0
Comment
Question by:kmc10314
  • 4
  • 3
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Are you trying to change the fields selected in the stored procedure or are you changing something in the report?

mlmcc
0
 

Author Comment

by:kmc10314
Comment Utility
I have 3 differerent sets of datat that has their own number of fields.
The fields will be different for each key
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Do you have an SP that returns different data (fields) based on the parameter?

Crystal will have trouble with that.

mlmcc
0
 

Author Comment

by:kmc10314
Comment Utility
yeah i do.
so it is not going to work with crystal?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Can you change the SP?

You could have it return fields for all reports with some of them being NULL or 0 if they don't apply

The SP would be like

if @typeparam = 1 then
   SELECT Name, StreetAddress, City, State, Zip, 0 as ProductID, "" as ProductName, 0 as Cost FROM Address
Else
   SELECT "" as Name, "" as StreetAddress, "" as City, "" as State, "" as Zip, ProductID, ProductName, Cost FROM Address

Crystal could use that in 2 different reports.  Not sure why you would want to go that route rather than having an SP that specifically fits the requirement for the report.

mlmcc
0
 

Author Comment

by:kmc10314
Comment Utility
So basically, i have to use it like an union where i have to have all sets to have same # of placeholders in order for crystal to process
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 450 total points
Comment Utility
If you want 1 to work for all, yes.

You could overlap by putting ones with the same type in the same places but the first one would determine the field name.

mlmcc
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 50 total points
Comment Utility
FWIW, if you're going to use UNION, each SELECT is going to have to produce the same number of columns, with the same data type in each column, anyway.  That's just the way that UNION works (at least in MS SQL).

 Like mlmcc, I don't really see the point in trying to create a single procedure that reads different tables and produces different output for different reports, but I suppose you have your reasons.

 James
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now