Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL query to pull data from AS400 help please

Author  Topic 

Tomsriv
Starting Member

5 Posts

Posted - 2013-01-31 : 12:53:08
Greetings all,
I am trying to pull and join some fields from an AS400 database into another program that will create points and a table. First off, I want to know if their is a problem in my syntax. From what I have read this is how to use select, but something isn't working. I get errors like "Keyword SELECT not expected." Can anyone help me troubleshoot?

select abaucd as LocID, abbdnb, abbenb from htedta.lmabrep
select utmtr as SerialNo, uttms as Type, utinmm as Month, utindd as Day, utinyy as Year, utmrmk as Remarks, utregs as registers, utmmke as Make, utmszc as Size, utstyl as Style
from htedta.ut550ap,
Where htedta.ut550ap.utlcid = htedta.lmabrep.abaucd

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-01-31 : 13:41:36
what happens if you run the first step on its own

select abaucd as LocID, abbdnb, abbenb from htedta.lmabrep


Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-31 : 13:57:21
As for the second query, I don't know the AS 400 syntax, but I think you need to list the second table as well.
select utmtr as SerialNo, uttms as Type, utinmm as Month, utindd as Day, utinyy as Year, 
utmrmk as Remarks, utregs as registers, utmmke as Make, utmszc as Size, utstyl as Style
from htedta.ut550ap, htedta.lmabrep
Where htedta.ut550ap.utlcid = htedta.lmabrep.abaucd
Go to Top of Page

Tomsriv
Starting Member

5 Posts

Posted - 2013-01-31 : 14:15:50
I tried both ways and it tells me "Keyword Select Not Expected"
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-31 : 14:20:09
What environment are you running this query in?
Go to Top of Page

Tomsriv
Starting Member

5 Posts

Posted - 2013-01-31 : 14:39:59
The environment is called Looking Glass Geomanager. I'll see if I can do a similar query in ArcGIS ArcCatalog.
Go to Top of Page

Tomsriv
Starting Member

5 Posts

Posted - 2013-01-31 : 14:46:21
No luck in ArcCatalog either. Each of these programs seem to need unique syntax.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-31 : 14:48:20
Most of the expertise on this forum is in Microsoft SQL Server. So if you are writing queries in those platforms, you would get better, faster, and more accurate answers on forums or other venues that have expertise in those platforms.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-01-31 : 15:50:26
Looks like you're trying to do a join

select abaucd as LocID, abbdnb, abbenb,
tmtr as SerialNo, uttms as Type, utinmm as Month,
utindd as Day, utinyy as Year, utmrmk as Remarks,
utregs as registers, utmmke as Make, utmszc as Size,
utstyl as Style
from htedta.lmabrep
INNER JOIN
htedta.ut550ap
ON htedta.ut550ap.utlcid = htedta.lmabrep.abaucd;
Go to Top of Page

Tomsriv
Starting Member

5 Posts

Posted - 2013-01-31 : 15:59:26
You may be right James. I should ask in the SQL 2000 forum because I bet that is the language this program needs.

Russel,
Thank you for making a very well organized example. I'll see if I can make it work in another program.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-02-01 : 12:56:42
Tomsrive - have you attempted to run this code on a different client such as iSeries navigator ?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -