如何检查条件并将文本写入文本文件oracle形式 [英] How to check conditions and write text into text file oracle forms

查看:164
本文介绍了如何检查条件并将文本写入文本文件oracle形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Oracle Forms中创建过程,在其中检查验证数据并将数据插入表中.同时检查验证数据.如果条件为true,则将一些文本写入文本文件;如果条件为true,则将一些文本写入文本文件.

I am creating Procedure in Oracle Forms in which Check Validation data and insert data into table. Also check Validation data If condition true then write Some texts into text file and If condition is not true then write some texts into text file.

赞:

Validation No.1 : OK
Validation No.2 : OK

我成功地为"TRUE"条件创建了过程.现在我想要如果一个条件为True而第二个条件为False,则将文本写入文本文件.

I created procedure successfully for "TRUE" Condition. Now I want If One Condition is True and 2nd Condition is False then write texts into text file.

赞:

Validation No.1 : OK
Validation No.2 : ERROR

如果两个条件都为"FALSE",那么

And If both conditions "FALSE" Then

Validation No.1 : ERROR
Validation No.2 : ERROR

代码:

PROCEDURE VALIDATION_TEST
(p_mid we_group_hof_k.mstatusid%TYPE,  
 p_status we_group_hof_k.cardstatus%TYPE
) is

LC$Line  Varchar2(4000);
TFile    CLIENT_TEXT_IO.FILE_TYPE ;

begin
insert into test
select mstatusid, cardstatus
from we_group_hof_k
where mstatusid = p_mid 
and cardstatus = p_status;

IF p_mid = 1 AND p_status = 'A' THEN
LC$Line := 'log_' || TO_CHAR (SYSDATE, 'yyyymmdd_HH24miss') || '.log';
TFile := CLIENT_TEXT_IO.FOpen( 'E:\HMIS\State\test.log', 'W' );
CLIENT_TEXT_IO.put_line (TFile, 'Log file ' || LC$Line);
CLIENT_TEXT_IO.new_line (TFile);
CLIENT_TEXT_IO.put_line (TFile, 'Job started at: ' || TO_CHAR (SYSDATE, 'dd-mm-yyyy HH24:mi:ss'));
CLIENT_TEXT_IO.new_line (TFile);
CLIENT_TEXT_IO.put_line (TFile, 'Validation No.1 : ' || 'OK');

CLIENT_TEXT_IO.new_line (TFile);
CLIENT_TEXT_IO.put_line (TFile, 'Validation No.2 : ' || 'OK');

CLIENT_TEXT_IO.fclose (TFile);

END IF;
end;

推荐答案

您尚未告诉我们实际的条件是什么,因此您需要填写详细信息.

You haven't told us what the conditions actually are so you'll need to fill in the details.

CLIENT_TEXT_IO.put (TFile, 'Validation No.1 : ' );
if condition_1 then
    CLIENT_TEXT_IO.put_line (TFile, 'OK');
else
    CLIENT_TEXT_IO.put_line (TFile, 'ERROR');
end if;

CLIENT_TEXT_IO.new_line (TFile);

CLIENT_TEXT_IO.put (TFile, 'Validation No.2 : ' );
if condition_2 then
    CLIENT_TEXT_IO.put_line (TFile, 'OK');
else
    CLIENT_TEXT_IO.put_line (TFile, 'ERROR');
end if;

我总共有15个条件

I have total 15 Conditions

在这种情况下,您可能需要将其包装到辅助函数中:

In which case you might want to wrap that up into helper function:

PROCEDURE VALIDATION_TEST (p_mid we_group_hof_k.mstatusid%TYPE,  
 p_status we_group_hof_k.cardstatus%TYPE ) is    
    LC$Line  Varchar2(4000);
    TFile    CLIENT_TEXT_IO.FILE_TYPE ;

    procedure print_validation (
        p_file in CLIENT_TEXT_IO.FILE_TYPE
        , p_validation_number in number
        , p_condition in Boolean )
    is
    begin
        CLIENT_TEXT_IO.new_line (p_file);            
        CLIENT_TEXT_IO.put (p_file, 'Validation No.'||to_char(p_validation_number) || ': ' );
        if p_condition then
            CLIENT_TEXT_IO.put_line (p_file, 'OK');
        else
            CLIENT_TEXT_IO.put_line (p_file, 'ERROR');
        end if;
    end print_validation;    
begin
    insert into test
    select mstatusid, cardstatus
    from we_group_hof_k
    where mstatusid = p_mid 
    and cardstatus = p_status;

    IF p_mid = 1 AND p_status = 'A' THEN        
        LC$Line := 'log_' || TO_CHAR (SYSDATE, 'yyyymmdd_HH24miss') || '.log';
        TFile := CLIENT_TEXT_IO.FOpen( 'E:\HMIS\State\test.log', 'W' );
        CLIENT_TEXT_IO.put_line (TFile, 'Log file ' || LC$Line);

        print_validation(TFile, 1, condition_1);
        print_validation(TFile, 2, condition_2);
        ...
        print_validation(TFile, 15, condition_15);

        CLIENT_TEXT_IO.fclose (TFile);

    END IF;
end; 

这篇关于如何检查条件并将文本写入文本文件oracle形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆