AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi aktuelles Mwst.-Problem [SQL]
Thema durchsuchen
Ansicht
Themen-Optionen

aktuelles Mwst.-Problem [SQL]

Ein Thema von Hansa · begonnen am 12. Aug 2005 · letzter Beitrag vom 8. Sep 2005
Antwort Antwort
Seite 4 von 4   « Erste     234   
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#31

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 10:35
Hallo Alex,

mit oder ohne colon ist in IB6 egal - ist das beim FB15 anders?

Mit colon ist irgenwie konsistenter, er signalisiert ja sowas wie eine Dereferenzierung - den Zugriff auf den Inhalt.

Freundliche Grüße vom marabu
  Mit Zitat antworten Zitat
Hansa

Registriert seit: 9. Jun 2002
Ort: Saarland
7.554 Beiträge
 
Delphi 8 Professional
 
#32

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 11:37
An den Doppelpunkten liegts echt nicht. Ich habe den Fehler eingekreist :

SQL-Code:
CREATE TABLE MWST8 (
    ID INTEGER NOT NULL,
    ABDATUM DATE,
    MWSTSATZ SMALLINT,
    MWSTWERT DECIMAL(15,2),
    ANGELEGT TIMESTAMP,
    LETZTEAENDERUNG TIMESTAMP
);


INSERT INTO MWST8 (ID, ABDATUM, MWSTSATZ, MWSTWERT, ANGELEGT, LETZTEAENDERUNG) VALUES (1, '1998-04-01', 2, 16, '2005-09-03 12:26:31', NULL);
INSERT INTO MWST8 (ID, ABDATUM, MWSTSATZ, MWSTWERT, ANGELEGT, LETZTEAENDERUNG) VALUES (2, '1998-04-01', 1, 7, '2005-09-03 12:26:47', NULL);
INSERT INTO MWST8 (ID, ABDATUM, MWSTSATZ, MWSTWERT, ANGELEGT, LETZTEAENDERUNG) VALUES (3, '2005-04-01', 2, 18, '2005-04-01 00:00:00', '2005-09-04 16:50:21');
INSERT INTO MWST8 (ID, ABDATUM, MWSTSATZ, MWSTWERT, ANGELEGT, LETZTEAENDERUNG) VALUES (4, '1900-01-01', 2, 15, '2005-09-03 13:55:15', NULL);

COMMIT WORK;



/******************************************************************************/
/****                          Stored Procedures                           ****/
/******************************************************************************/


SET TERM ^ ;

ALTER PROCEDURE MWSTWERTSP8 (
    MONAT SMALLINT,
    JAHR SMALLINT,
    MWSTSATZ SMALLINT)
RETURNS (
    MWSTWERT NUMERIC(9,2))
AS
DECLARE VARIABLE DATUM DATE;
BEGIN
  DATUM = CAST('01.'|| MONAT || '.' || JAHR AS DATE);
  SELECT FIRST 1
    MWSTWERT
  FROM
    MWST8
  WHERE
    (MWSTSATZ=:MWSTSATZ) AND (ABDATUM <= :DATUM)
  ORDER BY
    ABDATUM DESC
  INTO
    :MWSTWERT;
  IF (MWSTSATZ is null) THEN
    MWSTSATZ = 0;
MWSTWERT = 10; <-------------------------------------------
  SUSPEND;
END
^
Setze ich den MWSTWERT von Hand auf 10 (siehe oben), dann stimmt auch der Bruttoumsatz auf der Grundlage von 10 % Mwst. Die verwendeten Testdaten sind auch dabei. Gebe ich 100 ein so kommt 110 dabei raus. Mache ich das nochmals dann ist es 220. Also richtig. Lasse ich den MWSTWERT von der SP ermitteln, ohne diese Zeile, dann gehts nicht. 8)
Gruß
Hansa
  Mit Zitat antworten Zitat
alex517

Registriert seit: 23. Nov 2004
Ort: Bernau b. Berlin
273 Beiträge
 
Delphi XE5 Enterprise
 
#33

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 11:40
Hi marabu,

Zitat von marabu:
mit oder ohne colon ist in IB6 egal - ist das beim FB15 anders?
Beim Zugriff auf Variablen in assignment statements einer SP wird laut Manual IB6
colon nicht gesetzt.
Im Gegensatz zu SELECT/UPDATE/INSERT.. -statements.

Zitat:
DataDef.pdf, CHAPTER 9 WORKING WITH STORED PROCEDURES INTERBASE 6

Using assignment statements
---------------------------
A procedure can assign values to variables with the syntax:
variable = expression;
where expression is any valid combination of variables, operators, and expressions, and
can include user-defined functions (UDFs) and generators.
A colon need not precede the variable name in an assignment statement. For example,
the following statement assigns a value of zero to the local variable, ANY_SALES:
any_sales = 0;

Variables should be assigned values of the datatype that they are declared to be. Numeric
variables should be assigned numeric values, and character variables assigned character
values. InterBase provides automatic type conversion. For example, a character variable
can be assigned a numeric value, and the numeric value is automatically converted to a
string. For more information on type conversion, see the Embedded SQL Guide.



Using SELECT statements
-----------------------
In a stored procedure, use the SELECT statement with an INTO clause to retrieve a single
row value from the database and assign it to a host variable. The SELECT statement must
return at most one row from the database, like a standard singleton SELECT. The INTO
clause is required and must be the last clause in the statement.
For example, the following statement is a standard singleton SELECT statement in an
application:
EXEC SQL
SELECT SUM(BUDGET), AVG(BUDGET)
INTO :tot_budget, :avg_budget
FROM DEPARTMENT
WHERE HEAD_DEPT = :head_dept;

To use this SELECT statement in a procedure, move the INTO clause to the end as follows:
SELECT SUM(BUDGET), AVG(BUDGET)
FROM DEPARTMENT
WHERE HEAD_DEPT = :head_dept
INTO :tot_budget, :avg_budget;

For a complete discussion of SELECT statement syntax, see the Language Reference.

Die SP läßt sich zwar im Falle von Hansa compilieren, aber bei Verwendung des
Doppelpunktes ist ":UMSATZ" gleich NULL.
Damit ist auch das Ergebnis der Zuweisung gleich NULL.

VAR_UMSATZBRUTTO = NULL * (1 + VAR_MWSTWERT / 100) --> NULL


alex
Alexander
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#34

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 12:38
Alex, da steht "need not" und nicht "must not". Ich habe mir die Verwendung des colon auch in assignments aus dem angegebenen Grund angewöhnt. Sobald der Parser geändert wird, werde ich es mir wieder abgewöhnen müssen, aber bis dahin: es funktioniert bei mir.

marabu
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#35

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 12:55
Hansa, du solltest vielleicht Namensüberdeckungen vermeiden:

SQL-Code:
CREATE PROCEDURE MWSTWERTSP8 (
  iMONAT SMALLINT,
  iJAHR SMALLINT,
  iMWSTSATZ SMALLINT )
RETURNS (
  oMWSTWERT NUMERIC(9,2) )
AS
  DECLARE VARIABLE vDATUM DATE;
  DECLARE VARIABLE vMWSTWERT NUMERIC(9,2);
BEGIN
  vDATUM = CAST('01.'|| iMONAT || '.' || iJAHR AS DATE);
  SELECT FIRST 1 mwstwert
    FROM mwst8
    WHERE (mwstsatz = :iMWSTSATZ) AND (abdatum <= :vDATUM)
    ORDER BY abdatum DESC
    INTO :vMWSTWERT;
  oMWSTWERT = :vMWSTWERT;
  SUSPEND;
END
marabu (getippt und nicht getestet)
  Mit Zitat antworten Zitat
alex517

Registriert seit: 23. Nov 2004
Ort: Bernau b. Berlin
273 Beiträge
 
Delphi XE5 Enterprise
 
#36

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 13:02
Zitat:
da steht "need not" und nicht "must not".
Das habe ich gelesen. Und aus diesem Grund colon in assignments auch nicht verwendet.
In FB ist scheinbar aus dieser "Empfehlung" ein Muß geworden.

alex
Alexander
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#37

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 13:14
Alex, wenn das stimmt, dass der FB Parser an der Stelle nicht mehr kompatibel zum IB Parser ist, dann frage ich mich, wie Hansa getestet hat. FB hat er offensichtlich genommen, denn sonst wäre er ja über FIRST gestolpert.

Zitat von Hansa:
An den Doppelpunkten liegts echt nicht
marabu
  Mit Zitat antworten Zitat
alex517

Registriert seit: 23. Nov 2004
Ort: Bernau b. Berlin
273 Beiträge
 
Delphi XE5 Enterprise
 
#38

Re: aktuelles Mwst.-Problem [SQL]

  Alt 8. Sep 2005, 14:37
Hi Hansa, hi marabu,

Ihr habt beide Recht an den Doppelpunkten liegts nicht.

Hansa, sieh dir doch mal die Parameterreihenfolge der
MWSTWERTSP8-Deklaration und beim Aufruf der MWSTWERTSP8
an:
SQL-Code:
CREATE PROCEDURE MWSTWERTSP8 (
    MONAT SMALLINT,
    JAHR SMALLINT,
    MWSTSATZ SMALLINT)
RETURNS (
    MWSTWERT NUMERIC(9,2))
  SELECT MWSTWERT FROM MWSTWERTSP8 (:MWSTSATZ,:MONAT,:JAHR) INTO :VAR_MWSTWERT; alex
Alexander
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 4 von 4   « Erste     234   


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:23 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