Link to home
Start Free TrialLog in
Avatar of matrix0511

asked on

What is the AS400 Command to Run a Record Count on a Table?

I just need to run a simple record count on a table on an AS400. I'm running the command:

select count (*) from crpdta.f551201z

But that command is failing. I know the file exists. So I just want to make sure I"m stating the command correctly.

Can someone let me know real quick for me?

See below.

Thanks!User generated image
Avatar of n2fc
Flag of United States of America image

Your command is correct... SQL is complaining about the table name... It is either mistyped or you are not connected to the proper SQL server to access that table.
your command looks fine
are you sure you don't have a typo in the object name?
Avatar of matrix0511


Well, I can open the table from the application (JD Edwards E1). See below. It opens and I can even pull data. And the "Business Data - CRP" refers to the schema owner: CRPDTA which I stated in the command. NOt sure what else to check.

User generated image
Avatar of Member_2_2484401
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@davelash, that was it! You DA Man!! :-)
Excellent work Dave!!
The problem is that you've specified *SYS naming convention instead of *SQL.

To expand just a little, the default on the STRSQL command is *SYS. You can prompt the command and change it to *SQL when you run the command. (Or simply type the command with the parm on the command line.)

Or, once you're already in an interactive SQL session, you can press <F13> to access session services. Option 1, 'Change session attributes', lets you switch naming convention among other things.

The "Naming convention" can be involved in just about every SQL interaction that you'll have with an AS/400. Usually, whichever client you're using will default according to the platform the client is running on. And every client that I've seen will allow you to change to the alternative mode. Keep it in mind.