Home » SQL & PL/SQL » SQL & PL/SQL » Seperating a Value from a set of comma seperated values
Seperating a Value from a set of comma seperated values [message #211699] Mon, 01 January 2007 07:09 Go to next message
abcindiaxyz1
Messages: 2
Registered: January 2007
Location: Mumbai
Junior Member
Dear Experts,
I have a problem. It would be of immense help if you could resolve the issue.

ISSUE:
I have a primary key in a table (Say "abc")(E.g. It contains values like 022 in one row and 091 in another and 067 in another)
There is a column in another table (Say "xyz") where i have the primary key values seperated with a comma.(E.g.: "022,067,091,022,054")
Now my query is that, I want to find out the primary key value of table "abc" in the list of comma seperated values in table "xyz". If the primary key value does not exists, it has to appended to the list of the comma seperated values in the table "xyz" (E.g. There is a primary key value 008 in the table "abc", but it is absent in the "xyz" table. So this "008" has to be inserted into that row in the "xyz" table).

THANKS a LOT in Advance for those who reply.
Re: Seperating a Value from a set of comma seperated values [message #211704 is a reply to message #211699] Mon, 01 January 2007 09:34 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Check this Maaher's solution.
Re: Seperating a Value from a set of comma seperated values [message #211712 is a reply to message #211699] Mon, 01 January 2007 10:25 Go to previous messageGo to next message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
btw that sounds like a terrible data model. Why not have a second table to hold the set of keys? This would allow referential integrity as well as easy querying.

If you absolutely must have multivalue columns for some reason, Oracle provides nested tables for this. What is it with comma-separated lists?
Re: Seperating a Value from a set of comma seperated values [message #211717 is a reply to message #211699] Mon, 01 January 2007 11:56 Go to previous messageGo to next message
abcindiaxyz1
Messages: 2
Registered: January 2007
Location: Mumbai
Junior Member
Thanks for the reply.
But according to the COMPANY's Business requirement, that model had to be implemented
Re: Seperating a Value from a set of comma seperated values [message #211718 is a reply to message #211717] Mon, 01 January 2007 14:07 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Perhaps someone from the IT team should discourage Business Team from having such a model - you know, show them pros and contras.
Re: Seperating a Value from a set of comma seperated values [message #211721 is a reply to message #211699] Mon, 01 January 2007 14:40 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>But according to the COMPANY's Business requirement,
IMO, "requirements" do NOT dictate implementation details or storage models.
Ask those that insist on FUBAR model how they are going to solve THEIR problem.
Re: Seperating a Value from a set of comma seperated values [message #211722 is a reply to message #211721] Mon, 01 January 2007 17:15 Go to previous message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
What, it's the company's business requirement to use a comma-separated multivalue column rather than a nested table or two table design? Aren't business requirements and implementation details two completely separate things? The business doesn't know anything about programming, and it shouldn't have to.
Previous Topic: types of index
Next Topic: 1 statement to delete , update 2 tables
Goto Forum:
  


Current Time: Sat Dec 10 16:45:22 CST 2016

Total time taken to generate the page: 0.08721 seconds