Showing posts with label real. Show all posts
Showing posts with label real. Show all posts

Sunday, March 11, 2012

Assigning FOREIGN KEY, which method is correct?

Hi guys,

I am real new to SQL and just like to clear up some questions regarding to assigning FOREIGN KEY.

Are there any differences in assigning foreign keys this way:

CREATE TABLE NURSE
(EMP_ID VARCHAR2(8) CONSTRAINT fk_nurse_emp REFERENCES EMPLOYEE(EMP_ID),
WARD_ID VARCHAR2(8) CONSTRAINT fk_nurse_ward REFERENCES WARD(WARD_ID),
CONSTRAINT pk_nurse PRIMARY KEY(EMP_ID, WARD_ID));

and this way:

CREATE TABLE NURSE
(EMP_ID VARCHAR2(8),
WARD_ID VARCHAR2(8),
CONSTRAINT fk_nurse_emp FOREIGN KEY(EMP_ID) REFERENCES EMPLOYEE(EMP_ID),
CONSTRAINT fk_nurse_ward FOREIGN KEY(WARD_ID) REFERENCES WARD(WARD_ID),
CONSTRAINT pk_nurse PRIMARY KEY(EMP_ID, WARD_ID));

What are the differences between them?

Many thanks.No difference - except that you couldn't create a composite foreign key with the first method. They are just alternatives.|||Thank you for clearing this up for me andrewst.

Another question, might not be all that important, but which is the preferred method?

I guess the second method is more preferred, as it clearly identifies the FOREIGN KEYS, but it takes more lines. I just like to learn the basic conventions first and stick to it.|||Well it's really a matter of personal taste and/or company policy. But since the second syntax works for all foreign keys and the first works only for single-column foreign keys, the second syntax could be preferred.

Saturday, February 25, 2012

Assembly: returning "Globals!ReportName" but letting RS see it as code, not text?

I'm trying to make a reusable header function. In it, there is the report name and a couple other bits of info. The problem is making RS use the real report name

If I return "Globals!ReportName" in an assembly function, then call that function, I get that exact text - but what I really want is the report name. I understand what it's doing, but how to I trick it:

Is there some way to make RS aware of the fact that this is meant to be seen as something it needs to evaluate rather than just displaying the actual text?

How about passing the report name to your function as a parameter and then return the name in the return value?|||

that might be an option.

It's very similar to what i have in place - just appending the report name to the return value.

|||You probably tried this, but would it work to set a variable = Globals!ReportName.Value and then concatenate the variable with your other strings?
|||If you mean in the .net assembly, I just tried it and no luck, but thanks. It seems any text returned is taken to be literal, not code. I even tried something like {Globals!ReportName} - hoping to get lucky, but didn't.