🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #592

Recursive Stored Procedure

#592
From: Olivier Peter
Date: Sun, 14 Oct 2007 13:38
41 lines
1889 bytes
I have two tables T_PRODUCT_GENERAL and T_PRODUCTS_COMPOSITION.
The idea is that a products can consist of subproducts which in return can consist of subproducts ...

for example if i have a menu called "Steak with Peppersaus"
it's composed out of Steak and Peppersauce.
The peppersauce consists out of Pepper, flower, ...

So basically i want a stored procedure.
SP_PRODUCT_COMPOSITION(Steak with Peppersaus, 1) which returns
Steak, Pepper, flower, ...

RECREATE PROCEDURE SP_PRODUCT_COMPOSITION (
 IN_PRODUCTID        INTEGER,
 IN_PRODUCTQUANTITY  NUMERIC(8,2))
RETURNS (
 OUT_PRODUCTID       INTEGER,
 OUT_PRODUCTQUANTITY NUMERIC(8,2))
AS 
BEGIN
  ???
END

CREATE TABLE T_PRODUCT_GENERAL (
  PG_PRODUCTID      INTEGER NOT NULL,
  PG_PRODUCTNAME    VARCHAR(80),
  PG_PRODUCTPRICE   NUMERIC(8,2),
  PRIMARY KEY (PG_PRODUCTID)
);

CREATE TABLE T_PRODUCT_COMPOSITION (
  PC_COMPOSITIONID       INTEGER NOT NULL,
  PC_PRODUCTID           INTEGER,
  PC_SUBPRODUCTID        INTEGER,
  PC_SUBPRODUCTQUANTITY  NUMERIC(8,2),
  PRIMARY KEY (PC_COMPOSITIONID)
);

Any help would be appreciated.

Olivier Peter
Technical Details
Message-ID: <47121bc5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,7a6fad28b9fa39ec,start
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Olivier Peter" <peterolivier@hotmail.com>
Sender: "Olivier Peter" <peterolivier@hotmail.com>
Reply-To: "Olivier Peter" <peterolivier@hotmail.com>
Subject: Recursive Stored Procedure
Newsgroups: borland.public.interbase.sql
X-User-Info: 213.219.136.20     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <47121bc5$1@newsgroups.borland.com>
Date: 14 Oct 2007 06:38:13 -0700
X-Trace: newsgroups.borland.com 1192369093 207.105.83.66 (14 Oct 2007 06:38:13 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail