create or replace procedure createTree(
anyChar in varchar
) as 
longStrSql varchar(255);
begin 
dbms_output.putline(strChar);
longStrSql:='select * from test1 t start with trim(t.name)='||strChar||''connect by prior trim(t.owner)=trim(t.name)';
dbms_output.put_line(longStrSql);
end;
运行 
call createTree('el');
发现el 的确传入了但是 当我打印longStrSql时才发现 其中的值为
select * from test1 t start with trim(t.name)='||strChar||'connect by prior trim(t.owner)=trim(t.name)
那位赐教一下 谢谢 

解决方案 »

  1.   

    小弟打错了参数 原题中将anyChar 改为 strChar 求教那位高手赐教
      

  2.   

    create or replace procedure createTree(
    strChar in varchar
    ) as  
    longStrSql varchar(255);
    begin  
    dbms_output.put_line(strChar);  -- 是put_line
    longStrSql:='select * from test1 t start with trim(t.name)='''    --两个单引号算一个
    ||strChar||'''connect by prior trim(t.owner)=trim(t.name)';
    dbms_output.put_line(longStrSql);
    end;
    EXEC createTree('el');39  PL/SQL block, executed in 0 sec.                                                             
        el                                                                                           
        select * from test1 t start with trim(t.name)='el'connect by prior trim(t.owner)=trim(t.name)
        Total execution time 0.015 sec.                                                              
      

  3.   


    create or replace procedure createTree(
    strChar in varchar
    ) as  
    longStrSql varchar(255);
    begin  
    dbms_output.put_line(strChar);  -- 是put_line
    longStrSql:='select * from test1 t start with trim(t.name)='''    --两个单引号算一个
    ||strChar||''' connect by prior trim(t.owner)=trim(t.name)';      --connect by 前空一格
    dbms_output.put_line(longStrSql);
    end;