Hey AI — “What are the different types of IBM i SQL Variable?”

  • Home
  • /
  • Blog
  • /
  • Hey AI — “What are the different types of IBM i SQL Variable?”

January 24, 2024

AI is getting clever.

I’m honestly not too sure that AI is a good thing. We all watched the Terminator movies, right?

But that being said, I like to use the Microsoft’s COPILOT AI, because it makes collating answers to questions so very simple. It certainly makes researching answers to quick questions just about a hundred percent easier.

I even used it to generate the image header for this blog post.

I told it to generate a picture of Nick Litten fighting a giant rabbit robot!

What are the different types of IBM i SQL Variable?

Anyhoo, back to topic — I’ve been using a lot of IBM i SQL recently and regularly finding that my ten-year-old SQL knowledge is shockingly out of date. So, it’s time to double check everything I know and add new, cool code snippets to my mental Squirrel bucket.

So, let’s ask AI some basic questions and see what it tells us.

I’m going to record any salient AI answers as blogs just in case it helps anyone – because I know it helps me 🙂

QUESTION:

What are the different types of IBM i SQL Variable?

ANSWER:

In IBM i SQL, variables can be defined to store different types of data. Here are some of the variable types you can use:

  • CHAR(n): A fixed-length character string with a length of n.
  • NUMERIC(p, s): A numeric type with precision p and scale s.
  • DECIMAL(p, s): Similar to NUMERIC, a packed decimal number with precision p and scale s.
  • SMALLINT: A small integer that is typically a 2-byte binary number.
  • INTEGER: A 4-byte binary number, which is a standard integer.
  • BIGINT: An 8-byte binary number for larger integer values.
  • FLOAT: A floating-point number, which can be single precision (4 bytes) or double precision (8 bytes).

Additionally, there are date, time, and timestamp data types that are represented in an internal form not seen by an SQL user but can be represented by character string values [more]

For more detailed mappings between SQL data types and ILE RPG data types, you can refer to the official IBM documentation

The following figure illustrates the various built-in data types supported by Db2 for i.

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits.

Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day.

Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe NOW
7-day free trial

Take This Course with ALL ACCESS

Unlock your Learning Potential with instant access to every course and all new courses as they are released.
 [ For Serious Software Developers only ]

Online Learning for IBM i Software Technology Professionals

“The more that you read, the more things you will know. The more that you learn, the more places you’ll go.” – Dr. Seuss

>