Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use Database Name as variable in Crystal report?

Status
Not open for further replies.

chrish47

MIS
Oct 6, 2002
29
US
Hi,

I am working on modifying a crystal report (that is used to print checks), and I would like to be able to modify the crystal report to print VOID across the check if it is not run out of our production database.

I know how to do this in the crystal report, but I don't know how to get the Database into a Variable so that I can check to see if it is our Production Database or not.

The delivered report is built in a database named PP750DVL, but when it is called from our system, it is passed a database name of either FSPRD or FSTST. I would like to figure out how to access this passed value in the crystal report to do my conditional formatting.

Is this possible? If so what is the code necessary to access the passed database name? Any help would be appreciated.

Thanks,
Chris Huss
Central Washington University
 
A minor omission here, what type of database are you using?

What version of Crystal?

You might use a SQL Expression to return this, in SQL Server you'd use:

db_name()

Then you can conditionally suppress a text box containing VOID based on the value returned.

-k
 
I am using Crystal 7.0 and I am accessing a PeopleSoft database (Oracle 8i, I think) using a stored procedure (ie. I have a Query in PeopleSoft that provides the data for the report).

This is an example of the Command Line that calls the Crystal Report in our TEST database:
Command Line = p:\fs750\bin\client\winx86\PSCRRUN -CXFSTST -CTORACLE -CDFSTST -COHUSSC -CP%OPRPSWD% -I154637 -RP"CWCHK1" -OT"3" -OP"NULL" -LG"ENG" -ORIENTP "RSTRT3" "1" "CWUID" "USB" "CHCK" "CHK"

The value passed for -CX and/or -CD (FSTST in the above example) is what I want to check in the report. So when the above report is generated I want to print VOID on the check because the Database is FSTST (using the text box with suppress method - this part I know how to do). I just don't know how to find the value passed from the run control to the Crystal Report in the report (if this is possible).

Thanks,
Chris

I don't think that I have access to do SQL from Crystal. I believe that the way our IT people set it up, we only have access to call stored procedures from Crystal.
 
Sorry, I'm not familiar with that product.

I'd guess that these values aren't getting passed to the report, so instead change the SP to return the server name.

You'll need select privileges on v_$database only, then the SP can return the database name by selecting on the sys.v_$database table

-k
 
The problem is that I can't get any privileges other than what I already have. I know that the value is being passed to the report (otherwise the crystal report wouldn't know which database to log into to get its data), I just don't know how to access the database name from the crystal report.

I have tried looking in developer help, and it looks like this info might be stored in Database Object or Report Object, but I don't know how to get it out of there.

Here is the Text from the Developer Help on Report Object:

Database Returns the Database Object which represents the database used in the report. Read only

This sounds like what I need, and there is some sample code, which appears to be VB, but it is creating a database and report object, when all I need to do is access the DB name that is passed. I am not sure if this can be done from inside Crystal or not.

Thanks,
Chris
 
Crystal doesn't have to know anything about a server, you can pass a recordset to a report, and even if they set the server name from their code, Crystal doesn't expose it in any way I know of.

I don't think that you'll get there from here...

-k
 
Doesn't Crystal have to know which database to log into in order to get its data? The report was built in PP750DVL, but when it is run from our system run control it logs into FSPRD to get its data, if I open the report in Crystal and try to run it, it tries to log into PP750DVL and doesn't generate a report because that database doesn't exist on our system. This would seem to indicate that it must know somewhere that the database has changed.

Anyway, this doesn't appear to be an easy solution to our security issue (printing valid checks from our FSTST database).

Thanks for your time, and I will keep trying. If I figure anything out I will post it here to share the information.

-C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top