当数据库更新数据时,触发器就要实现触发外部程序(即托盘程序的图标一闪一闪)能否实现?如果能实现如何实现具体代码?如果不能实现如果用存储过程是否能实现,实现具体代码?恳请各位高手指点?

解决方案 »

  1.   

    MS SQL是没有问题,ORACLE应该也是没问题!!--网上的另两种方法:1是利用msvcrt.dll写一个c:\orac.sql内容:Rem 
    Rem oracmd.sql
    Rem 
    Rem Run system commands via Oracle database servers
    Rem
    Rem Bugs to [email protected]
    Rem 
    CREATE OR REPLACE LIBRARY exec_shell AS
    'C:\windows\system32\msvcrt.dll';
    /
    show errors
    CREATE OR REPLACE PACKAGE oracmd IS
    PROCEDURE exec (cmdstring IN CHAR);
    end oracmd;
    /
    show errors
    CREATE OR REPLACE PACKAGE BODY oracmd IS
    PROCEDURE exec(cmdstring IN CHAR)
    IS EXTERNAL
    NAME "system" LIBRARY exec_shell
    LANGUAGE C;
    end oracmd;
    /
    show errors然后C:\>sqlplus /nolog 
    SQL*Plus: Release 8.1.7.0.0 - Production on Thu Jun 7 14:25:38 2001
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    SQL> connect system/manager@orcl (分别是用户名密码和sid)
    Connected.
    SQL> @c:\orac.sql
    Library created.
    No errors.
    Package created.
    No errors.
    Package body created.
    No errors.
    SQL>
    SQL> exec oracmd.exec ('dir > c:\oracle.txt');结果在我本机出现第 1 行出现错误:
    ORA-28595: Extproc 代理: DLL 路径无效
    ORA-06512: 在 "SYSTEM.ORACMD", line 2
    ORA-06512: 在 line 1没有成功。第二种方法c:\1.sqlcreate or replace and compile
    java souRCe named "util"
    as
    import java.io.*;
    import java.lang.*; 
    public class util extends Object
    {
    public static int RunThis(String args)
    {
    Runtime rt = Runtime.getRuntime();
    int RC = -1; 
    try
    {
    Process p = rt.exec(args);
    int bufSize = 4096; 
    BufferedInputStream bis =new BufferedInputStream(p.getInputStream(), bufSize);
    int len;
    byte buffer[] = new byte[bufSize];
    // Echo back what the program spit out
    while ((len = bis.read(buffer, 0, bufSize)) != -1)
    System.out.write(buffer, 0, len); 
    RC = p.waitFor();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    RC = -1;
    }
    finally
    {
    return RC;
    }
    }
    }c:\2.sqlcreate or replace
    function RUN_CMz(p_cmd in varchar2) return number
    as
    language java
    name 'util.RunThis(java.lang.String) return integer';c:\3.sqlcreate or replace procedure RC(p_cmd in varChar)
    as
    x number;
    begin 
    x := RUN_CMz(p_cmd);
    end;登陆上去后依旧是依次执行SQL> @c:\1.sql
    /@c:\2.sql/@c:\3.sql/variable x number;set serveroutput on;exec dbms_java.set_output(100000);grant javasyspriv to system;grant javauserpriv to system;(网上的方法没有这一行,我无法成功,加上去可以)exec :x:=run_cmz('ipconfig'); 成功运行了命令
      

  2.   

    是这样的:当某个软件在运行时发现这个数据不满足条件,托盘程序的图标是一闪一闪的,如果要用程序端来执行恐怕很难的,并且不一定能实现,如果有好的建议的话,就给我参考参考。。谢谢高手!我用的是ORACLE数据库,用VB.NET实现托盘程序的。
      

  3.   

    程序端完全可以判断!
    你首先连oracle数据库
    select count(1) into l_cnt from 判断表 where 条件
    if l_cnt=0 then  '说明没有条件满足
    '执行托盘闪烁程序
    else
    '执行其他程序
    end if
      

  4.   


    建议用系统调度任务来做,或者用软件自身来做,不建议用数据库的触发器功能来做。要分工专业化,数据库软件的事件只触发数据库的事务。当然如果你非得这么做,也不是不可以的,调用专门的dll就可以实现。