IBM Cloud Authors: Elizabeth White, Yeshim Deniz, Pat Romanski, Liz McMillan, Stefan Bernbo

Related Topics: PowerBuilder

PowerBuilder: Article

SQL Anywhere Studio 9 Developer's Guide

A new book by Breck Carter

As a PowerBuilder developer I'm sure you have already used SQL Anywhere a few times, but did you know that SQL Anywhere owns over 70% of the mobile database market?

There are several good reasons for this big market share; it's easy to use, easy to administer, and doesn't take up much space, but SQL Anywhere isn't just for mobile and embedded databases; it's got the features and the flexibility to work as a network server with hundreds of active users pounding away on a single database. And it's got a solid foundation and a long history from its roots with Watcom in the 1980s through to Powersoft and Sybase in the 1990s and now with iAnywhere Solutions in the new millennium. But there are still some features that aren't fully covered by the documentation so Breck Carter decided to write a book about this wonderful database. It's called SQL Anywhere Studio 9 Developer's Guide. So let's have a look at this book this month.

The Book
The book includes a companion CD that includes the full Backus-Naur Form notation for the SQL syntax from the book in HTML format for easy browsing. It also includes all of the examples in the book, plus a full copy of SQL Anywhere Studio 9 Developer Edition for Windows. The book itself is about 450 pages long and starts with the history of the database, beginning with the story of Watcom in 1965 and ending with the release of SQL Anywhere version 9. Then the reader dives into the deep world of the product and learns a lot in the next 10 chapters.

Chapter 1: Creating
This chapter begins with 12 rules to answer the question "What is a relational database?" It then describes the five kinds of tables (global permanent, global temporary, remote, proxy and local temporary) available using the seven different syntax options for the CREATE TABLE statement and, moving on to the wide variety of built-in string, date-time, and numeric data types, it continues with column properties, computed columns, default values, the NULL property, and column constraints. User-defined data types, table constraints, remote data access, and temporary tables are also covered. The chapter ends with a discussion of normalization to answer the question, "What is a good relational database?" An interesting chapter, compactly written.

Chapter 2: Inserting
With the first chapter covering so much information, the second one is exactly right. It talks about putting data into the database, covering five different flavors of INSERT (with a values list for all columns or a list of named columns, a select for all column values or a list of named columns, and use of the auto name facility as well as the load table statement and ISQL's client-side alternative, the input statement.

Chapter 3: Selecting
This one talks about the inverse of Chapter 2, getting data out of the database with SELECT, UNLOAD, and the ISQL OUTPUT statement. This is the longest chapter in the book, which should come as no surprise since the SQL SELECT statement may be the most powerful and complex single syntactic construction available in any database programming language.

Chapter 3 starts by explaining the SELECT statement, and the logical execution of a SELECT, which shows how all the various clauses fit together and contribute to the final result set without concern for how SQL Anywhere actually executes a SELECT. Most of the rest of Chapter 3 follows the steps laid out and explained at the beginning of the chapter. If you've ever had trouble with the GROUP BY clause, or had a SELECT that returned 10,000 rows instead of the three you wanted, or wondered why you can't call NUMBER(*) in a WHERE clause, this is the chapter for you.

Chapter 4: Updating
This chapter covers the UPDATE statement and how it can be used to update a single row in one table, or multiple rows, or even multiple rows in multiple tables. It also includes a section on the logical execution of a set UPDATE and a discussion of cursor UPDATE statements using the WHERE CURRENT OF clause.

Chapter 5: Deleting
Breck calls deleting the evil twin of Chapter 4; he talks about deleting single and multiple rows, and includes a section on the logical execution of a set DELETE as well as information about cursor DELETE statements using WHERE CURRENT OF. He also has a section on TRUNCATE TABLE and how it compares with DELETE: sometimes faster, sometimes not, and why.

Chapter 6: Fetching
A chapter six is a chapter a PowerBuilder developer should read since it talks about the DECLARE, OPEN, FETCH, and CLOSE statements as they apply to cursors using SELECT queries and procedure calls. It also describes the cursor FOR loop, which vastly simplifies the cursor loops in SQL by eliminating the need to DECLARE all those local variables or code those endless FETCH lists. Something a PowerBuilder developer doesn't do very often because of the datawindow and datastore we have.

Chapter 7: Synchronizing
Here you have it - the MobiLink chapter. It discusses how the MobiLink server works together with the MobiLink client for ASA to synchronize data back and forth between a consolidated database and dozens or thousands of remote databases. MobiLink scripts are classified by level (connection, session, table, and row) and by direction (upload versus download). And error handling on the server and client sides is described. This is an interesting chapter for every serious PocketBuilder developer. I can highly recommend it if you want to synchronize your mobile device with a desktop machine.

Chapter 8: Packaging
This chapter is about moving application logic into the database using BEGIN blocks and SQL modules based on BEGIN blocks: procedures, functions, triggers, and events. The SET assignment statement is described, as well as the flow-of-control structures IF, CASE, and WHILE, the EXECUTE IMMEDIATE statement, and the connection-level CREATE VARIABLE statement. This section introduces the basics of exception handling, a topic expanded on in Chapter 9.

Chapter 9: Protecting
Chapter 9 is the second-longest chapter in the book. It explores a wide variety of topics including options, transactions, exceptions, errors, subtransactions, locks, blocks, isolation levels, deadlocks, mutexes, user IDs, privileges, user groups, logging, recovery, backup, restore, and (gasp!) database validation. Many of these topics are only loosely connected to one another, but they all fall under the general heading "Crashing, Bashing, Thrashing, and Protection Therefrom."

Chapter 10: Tuning
This chapter might be the one with the biggest audience since everyone's interested in speed, speed, speed. This chapter should be read last because the first rule of optimization is "Don't do it." If you're an expert, Rule 2 also applies: "Don't do it yet."

Chapter 10 explains the four big performance tuning tools that SQL Anywhere provides: request-level logging, the Index Consultant, the Execution Profiler, and the Graphical Plan. It then moves on to more arcane topics such as file, table, and index fragmentation, and table, index, and database reorganization.

Sections on the syntax of CREATE INDEX and database performance counters are included, and the book ends with a performance tuning "Tips and Techniques" section that lists 36 do's and don'ts that didn't find a home earlier in the book.

The book is easy to read and contains important details about SQL Anywhere development. If you're new to SQL Anywhere the material will save you hours of time and dramatically shorten your learning curve. This book is simply a must-have for SQL Anywhere database developers because it's a complete and compact reference for experienced developers as well as comprehensive immersion for beginners and less experienced coders. It's written by someone who has a great deal of experience using SQL Anywhere Studio to build real-world software solutions. Have fun reading it.


Breck Carter is an experienced database developer. He first worked with a relational database in 1973 (the year I was born) before there were any practical commercial implementations. Over the years he has worked as an independent consultant to develop enterprise databases and applications using IMS DB/DC, DB2, Oracle, SQL Server, ASE, and, beginning in 1995, SQL Anywhere.

Breck has been a member of Team Sybase since 1993, which means you can find him answering questions on the SQL Anywhere newsgroups on behalf of Sybase and iAnywhere Solutions. He is also a member of the iAnywhere Solutions Customer Advisory Board, helping to shape future product direction.

More Stories By Berndt Hamboeck

Berndt Hamboeck is a senior consultant for BHITCON (www.bhitcon.net). He's a CSI, SCAPC8, EASAC, SCJP2, and started his Sybase development using PB5. You can reach him under admin@bhitcon.net.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

IoT & Smart Cities Stories
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
In an era of historic innovation fueled by unprecedented access to data and technology, the low cost and risk of entering new markets has leveled the playing field for business. Today, any ambitious innovator can easily introduce a new application or product that can reinvent business models and transform the client experience. In their Day 2 Keynote at 19th Cloud Expo, Mercer Rowe, IBM Vice President of Strategic Alliances, and Raejeanne Skillern, Intel Vice President of Data Center Group and G...
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.