如何在存储过程中创建函数或视图 [英] how to create functions or views from within a stored procedure
问题描述
在存储过程中我知道你可以创建表或数据库或模式,但是可以创建一个函数或视图:
这里是我尝试的:
创建 PROCEDURE schemaName。 asd()
begin
DECLARE stmt VARCHAR ( 255 );
SET stmt:= concat(' CREATE FUNCTION schemaName.asdsfasdf()RETURNS int BEGIN return 1; end;');
PREPARE stmt FROM @ stmt ;
EXECUTE stmt;
end ;
当我这样做时
调用schemaName.asd()$$
我得到一个错误代码1064
是否可以在这里创建功能或视图?
如果是的话怎么办?
如果可以这样做一个简单的例子就可以了:)(我有mysql v5.1)
我得到一个错误代码1064
是否可以在这里创建函数或视图?
如果是,它怎么能可以吗?
如果可以这样做一个简单的例子就可以了:)(我有mysql v5.1)
< blockquote>我发现你不能,也许将来mysql会有这个功能。
in a stored procedure i know you can create tables or database or schema, but is it possible to create a function or a view:
here is what i tried:
create PROCEDURE schemaName.asd()
begin
DECLARE stmt VARCHAR(255);
SET stmt := concat('CREATE FUNCTION schemaName.asdsfasdf() RETURNS int BEGIN return 1; end;');
PREPARE stmt FROM @stmt;
EXECUTE stmt;
end;
when i do
call schemaName.asd()$$
and i get an ERROR CODE 1064
is it possible to create here functions or views?
if yes how can it be done?
if this can be done a simple example would be just fine :)(i have mysql v5.1)
and i get an ERROR CODE 1064
is it possible to create here functions or views?
if yes how can it be done?
if this can be done a simple example would be just fine :)(i have mysql v5.1)
i found out that you can''t, maybe in the future mysql will have this functionallity.
这篇关于如何在存储过程中创建函数或视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!