在lua官方维基上,它说明了如何制作模块
CREATE TABLE [dbo].[SOURCE_TABLE]
(
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](250) NULL,
[Family] [nvarchar](250) NULL,
[Priority] [nvarchar](max) NULL,
[CreationDate] [nvarchar](250) NOT NULL
)
CREATE TABLE [dbo].[TARGET_TABLE]
(
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](250) NULL,
[Family] [nvarchar](250) NULL,
[Priority] [nvarchar](max) NULL,
[CreationDate] [datetime2] NOT NULL
)
MERGE TARGET_TABLE AS target
USING SOURCE_TABLE AS source ON (target.ID = source.ID)
WHEN NOT MATCHED THEN
INSERT ([Name], [Family], [Priority], [CreationDate])
VALUES (source.Name, source.Family, source.Priority,
CONVERT(DATETIME, source.CreationDate, 101))
WHEN MATCHED THEN
UPDATE SET target.Name = source.Name
target.Family = source.Family
target.Priority = source.Priority
target.CreationDate = CONVERT(DATETIME, source.CreationDate, 101)
但是你不能做
local mymodule = {}
function mymodule.foo()
print("Hello World!")
end
return mymodule
我熟悉Lua,但不是专家。那我写的东西有什么问题吗?
答案 0 :(得分:2)
您的方式非常好。
Wiki中的示例更适合于具有多个功能甚至可能包含私有数据的大型模块。