?
Solved

"Database Name" -- How to display it on a Crystal Report?

Posted on 2005-03-31
10
Medium Priority
?
2,565 Views
Last Modified: 2016-07-20
I'm using an external tool to make some changes on some Crystal Reports, and just wanted to check if the change to "database server" took effect when I preview the report.  

So, is there a way for me to Display the Database Name on a Crystal Report (so I can quickly see if my changes took effect in my tool's viewer, and to show the difference between the "production" report and the new "test" reports I'm modifying)?
0
Comment
Question by:quellcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13673027
Since the database will be set in your application you can just send it over as a parameter or set the value of a textfield.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13673140
You could also use a formula that gets set by the application.

mlmcc
0
 

Author Comment

by:quellcoder
ID: 13673148
By "external tool", I mean rptInspector, which makes changes to Crystal Reports (fonts, database location, formulas, etc -- neat in concept, but I'm just now getting into it, so don't know just yet if I'd recommend it, btw).  

So, in response the BriCrowe, I'm not "sending" the database name over as I call the report.  I just need the syntax or function on how to display the database name in a text-box on the report, so I can 1) see it when I print the test reports, and 2) make sure the test reports are actually pointing the test server (I guess I can "look" for test data, but the concept would be the reports would show almost identical data results).
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 13

Accepted Solution

by:
vidru earned 300 total points
ID: 13673212
Try using a SQL Expression field (if your type of db connectivity supports it).  It has a cross-db-platform function that gets the database name (under Functions > System > DATABASE()):

{fn DATABASE()}

-dave
0
 

Author Comment

by:quellcoder
ID: 13673403
How?  (sorry)
I did the following (trying to be detailed here, in case there is another way I'm supposed to do it).

I opened the report in Crystal Reports, went to FormulaFields, New, gave it a name, UseEditor, and I pasted in " {fn DATABASE()} ", but when I did "Check Formula", I got the error of "The Field Name is not known.".

(and I tried both "Crystal Syntax" or "Basic Syntax" in the editor.)
0
 
LVL 13

Expert Comment

by:vidru
ID: 13673457
Instead of Formula Fields, do you see SQL Expression Fields?  If you don't see it, then you can't use it - that would mean your db/connectivity doesn't support their use.  If you do see it, that's where you'd write the formula.

-dave
0
 

Author Comment

by:quellcoder
ID: 13673491
oh.  
No, it's not a node in Field Explorer. I also looked up SQL Expressions in the Crystal Help, and it shows "where it would be", and it's not there. I'm using Oracle 9i, Crystal Reports 9.   (But, that would have been Very Handy for other sql syntax that I Could have used. Thanks).

ok, any additional suggestions?
0
 
LVL 13

Expert Comment

by:vidru
ID: 13673808
The long way #1:
Try running the report, then going to Datbase > Show SQL Query to see if the correct database is being used.

The longer way #2:
Use the 'Add Command' option to add another 'table' to the report(s) that uses the valid syntax for Oracle to get the current database name.  The text of the Command would look like this (I have no idea what the Oracle syntax for retrieving the current database name is, so you'll have to find that):

SELECT <Oracle function to get the current database name>
  FROM Dual

I'm surprised that SQL Expression fields aren't an option with Oracle 9i.  Are your reports using stored procedures (that would also be an instance where SQL Expressions aren't allowed)?

-dave
0
 

Author Comment

by:quellcoder
ID: 13684561
Two "solutions" in one page.    

The Original Q, AND, How make "SQL Expression Fields" show up in Field Explorer:
I went into Record Selection, and it put me in "Formula Workshop" --- and a node for "SQL Expression Fields" is in that tree.
I created a new field (using the {fn DATABASE()} mentioned above by "vidru" -- thanks),
and "checked it", and saved.  
It now shows up in Field Explorer, and I can just insert that new field onto my report. AND IT WORKS GREAT!

Also, now every time I open Crystal Reports, the "SQL Expression Fields" node is always available in the Field Explorer.

====================
Also, as an aside, I created my own 'function' to use in SQL if I need it (following Vidru's last suggestion).

CREATE OR REPLACE FUNCTION Get_Dbname
RETURN VARCHAR2
IS
  vName VARCHAR2(100);
BEGIN
   SELECT name INTO vName FROM v$database;
   RETURN(vName);
END;
/

And, I'd call it with:   SELECT Get_Dbname FROM dual;

============

So, the "SQL Expression Field" using {fn DATABASE()} was the solution to this question. Thanks.
 
0
 
LVL 1

Expert Comment

by:tcalbaz
ID: 41721477
I know its way after the fact but I  found another solution to getting the Server Name.  With what ever Selection method you're using just add one more field.  ie:  

SELECT Field1, Field2, SELECT @@SERVERNAME AS MyServer FROM MyTable

That field MyServer will be available in the report where ever you want to place it.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 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