PDA

View Full Version : Variable als Parameter für SUBSTR in SQL-Anweisung (UDF)



hartmuth
24-07-14, 10:11
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.

Fuerchau
24-07-14, 10:40
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.

hartmuth
24-07-14, 10:52
Da hatte ich offensichtlich eine markante Bildungslücke. Vielen Dank für die Info