sqlserver中:
declare a varchar(400)
set a = ''
select a=a+name from name_table
在oracle中怎么实现在结果集中累加?
------解决方法--------------------------------------------------------
自己还不是不练!!
CREATE OR REPLACE FUNCTION get_all_col (tab VARCHAR2)
RETURN VARCHAR2
IS
col_c2 VARCHAR2 (4000);
sqlstr VARCHAR2 (4000);
BEGIN
sqlstr := ' select ';
FOR cur IN (SELECT column_name
FROM user_col_comments
WHERE table_name = UPPER (tab))
LOOP
col_c2 := col_c2 || cur.column_name || ',';
END LOOP;
col_c2 := RTRIM (col_c2, 1);
col_c2 := SUBSTR (col_c2, 1, LENGTH (col_c2) - 1);
sqlstr := sqlstr || col_c2 || ' from ' || tab;
EXECUTE IMMEDIATE sqlstr;
RETURN sqlstr;
END;
/