may be stored procedure.

I Have Table T1(A,B,C) and I have a Table t2(D,E,F).

when ever i want to insert on table t1 in coulmn A,B,C. I want to insert it into table T2 same value for clumns in T1 + may be  appending some additional value to table t2 or .

what would be the best approach and can i sample code for it.

for ex:
if insert (USA,UK,IND) in to T1 i need to pass values and append 001 for USA and 044 to uk and 091 to IND and it should insert like (USA001,UK044,IND091).

in above example 001,044,091 should be any value i want to append it to the value in table T1.
ajaybeldeAsked:
Who is Participating?
 
sdstuberCommented:
>> if it is manual for all values. how would i pass 6 values to SP

begin
 insert_two_table('USA','UK','IND','001','044','091');
end;
0
 
slightwv (䄆 Netminder) Commented:
An insert trigger on t1 might work.

Where are you getting the values to append?

I don't see how a stored procedure would work unless you have some 'new' flag in t1 that the procedure can process in batch mode.
0
 
ajaybeldeAuthor Commented:
its manual
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
slightwv (䄆 Netminder) Commented:
So how do you know what records in t1 need manual values added to t2?
0
 
sdstuberCommented:
something like this?


CREATE OR REPLACE PROCEDURE insert_two_table(
    p_a   IN VARCHAR2,
    p_b   IN VARCHAR2,
    p_c   IN VARCHAR2,
    p_d   IN VARCHAR2,
    p_e   IN VARCHAR2,
    p_f   IN VARCHAR2
)
IS
BEGIN
    INSERT INTO t1(a, b, c)
         VALUES (p_a, p_b, p_c);

    INSERT INTO t2(d, e, f)
         VALUES (p_a || p_d, p_b || p_e, p_c || p_f);
END;
0
 
ajaybeldeAuthor Commented:
@sdstuber
does  p_a ,p_b,p_c   is also need to be passed Manual?.

my req is whenver we insert  p_a ,p_b,p_c on t1(which is not manual)  it should insert VALUES in t2 (p_a || p_d, p_b || p_e, p_c || p_f) and i should able pass the values p_d, p_e, p_f manually where ever required
0
 
sdstuberCommented:
if a non manual process inserts a,b,c to t1
how do you imagine a user could possibly be prompted to manually enter d,e,f?

The request doesn't make sense to me.
0
 
ajaybeldeAuthor Commented:
if it is manual for all values. how would i pass 6 values to SP
0
 
slightwv (䄆 Netminder) Commented:
>>if it is manual for all values. how would i pass 6 values to SP

You need some way to flag the new rows in t1.  How do you plan on knowing what rows in t1 need to have some value appended in t2?   Will ALL the new values in t1 get appended with the same values in t2?

What does appending a value give you?

I would think the design would be something like: t2(A,B,C,D,E,F).

Then a trigger on t1 could pre-populate A,B and C in t2.  Then all you need to do is look for null values for D,E and F in t2 to get what rows need processing.

Even if you need them concatenated, you can create a view off of t2 to perform the concatenation:

create or replace view t2_vw as
select a||d a_d, b||e b_e, c||f c_f from t2 where d||e||f is not null;
0
 
awking00Commented:
What does the appended value do? From your example, it looks like it could be a numerical representation of the country code. That would mean for every value in T1, there would be a corresponding append value, which could be managed by a lookup table of some sort. If that's not the case and the values that get appended are truly random or at the mercy of someone's imagination, what good do they do? If there is some sort of criteria that define the values to be appended, I think you might still accomplish your intent with an after insert trigger that applies the criteria logic.
0
 
ajaybeldeAuthor Commented:
they are planning to prevent it from application logic
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.