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
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
Chris Matthieu is the President & CEO of Computes, inc. He brings 30 years of experience in development and launches of disruptive technologies to create new market opportunities as well as enhance enterprise product portfolios with emerging technologies. His most recent venture was Octoblu, a cross-protocol Internet of Things (IoT) mesh network platform, acquired by Citrix. Prior to co-founding Octoblu, Chris was founder of Nodester, an open-source Node.JS PaaS which was acquired by AppFog and ...
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...