A:
使用Execsql的方法,客户需花费大量的时间在拼接字符串的工作上,资源和时间都不允许,本身效率也不高,可参考使用下面的方法,参考范例如下:
现有数据库:test,表:calendar
表的创建脚本如下:
USE [test]
GO
/****** Object: Table [dbo].[calendar] Script Date: 03/03/2011 21:43:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[calendar](
[symbol] [varchar](8) NULL,
[date_] [datetime] NULL,
[isedate] [bit] NULL,
[tclose] [numeric](9, 4) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
在天软安装目录\plguin\Execsql.ini中的配置如下:
[testsql]
ConnectStr=Provider=MSDAORA.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test;Data Source=localhost(请根据本地实际情况进行配置,此处为笔者本机的配置)
permit=local
在天软平台新建函数,代码如下:
Function Function94();
Begin
setsysparam(pn_stock(),'SZ000002'); a:=nday(10,'stocKid',getsysparam(pn_stock()),'d',datetostr(sp_time()),'isedate',istradeday(sp_time()),'c',close());
sqlstate:=rdo2 function93('calendar','testsql',a);
return sqlstate;
End;
Function Function93(table,dbname,a);
Begin
return Insert sqltable table of dbname insertfields(['date_'],['tclose'])
select ['d'] as 'date_',['c'] as 'tclose' from a end;
End;
运行function94后,如果返回结果为1则插入成功,查询数据库