2006. 3. 17. 19:11ㆍ일 이야기
Private Sub procSearchData()
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
'db connection
GF_ConnectDB_SIMS
Set cmd = New ADODB.Command
cmd.ActiveConnection = g_SIMSDBConn ' 연결
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "PKG_SAMPLE.SAMPLE_SELECT"
'OUPUT 값
cmd.Parameters.Append cmd.CreateParameter("ERR", adVariant, adParamOutput)
'INPUT 값
cmd.Parameters.Append cmd.CreateParameter("S_DATE", adVarChar, adParamInput, 8, "20060501")
Set rs = cmd.Execute
Debug.Print "err:" & cmd(0)
If Not rs.EOF And Not rs.BOF Then
Do Until rs.EOF
Debug.Print rs("SDATE").Value
rs.MoveNext
Loop
End If
Set cmd = Nothing
GP_CloseDB_SIMS
End Sub
-------------------- DataBase ------------------------
---- Package Header
CREATE OR REPLACE PACKAGE UCMAS.PKG_SAMPLE AS
TYPE CUR_DATA IS REF CURSOR;
PROCEDURE SAMPLE_SELECT(ERR OUT VARCHAR2,
CREC OUT CUR_DATA,
S_DATE IN VARCHAR2);
END PKG_SAMPLE;
----- Package Body
CREATE OR REPLACE PACKAGE BODY UCMAS.PKG_SAMPLE AS
PROCEDURE SAMPLE_SELECT(ERR OUT VARCHAR2,
CREC OUT CUR_DATA,
S_DATE IN VARCHAR2
) IS
BEGIN
OPEN CREC FOR
SELECT SYSDATE AS SDATE FROM DUAL;
ERR:='TRUE';
END SAMPLE_SELECT;
END PKG_SAMPLE;