Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

There is an urgent requirement in our project related to SQL queries. I don't have much knowledge on SQL/script. Need to write a script with the following requirements (we should only use SQL queries and no PLSQL/functions).

Inputs to this script (Perl) - Primary Key1, Associated Value1

What it does: The script queries a table, table_t. This table has two columns: Primary Key and Associated Value. The script gets the Associated Value value for the Primary Key passed in the query. If the output is a CSV (comma separated value), then it appends Associated Value1 to the output and updates the value in the DB. If the output is NULL, then a new row is added with the value Primary Key1, Associated Value1.

Example:

BEFORE
Primary Key Associated Value

abc J1,J9

pqr

mno J8

xyz J3,J5



script(mno, J3);
script(pqr, J5);
script(xyz, J2);
script(efg, J6);

AFTER
Primary Key Associated Value

abc J1,J9

pqr J5

mno J8,J3

xyz J3,J5,J2

efg J6


Thanks in advace.

Regards
Deepu
Posted
Updated 10-Feb-10 9:07am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900