-
set :Z = geht nicht, ohne das set sehrwohl
Gleich noch eine SQL Frage (danke)
Das liefert eine 1 zurück (interaktiv, strsql)
Code:
with a as (select xxkey1, xxkey2, xxkey3
from xxfile where xxma = 14073
and xxan = 0 and xxstat = 2)
select count(*) from(
select yypool from yyfile
where yyma=14073 AND yyAN=0
AND (yykey1, yykey2, yykey3) in(
select xxkey1, xxkey2, xxkey3 from a)
and yymk*1000+yymst <> 999997
group by yypool) as v
ich brauche das als
Code:
C/exec-sql
C+ set :Z = (with a as (select xxkey1, xxkey2, xxkey3
C+ from xxfile where xxma = 14073
C+ and xxan = 0 and xxstat = 2)
C+ select count(*) from(
C+ select yypool from yyfile
C+ where yyma=14073 AND yyAN=0
C+ AND (yykey1, yykey2, yykey3) in(
C+ select xxkey1, xxkey2, xxkey3 from a)
C+ and yymk*1000+yymst <> 999997
C+ group by yypool) as v )
C/end exec
Das bricht zur Laufzeit ab und erzeugt sogar einen dump
Was ist falsch?
Danke
-
Ggf. wird ein Fullselect beim Set nicht unterstützt.
Eine Set-Anweisung entspricht einem skalaren Subselect und da ist With auch nicht erlaubt.
Aber dies geht wohl ebenso:
Code:
C/exec-sql
C+ with a as (select xxkey1, xxkey2, xxkey3
C+ from xxfile where xxma = 14073
C+ and xxan = 0 and xxstat = 2)
C+ select count(*) into :Z
c+ from(
C+ select yypool from yyfile
C+ where yyma=14073 AND yyAN=0
C+ AND (yykey1, yykey2, yykey3) in(
C+ select xxkey1, xxkey2, xxkey3 from a)
C+ and yymk*1000+yymst <> 999997
C+ group by yypool) as v
C/end exec
-
Danke, so hat es funktioniert!
Dietlinde Beck
-
Bedenke dabei nur, dass der Count u.U. auch NULL zurückgeben kann wenn keine Daten gefunden werden. In diesem Fall wäre ein NULL-Anzeiger schon hilfreich, denn ein negativer SQLCODE kann auch andere Gründe haben. Aber SQLCODE und/oder NULL-Anzeiger abzufragen macht da schon Sinn.
-
... count sollte schon was zurück geben, bei leerem ResultSet dann 0.
D*B
-
Nein, meine Erfahrung besagt, dass Count auch NULL zurückgibt, sonst hätte ich es nicht erwähnt.
Mag sein, dass dies ein IBM-SQL-Fehler ist, aber das hat mich dann nie interessiert.
-
Das würde mich jetzt auch sehr wundern wenn ein count NULL zurück liefert.
Auch in der Doku steht auch extra "The result cannot be null".
-
Dann werde ich den SQL nochmal raussuchen, vielleicht ist der Grund dann erkennbar.
Similar Threads
-
By alex61 in forum IBM i Hauptforum
Antworten: 2
Letzter Beitrag: 08-03-17, 09:50
-
By Robi in forum IBM i Hauptforum
Antworten: 6
Letzter Beitrag: 03-02-16, 09:16
-
By Robi in forum NEWSboard Programmierung
Antworten: 5
Letzter Beitrag: 23-09-14, 07:30
-
By malzusrex in forum IBM i Hauptforum
Antworten: 4
Letzter Beitrag: 01-09-14, 21:48
-
By Uwe Kohlberg in forum IBM i Hauptforum
Antworten: 8
Letzter Beitrag: 23-01-07, 10:59
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks