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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

REPLACE Function or plsql function

384655Feb 17 2005 — edited Feb 18 2005
Hi,
I have the following tables:

persons p
-------
id
name
surname

emails e
------
emid
subject
sender
html_body
text_body

cods c
----
id --> fk on persons(id)
emid --> fk on emails(emid)
cod1
cod2
cod3

In the fields html_body and text_body I have some parameters that should be replaced dinamically.
These fields are:
NAME
SURNAME
COD1
COD2
COD3

I should replace those fields dinamically with the fields of tables persons and cods.

I have a procedure and inside I have a cursor like:
FOR cur IN (SELECT e.sender, e.subject,
REPLACE
(REPLACE
(REPLACE
(REPLACE(e.html_body,'_NAME_',p.name)
,'_SURNAME_',p.surname)
,'_COD1_',c.cod1)
,'_COD2_',c.cod2) AS html_text,
REPLACE
(REPLACE
(REPLACE
(REPLACE(e.text_body,'_NAME_',p.name)
,'_SURNAME_',p.surname)
,'_COD1_',c.cod1)
,'_COD2_',c.cod2) AS
text_text
FROM
person p,
emails e,
cods c
WHERE p.id=c.id
AND e.emid=c.emid)
LOOP
send email here
do some inesrts....

What I want to do is replace all those "REPLACE" statements with some function.
Does this have sense or doing it like this, even if it's confusing, is more correct and performaning?

Thanks in advance

Tarek
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2005
Added on Feb 17 2005
9 comments
568 views