[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Jul 2010
    Beiträge
    59

    Variable als Parameter für SUBSTR in SQL-Anweisung (UDF)

    Hallo, zusammen

    Die folgende Anweisung wird nicht akzeptiert (Variable COUNTER ist DECIMAL(3,0) definiert).

    IF SUBSTR(FELD15, COUNTER, 1) < '0' OR
    SUBSTR(FELD15, COUNTER, 1) > '9'

    Bei SET-Anw. dürfen Variable aber offenbar vorkommen.

    Ich weiß jetzt jeenfalls nicht, wie ich im gegenständlichen Fall abfragen soll, ob nur numerischer Wert enthalten.

    Eine MONITOR-Überwachung wie in RPG gibt es ja in SQL-UDFs nicht, soweit ich weiß. Wäre hier praktisch. Denn jede einzelen Stelle abzufragen, ist ohnehin wenig elegant.

    Danke im Voraus für Unterstützung.

  2. #2
    Registriert seit
    Feb 2001
    Beiträge
    20.241
    Der Monitor in SQL heißt hier WHENEVER:
    Syntax

    WHENEVER NOT FOUND

    SQLERROR

    SQLWARNING

    CONTINUE

    GOTO
    host-Label

    GO TO :

    

    Description

    The NOT FOUND, SQLERROR, or SQLWARNING clause is used to identify the

    type of exception condition.

    NOT FOUND

    Identifies any condition that results in an SQLSTATE of '02000' or an

    SQLCODE of +100.

    SQLERROR

    Identifies any condition that results in an SQLSTATE value where the first two

    characters are not '00', '01', or '02'.

    SQLWARNING

    Identifies any condition that results in an SQLSTATE value where the first two

    characters are '01', or a warning condition (SQLWARN0 is 'W').

    The CONTINUE or GO TO clause are used to specify the next statement to be

    executed when the identified type of exception condition exists.

    CONTINUE

    Specifies the next sequential instruction of the source program.

    GOTO or GO TO
    host-Label

    Specifies the statement identified by
    host-label. For host-label, substitute a single

    token, optionally preceded by a colon.

    Du kannst also per "SET VAR = DEC(FLD15, n, m)" und anschließender Abfrage des SQLCOD den Fehlerfall abfangen.
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

  3. #3
    Registriert seit
    Jul 2010
    Beiträge
    59
    Da hatte ich offensichtlich eine markante Bildungslücke. Vielen Dank für die Info

Similar Threads

  1. CAST(SUM(SUBSTR
    By tarkusch in forum NEWSboard Programmierung
    Antworten: 3
    Letzter Beitrag: 05-05-14, 16:42
  2. RPGLE Parameter *NOPASS
    By XMan in forum NEWSboard Programmierung
    Antworten: 3
    Letzter Beitrag: 20-12-13, 08:50
  3. QRY und PARAMeter
    By HoScHiE in forum IBM i Hauptforum
    Antworten: 28
    Letzter Beitrag: 17-01-08, 10:35
  4. Parameter empfangen in RPG??
    By JonnyRico in forum IBM i Hauptforum
    Antworten: 1
    Letzter Beitrag: 02-04-03, 15:53
  5. Query Parameter
    By Hans Zuther in forum IBM i Hauptforum
    Antworten: 3
    Letzter Beitrag: 21-10-02, 15:29

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •