Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Populate new column results of a function:

leonhardtkJul 27 2009 — edited Jul 29 2009
I'm getting so close to have this project done! But my limited understanding of SQL is slowing me down!

Here's my situation:

I have a table "Family", that has several columns. The only ones I care about right now are:

family_first
family_middle
family_last

They are, unfortunately, in a foreign language that I cannot read! HOWEVER, there is a lookup table to translate them and thanks to some help from a previous post to Oracle OTN, my translating function works fine. I now want to create a new column and translate and append the three columns above into a single column:

family_full

Here's my function "TRANS_NAME":

create or replace function "TRANS_NAME"
(v_original) in VARCHAR2)
return VARCHAR2
is
v_translated varchar2(40);
begin
select TRANS into v_translated
FROM NAMES_TRANS
where ORIGINAL=v_original
and SOURCE="IC"
return v_translated;
end;

My query to show the translated values, and what I now want populated into family_full, is:

select TRANS_NAME(FAMILY_FIRST)||' '||
TRANS_NAME(FAMILY_MIDDLE)||' '||
TRANS_NAME(FAMILY_LAST) AS "FAMILY_FULL"
FROM FAMILY

I'm not sure how to insert this, I'm assuming it would be something like:

Insert into FAMILY (FAMILY_FULL) VALUES (
select TRANS_NAME(FAMILY_FIRST)||' '||
TRANS_NAME(FAMILY_MIDDLE)||' '||
TRANS_NAME(FAMILY_LAST) AS "FAMILY_FULL"
)

However when I try this, I get the following error:

ORA-00936: missing expression.

Thanks.

KSL.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2009
Added on Jul 27 2009
14 comments
2,160 views