dbTalk Databases Forums  

Embed a string in a SQL-Statement in Dynamic PL/SQL

comp.database.oracle comp.database.oracle


Discuss Embed a string in a SQL-Statement in Dynamic PL/SQL in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jürg Schaufelberger
 
Posts: n/a

Default Embed a string in a SQL-Statement in Dynamic PL/SQL - 09-22-2004 , 02:35 PM






Hello

I work with oracle 8.1.7 and I wrote the following procedure

CREATE OR REPLACE PROCEDURE SetPointDeleted (
PointFeatureTable VARCHAR2, PunktFID NUMBER, MutID NUMBER)
AS
OS_User4Char VARCHAR2(6);
aStatement VARCHAR(500);
...
BEGIN
SELECT sys_context('userenv', 'os_user') INTO OS_User4Char FROM dual;
...
aStatement := 'update '||T_geo||' LG set LG.deleted = 1,
LG.mutation_id_deleted = '||MutID||',
LG.mutation_status_deleted = 3,
LG.user_deleted = '||OS_User4Char||',
LG.date_deleted = SYSDATE
where LG.deleted = 0 and exists (
select 1
from '||T||' L
where L.fid = '||FID_T||' and L.gid = LG.gid)';
EXECUTE IMMEDIATE aStatement;
...
END;
/
SHOW ERRORS;
COMMIT;

It is compiled successfully, but if I execute it, I get the message:
ErrorMessage : ORA-00904:

The column OS_User4Char does not exists ! How can I embed the value of
OS_User4Char which contents for example 'mere' in the String 'aStatement' ?
Thank you for help.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.