Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i concate a string in pl/sql

Status
Not open for further replies.

2314

Programmer
May 19, 2001
69
IN
how do i concate a string in pl/sql what i really need is to create a long sql select string in store procedure pass paramters to it and get back the value
 
what is want is to do this

create procedure getlastdgt(cmpny_cd varchar2(3),ctgry_cd varachar2(3),STR out VARCHAR2(200)) as
begin
str:='Select LST_DGT from EPAYPARAMETER where CMPNY_CD' || ''' || cmpny_cd || ''' || 'and ctgry_cd=' || ''' || || ctgry_cd || '''
print :str;
end
/

but i am getting errors
 
2314,

Here is completed code that returns what you want:
Code:
create or replace procedure getlastdgt
    (cmpny_cd varchar2,ctgry_cd varchar2,STR out VARCHAR2) as
begin
    str:='Select LST_DGT from EPAYPARAMETER where CMPNY_CD = ''' ||
        cmpny_cd ||''' and ctgry_cd = ''' ||ctgry_cd || '''';
end;
/

Procedure created.

var whatever varchar2(200)
var company varchar2(10)
var category varchar2(10)
exec :company := 'ABC'
exec :category := 'XYZ'
exec getlastdgt(:company,:category,:whatever)
select :whatever from dual;

Select LST_DGT from EPAYPARAMETER where CMPNY_CD = 'ABC' and ctgry_cd = 'XYZ'

Let us know if this is what you wanted.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
@ 16:08 (21Oct04) UTC (aka "GMT" and "Zulu"),
@ 09:08 (21Oct04) Mountain Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top