Einzelnen Beitrag anzeigen

Nightfly

Registriert seit: 25. Mär 2004
Ort: Dresden
118 Beiträge
 
#1

Eine von einer Prozedur stammende datenmenge ändern

  Alt 5. Apr 2004, 15:54
Es geht um folgende Prozedur:
SQL-Code:
CREATE PROCEDURE PLANSUMMIEREN (
    STELLE CHAR(9),
    JAHR INTEGER)
RETURNS (
    BEREICH INTEGER,
    BEZ CHAR(32),
    ALLES NUMERIC(9,2),
    JAN NUMERIC(9,2),
    FEB NUMERIC(9,2),
    MAR NUMERIC(9,2),
    APR NUMERIC(9,2),
    MAI NUMERIC(9,2),
    JUN NUMERIC(9,2),
    JUL NUMERIC(9,2),
    AUG NUMERIC(9,2),
    SEP NUMERIC(9,2),
    OKT NUMERIC(9,2),
    NOV NUMERIC(9,2),
    DEZ NUMERIC(9,2))
AS
begin
  for select ID,BEZ from MAIN B where B.STELLE = :stelle
  into :BEREICH, :BEZ do
  begin
    if (exists (select * from vorgabe where (ID = :bereich) and (del = 0))) then
    begin /* die direkten parents berechnen */
    if (not exists (select id from hauptkeys where id = :bereich)) then
      begin
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr
      into :ALLES;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 1
      into :JAN;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 2
      into :FEB;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 3
      into :MAR;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 4
      into :APR;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 5
      into :MAI;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 6
      into :JUN;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 7
      into :JUL;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 8
      into :AUG;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 9
      into :SEP;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 10
      into :OKT;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 11
      into :NOV;
      select sum(WERT) from PLANUNG P, MAIN M
      where (P.stelle = :stelle) and (M.stelle = P.Stelle) and (P.bereich = M.ID) and (M.parent = :BEREICH) and P.Jahr = :jahr and P.monat = 12
      into :DEZ;
      suspend;
      end
     end
end
Mittels eines DataSet wird diese über eine DataSource in einem DBGrid angezeigt. Im SelectSQL des Dataset steht also select * from plansummieren.

So, jetzt wirds haarig.

Ich würde gern im grid einfach drin rum schreiben können. Das jahr steht in einer variablen in meinem Programm. Den monat kann ich ja aus der spalte ermitteln. der wert für stelle steht ebenfalls in einer variablen meines programms, und der wert bereich lässt sich aus der zeile, in der die eingabe erfolgt,ermitteln
Also habe ich einen kompletten datensatz für die Tabelle Planung zusammen. Bloß wie bekomm ich die daten jetzt da rein?

In meinem Leichtsinn hab ich als InsertSQL in das Data set,welches oben beschriebenes select statement enthält,folgendes reingeschrieben:

INSERT INTO PLANUNG(stelle,bereich,wert,monat,jahr
)
VALUES(?stelle,?bereich,?wert,?monat,?jahr
)

Aber leider erfolglos,wäre ja auch zu einfach,wo soll der her wissen welche werte die variablen haben...

Ist mein vorhaben so überhaupt zu realisieren?
  Mit Zitat antworten Zitat