AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi Eine von einer Prozedur stammende datenmenge ändern
Thema durchsuchen
Ansicht
Themen-Optionen

Eine von einer Prozedur stammende datenmenge ändern

Ein Thema von Nightfly · begonnen am 5. Apr 2004 · letzter Beitrag vom 5. Apr 2004
Antwort Antwort
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
Benutzerbild von MrSpock
MrSpock
(Co-Admin)

Registriert seit: 7. Jun 2002
Ort: Owingen
5.865 Beiträge
 
Delphi 2010 Professional
 
#2

Re: Eine von einer Prozedur stammende datenmenge ändern

  Alt 5. Apr 2004, 18:26
Hallo Nightfly,

welche Datenbank nutzt du denn?

Mir ist außerdem nicht klar, was du genau vorhast. Nach einem Aufruf der Procedure mittels SELECT erhälst du eine Datenmenge mit den Feldern BEREICH, BEZ, ALLES, JAN, ..., DEZ. Die Monatswerte sind Summen aus der Tabelle Planung. Jetzt willst du diese Summen überschreiben!? Was soll denn dann passieren?
Albert
Live long and prosper


MrSpock
  Mit Zitat antworten Zitat
Nightfly

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

Re: Eine von einer Prozedur stammende datenmenge ändern

  Alt 5. Apr 2004, 22:04
die DB ist eine Firebird 1.5

Du hast schon sehr gut erkannt was ich machen will. Felder in denen eine berechnete Summe steht sollen gesperrt werden(das hab ich vergessen zu erwähnen).
Felder in denen nach dem berechnen noch ein null steht, sollen editierbar sein. In die tabelle planung soll dann ein ds eingefügt werden, mit dem eingegeben wert, dem monat (aus der spalte),dem bereich(aus derzeile) und jahr sowie stelle(als variablen verfügbar)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:39 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz