Christopher
Christopher

Reputation: 691

Hiding output on specific columns

I have written a package that has a stored procedure and a REF cursor. I am able to now display all of the columns in my table through this cursor. I would like to be able to insert a loop that if a certain condition is met, four of the seven columns will show four asterisks and the rest of the columns will show up with their normal data.

For example, I have a column called country. Any time that USA appears in a record, the four columns of (empid, ss, address, dept) will need to only show **** while the rest of the columns will appear as normal. If a country that is not USA is in a record, then all columns will show the data as normal. I know there is a noprint function but I can't seem to figure out how to just show the asterisks.

Upvotes: 1

Views: 1134

Answers (1)

JNK
JNK

Reputation: 65157

Instead of using something complicated for this, just use a CASE expression:

SELECT CASE WHEN Country = 'USA' THEN '*****' Else EmpID END as EmpID

Upvotes: 5

Related Questions