tags:

views:

145

answers:

1

I'm trying to help a friend troubleshoot connection problems with an AS/400. He'd like to run a query against the AS/400 that will always return a record, (similar to a SELECT 1 against MSSQL).

He's attempted running SELECT 1 but without luck ... I'm assuming that the AS/400 expects a FROM TableName ...

Can anyone provided assistance? Is there a system table/file that always exists that he can run a SELECT TOP 1 (or it's equivalent) against? I've never interacted with an AS/400 so I'm a bit out of my element ... was hoping SO could give me a quick answer ...

Thanks in advance!

+4  A: 

I'm pretty certain it's DB2 running on those boxes (they're called iSeries now, by the way) so you can give:

select * from sysibm.sysdummy1

a shot. This should return a single column IBMREQD, set to Y.

paxdiablo
I'll pass this on ... Would 'SELECT * FROM sysibm.sysdummy1 FETCH FIRST 1 ROW ONLY' be valid?
bryan_cook
That's certainly valid syntax for DB2/z and DB2/LUW so I assume it would work on the iSeries as well. But I don't think it'll be needed, SYSDUMMY1 only *has* one row.
paxdiablo
Ah, I see :-) I'll pass this on and we'll see how it goes. Appreciate the response!
bryan_cook
And looking at the docs, 'fetch first n rows' was added in 5.1 back in 2001.
paxdiablo
See http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/db2/rbafzmstintsel.htm#intsel and remember: publib-boulder has a HUGE amount of online docs for all IBM products. That should be the first point of call if you're using IBM's wonderful software :-)
paxdiablo
Just tried that SQL in the answer on an actual AS/400, and it does work. No need to limit the number of rows returned, as it returns only one row as-is.
Brian Showalter
@paxdiablo Haven't heard back from my friend yet, but I'm sure what you've provided will work ... thanks for the answer and link!
bryan_cook
@Brian Showalter Thanks for confirming!
bryan_cook
"SELECT * FROM sysibm/sysdummy1 FETCH FIRST 1 ROW ONLY" works in STRSQL (note / instead of .)
Thorbjørn Ravn Andersen
(and they are named *IBM i* this week)
Thorbjørn Ravn Andersen