1) 사이베이스DB에 프로시저를 생성하고 델파이에서 TStoredProc를 사용하여 DB와 프로시저를 셋팅해주었습니다.
2) property설정에서 active를 true로 설정하니 자꾸 parameter를 지정하라는 에러박스가 뜹니다.
3) 'RESULT_VALUE'와 나머지 변수들을 타입선언해줘야하는데 어떻게 해도 먹히질 않네요.
4) 대충 파라미터를 자정하고 나서 다시 active를 true로 설정해주면 다음의 에러메세지가 뜹니다.
5) 'Key violation,
[INTERSOLV][ODBC SQL Server driver][SQL SQL Server]The parameter '@listid' in
the procedure 'pr_random_extract' was not declared a
General SQL error.
an OUTPUT parameter. '
6) 여러 델파이 고수 여러분들께 답변 간곡히 부탁드립니다.(Please Help me~~~)
7) 참고로 제가 만든 프로시저의 내용이 아래에 있습니다.
CREATE PROCEDURE pr_random_extract
@listid INT,
@request_cnt INT
AS
DECLARE @multiplier DECIMAL,
@increment DECIMAL,
@Seed DECIMAL,
@rand_custid DECIMAL,
@insert_cnt DECIMAL,
@exist_cust_flag DECIMAL,
@exist_list_flag DECIMAL,
@total_cnt DECIMAL,
@max_custid DECIMAL,
@new_request_cnt DECIMAL,
@listseq_cnt INT,
@random_numbers DECIMAL,
@exist_num DECIMAL
select @multiplier = 22695477
select @increment = 1
select @Seed = 1
select @rand_custid = 0
select @insert_cnt = 0
select @exist_cust_flag = 0
select @exist_list_flag = 0
select @total_cnt = 0
select @max_custid = 0
select @new_request_cnt = 0
SELECT @max_custid = max(CUSTID) FROM TB_CUSTOMER
select @listseq_cnt = 1
WHILE @insert_cnt < @request_cnt
BEGIN
IF @insert_cnt < @request_cnt
------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT @Seed = ROUND(RAND() * 10000000000000000, 0) + convert(int,convert(char(2),getdate(),114))
select @Seed = ( @multiplier * @Seed + @increment ) / 65536 / 65536
IF @max_custid < 32767
BEGIN
select @random_numbers = convert(int, @Seed/65536) & convert(int, 32767)
select @random_numbers = convert(int, @random_numbers) % convert(int, @max_custid) + 1
END
ELSE
BEGIN
select @random_numbers = convert(int, floor(@Seed/65536)) & convert(int, @max_custid)
END
select @rand_custid = @random_numbers
SELECT @exist_num = count(*) FROM TB_CUSTOMER WHERE CUSTID = @rand_custid
IF @exist_num > 0
select @exist_num = 1
select @exist_cust_flag = @exist_num
IF @exist_cust_flag = 1
BEGIN
select @exist_num = 0
SELECT @exist_num = count(*) FROM TB_LIST WHERE LISTID = @listid AND CUSTID = @rand_custid
IF @exist_num > 0
select @exist_num = 1
select @exist_list_flag = @exist_num
IF @exist_list_flag = 0
BEGIN
INSERT INTO TB_LIST(LISTID, LISTSEQ, CUSTID, CUSTNAME, CUSTCHARGERID, PAGER, HANDPHONE, CUSTPHONE, ZIPCODE, ADDRESS, FAX, EMAILADDRESS )
SELECT @listid, @listseq_cnt, C.CUSTID, ltrim(rtrim(C.CUSTNAMEK)), C.CHARGERID, C.PAGER, C.HANDPHONE,
case when UPPER(C.MAILTOCD) = 'O' then C.O_PHONE when UPPER(C.MAILTOCD) = 'H' then C.H_PHONE else null end,
case when UPPER(C.MAILTOCD) = 'O' then C.O_ZIPCODE when UPPER(C.MAILTOCD) = 'H' then C.H_ZIPCODE else null end,
case when UPPER(C.MAILTOCD) = 'O' then rtrim(O.ADDRESS2) + ' ' + ltrim(C.O_ADDRESS)
when UPPER(C.MAILTOCD) = 'H' then rtrim(H.ADDRESS2) + ' ' + ltrim(C.H_ADDRESS) else null end,
case when UPPER(C.MAILTOCD) = 'O' then C.O_FAX when UPPER(C.MAILTOCD) = 'H' then C.H_FAX else null end,
EMAILADDRESS
FROM TB_CUSTOMER C,
TB_ZIP_CODE H,
TB_ZIP_CODE O
WHERE C.CUSTID = @rand_custid AND
C.o_zipcode *= O.zipcode AND
C.h_zipcode *= H.zipcode
select @insert_cnt = @insert_cnt + 1
select @listseq_cnt = @listseq_cnt + 1
END
END
END