
프로시저와 함수...저는 할만큼 했습니다.
어딘가 뭐가 빠져서 안되는거 같은데..
도통 모르겠습니다..ㅠ.ㅠ
이거 진짜 제 사진입니다.
고수님들 제발 좀 도와주세요..ㅜ.ㅜ
#########################################################
1. 프로시저를 사용하려니..서브쿼리에서 에러가 나고..ㅠ.ㅠ
#########################################################
-------------
프로시저 선언
-------------
drop PROCEDURE idecode_proc;
SET TERM !! ;
CREATE PROCEDURE idecode_proc (arg1 integer, arg2 integer,
ifeq integer, ifneq integer )
RETURNS (decode integer)
AS
BEGIN
IF (:arg1 = :arg2) THEN
decode = :ifeq ;
ELSE
decode = :ifneq ;
SUSPEND ;
END !!
SET TERM ; !!
------------------------
서브쿼리로 프로시저 호출
------------------------
select count(*)
,(SELECT decode FROM idecode_proc(128,128,6,5))
from srch;
----
결과
----
Dynamic SQL Error
SQL error code = -104
invalid column reference
Statement: select count(*)
,(SELECT decode FROM idecode_proc(128,128,6,5))
from srch
##################################################################
2. DLL을 만들어서 function을 선언하려니 못찾겠다고 에러나고..ㅜ.ㅜ
##################################################################
-------
DLL생성
-------
library sol_udf;
uses
SysUtils,
Classes;
function MakeResultString(a, b:PChar; c:Integer):PChar; external 'FreeUDFLib.dll' name 'MakeResultString';
{$R *.RES}
function SOL_UDF_decode(value1, value2, matchResult, unmatchResult :PChar) :PChar ; cdecl; export;
var
s : String;
begin
if (strcomp(value1, value2) = 0) then s := matchResult
else s := unmatchResult;
Result := MakeResultString(PChar(s), nil, 0);
end;
begin
end.
-----------
DLL파일복사
-----------
C:\Program Files\Borland\InterBase\UDF 에 DLL넣고
--------
함수선언
--------
DROP EXTERNAL FUNCTION decode;
DECLARE EXTERNAL FUNCTION decode
CSTRING(80), CSTRING(80), CSTRING(80), CSTRING(80)
RETURNS CSTRING(80) /*FREE_IT*/
ENTRY_POINT 'SOL_UDF_decode' MODULE_NAME 'sol_udf';
--------
함수호출
--------
select decode('aaa','aaa','6','5')
from rdb$database
----
결과
----
Invalid request BLR at offset 63
function DECODE is not defined
module name or entrypoint could not be found
Statement: select decode('aaa','aaa','6','5')
from rdb$database