MySql stored procedures: How to select from procedure table?

后端 未结 3 1764
星月不相逢
星月不相逢 2020-12-28 13:49

Let\'s say we have a stored procedure selecting something from a table:

CREATE PROCEDURE database.getExamples() 
SELECT * FROM examples;

How can I use

相关标签:
3条回答
  • 2020-12-28 14:22

    Reformulated the question in this thread: Can a stored procedure/function return a table?. Obviously, it isn't possible without the use for temp tables.

    0 讨论(0)
  • 2020-12-28 14:23

    In SQL server you can then do SELECT * FROM database.getExamples()

    If you want to re-use the 'procedure' then, yes, I would put it into a table valued function.

    Otherwise you could just SELECT INTO a #temporary table inside the stored procedure.

    0 讨论(0)
  • 2020-12-28 14:36
    CREATE TABLE #TempTable
    (OID int IDENTITY (1,1),
    VAr1 varchar(128) NOT NULL,
    VAr2 varchar(128) NOT NULL)
    
    Populate temporary table
    
    INSERT INTO #TempTable(VAr1 , VAr2 )
    SELECT * FROM examples
    
    0 讨论(0)
提交回复
热议问题