用PLSQL自动生成数据库表的Delphi对象
DECLARE
TYPE TY_QUECUR IS REF CURSOR;
CUR_COLUMNS TY_QUECUR;
SQLCMD VARCHAR(500);
TABNAME VARCHAR(20);
COLNAME VARCHAR(50);
COLTYPE VARCHAR(20);
COLCOMMENT VARCHAR2(50);
COLLENGTH INTEGER;
COLPRECISION INTEGER;
I INTEGER;
COLLIST VARCHAR(1000);
VCOLLIST VARCHAR(1000);
DelphiDS VARCHAR2(20);
BEGIN
TABNAME:= 'DIC_USER';
DelphiDS:= '__DS';
I:= 0;
COLLIST:= '';
VCOLLIST:= '';
SQLCMD:= 'SELECT A.COLUMN_NAME, A.DATA_TYPE,B.COMMENTS,A.DATA_LENGTH,A.DATA_PRECISION '
||'from USER_TAB_COLUMNS A LEFT JOIN USER_COL_COMMENTS B '
||'ON A.COLUMN_NAME=B.COLUMN_NAME AND A.TABLE_NAME=B.TABLE_NAME WHERE A.TABLE_NAME= '''|| TABNAME || '''';
DBMS_OUTPUT.PUT_LINE('//==============================================================');
DBMS_OUTPUT.PUT_LINE('//生成Delphi对象');
DBMS_OUTPUT.PUT_LINE('//==============================================================');
DBMS_OUTPUT.PUT_LINE('unit u'|| INITCAP(TABNAME)||';');
DBMS_OUTPUT.PUT_LINE('interface');
DBMS_OUTPUT.PUT_LINE('uses Windows, Messages, SysUtils, Variants, Classes, DB, DBClient;');
DBMS_OUTPUT.PUT_LINE('Type');
Dbms_Output.PUT_LINE(' TEditMode=(emAppend, emEdit, emDelete);');
DBMS_OUTPUT.PUT_LINE(' T'||TABNAME||'= Class');
DBMS_OUTPUT.PUT_LINE('private');
DBMS_OUTPUT.PUT_LINE(' fCdsDatas: TClientDataSet;');
OPEN CUR_COLUMNS FOR SQLCMD;
FETCH CUR_COLUMNS INTO COLNAME, COLTYPE, COLCOMMENT, COLLENGTH, COLPRECISION;
WHILE CUR_COLUMNS%FOUND LOOP
IF I = 0 THEN
COLLIST:= COLNAME;
ELSE
COLLIST:= COLLIST || ', '|| COLNAME;
 
相关文档:
1. 产品类
{《HeadFirst设计模式》工厂模式之简单工厂 }
{ 产品类 }
{ 编译工具 :Delphi7.0 }
{ 联系方式 :xshlife@163.com }
unit uProducts;
interface
type
TPizza = class(TObject)
public
procedure Prepare; virt ......
模板方法模式定义了一个算法骨架,允许子类对算法的某个或某些步骤进行重写(override)。
1.CoffeineBeverageWithHook
{《HeadFirst设计模式》之模板方法模式 }
{ 编译工具: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uCoffeineBeverageWithHook;
interface
uses
SysUti ......
1.策略类
{《HeadFirst设计模式》之策略模式 }
{ 本单元中的类为策略类 }
{ 编译工具: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uStrategy;
interface
type
{飞行接口,及其实现类 }
IFlyBehavior = Interface(IInterface)
procedure Fly;
......
1. 命令的接收者
{《HeadFirst设计模式》之命令模式 }
{ 本单元中的类为命令的接收者 }
{ 编译工具 :Delphi7.0 }
{ 联系方式 :xshlife@163.com }
unit uReceiveObject;
interface
type
TLight = class(TObject)
private
FLocation: String;
public
constru ......
1. 命令的接受者
unit uReceiveObject;
interface
type
TLight = class(TObject)
public
procedure Open;
procedure Off;
end;
TGarageDoor = class(TObject)
public
procedure Up;
procedure Down;
procedure Stop;
procedure LightOn;
procedure LightOff;
end; ......