CS157B: Spring 2021
HW #2: Embedded Static & Dynamic SQL (70 Points)
Due Date: Mar 11, 2021
Write an embedded static & dynamic SQL program to perform a “SELECT * FROM table_name” from any database. Use sample2.sqc and HW#1 as your starting point.
“hw2 database_name table_name”
Database_name – any valid database name within Db2 (e.g. SAMPLE)
Table_name – any valid table_name within the Database_name (e.g. employee, dept, sales, inventory, …)
You will submit a hw2.sqc file and a readme.hw2 file.
A few helpful commands:
db2 “connect to sample”
To show which tables are in the sample database:
db2 “list tables”
db2 “list tables for schema db2inst1”
To show the schema for a specific table like sales:
db2 “describe table sales”
db2 “describe table db2inst1.sales”
If you run you program (after PREP & compile steps) like:
./hw2 sample sales
Your output should look just like as you execute the db2 “select * from sales” command from the container window after you connect to sample. This is an easy way to verify your program. If you notice the output, strings are left justified, and numbers are right justified. You can use the static SQL to connect and query the catalog shown in sample2.sqc. However in order for you to complete this assignment, you will need to build dynamic SQL statement based on the table name which you accept from the command line.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: firstname.lastname@example.org 微信:itcsdx