Create a view in DB2/400

344900 pts.
Tags:
DB2
DB2/400
I need an example to create a view in DB2/400. I Need to create a view where the table name is greather than 8 characters and collumns names greather than 6 characters. please somebody can help me??

Answer Wiki

Thanks. We'll let you know when a new response is added.

If I understand your question correctly, on the AS400 you can use sql to create a file or logical view, or table, whatever you want to call it. The command is STRSQL to get into sql then the sql command to create a table is CREATE VIEW filename AS SELECT fieldnames etc. You will need to lookup sql commands but that is the basic command that will create a logical view of a physical file. I have one with a file name that is ten characters long and ten character long field names, since you asked about length
here is an example

CREATE VIEW filename AS SELECT field1 AS field1descriptivetext, COUNT(field2) AS field2descriptivetext FROM library.physicalfile GROUP BY fieldname

===============================================================

The STRSQL command will only be available if your system has the SQL Development Kit product installed, and probably licensed, too. Most production systems have it nowadays.

If it’s not available, SQL statements for creating SQL objects can still be created by entering the CREATE statements into a source file member. The member is then used as input to the RUNSQLSTM command. Multiple statements can be in a member, each one separated by a semi-colon as the statement terminator.

Also, the PC iSeries Navigator program includes a Run SQL Scripts function. SQL can be developed on your PC and sent to your AS/400 for execution.

There are other possibilities, but those two are easily available to everyone (who has authority). No additional product licenses needed.

Tom

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • tjgm88
    Hi, You can create views on the AS400 using the CRTLF (Create Logical file) command. On this command you will need to supply the name of a source file which points to the physical file(data file) and describes the key sequence of the view. You need to crease the source file first using the STRPDM facility. Cheers!
    995 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following