Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Can some body help me with changing to the oracle sp.
I need help in reconstructing the oracle stored procedure as this
involves lot of global temporaty tables can any one help me with the
code.
---------------------------------SQL Version-----------------------------
declare @sSql varchar(4000)
SELECT @sSql = 'SELECT * INTO ##VIEW FROM ' + @view_name
IF DATALENGTH(@pfilter_txt) <> 0
BEGIN
SELECT @sSql = @sSql + ' WHERE Id=' + @pfilter_txt
END
exec(@sSql)
DECLARE @InternalName AS VARCHAR(50)
DECLARE @Value AS VARCHAR(50)
DECLARE DetailCursor CURSOR FOR
SELECT INTERNL_NME FROM #DATA_DEFINITION
OPEN DetailCursor
FETCH NEXT FROM DetailCursor INTO @InternalName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC('UPDATE #DATA_DEFINITION SET VALUE = (SELECT ISnull(' +
@InternalName + ','''') FROM ##VIEW) WHERE INTERNL_NME = ''' +
@InternalName + '''')
FETCH NEXT FROM DetailCursor INTO @InternalName
END
CLOSE DetailCursor
DEALLOCATE DetailCursor
SELECT SEQ_NUM,FLD_BUS_NME, VALUE /*, DATA_TYP_NUM */ FROM
#DATA_DEFINITION ORDER BY SEQ_NUM ASC
DROP TABLE #DATA_DEFINITION
DROP TABLE ##VIEW
COMMIT TRANSACTION
END
CREATE OR REPLACE PROCEDURE SP_STANDARDDETAIL(
INQ_NUM IN NUMBER, VIEW_NAME IN VARCHAR2, PFILTER_TXT IN VARCHAR2 DEFAULT NULL, P_CV1 IN OUT PK_COM_DEFS.CV_TYP
debug NUMBER(10,0) := 0; -- 0 = Debug off : 1 = Debug on
strValue VARCHAR2(2000); sqlStmt VARCHAR2(2000); InternalName VARCHAR2(50); TYPE DtaCurTyp IS REF CURSOR; DataCursor DtaCurTyp;
BEGIN
FOR i IN 0..(LENGTH(sqlStmt)-1)/80 LOOP
DBMS_OUTPUT.PUT_LINE(SUBSTR(sqlStmt, (i*80) + 1, 80)); END LOOP; EXECUTE IMMEDIATE sqlStmt USING strValue,INQ_NUM ;
FOR i IN 0..(LENGTH(sqlStmt)-1)/80 LOOP
DBMS_OUTPUT.PUT_LINE(SUBSTR(sqlStmt, (i*80) + 1, 80)); END LOOP; EXECUTE IMMEDIATE sqlStmt USING VIEW_NAME,PFILTER_TXT ;
--UPDATE THE RETURN DATASET WITH VALUES
OPEN DataCursor FOR 'SELECT INTERNL_NME FROM DATA_DEFINITION';
LOOP FETCH DataCursor INTO InternalName; EXIT WHEN DataCursor%NOTFOUND; -- process record EXECUTE IMMEDIATE 'UPDATE DATA_DEFINITION SET VALUE =(SELECT
END LOOP; CLOSE DataCursor ;
--RETURN DATASET
OPEN P_CV1 FOR 'SELECT SEQ_NUM,FLD_BUS_NME, VALUE FROM
DATA_DEFINITION ORDER BY SEQ_NUM ASC ';
SHOW ERRORS;
------------------------------Oracle version Ends ---------------------------
but this dosnt work can any one help regarding this. Received on Thu Nov 03 2005 - 11:42:34 CST