use wroxdb
go
--
--   Name:  get_order_template
--
--   Description: returns XML template for all entities in an order
--
--
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'get_order_template')
BEGIN
    DROP PROCEDURE get_order_template
END
GO
 
PRINT 'get_order_template'
GO
CREATE PROCEDURE get_order_template @xmlout varchar(4000) OUTPUT
AS
DECLARE @xml varchar(4000)
DECLARE @tmp varchar(4000)


	EXEC get_empty_xml 'orders', @tmp OUTPUT, 'order'
	SELECT @xml = @tmp

	EXEC get_empty_xml 'lines', @tmp OUTPUT, 'row'
	SELECT @xml = @xml + @tmp
	
	EXEC get_empty_xml 'payments', @tmp OUTPUT, 'row'
	SELECT @xml = @xml + @tmp

	SELECT @xmlout = "<template>" + @xml + "</template>"
 
GO
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'get_order_template')
   PRINT  '>>> Created procedure get_order_template <<<'
GO


/* test

DECLARE @xml varchar(4000)

EXEC get_order_template @xml OUTPUT
PRINT @xml

*/


