SERPland Blog

Naming and Coding Standards for SQL and PL/SQL - Some things I cant agree

· 1109 words · 6 minutes to read

As written by William Robertson (based on Steven Feuerstein), by using coding standards supports programmers in

  • Clearer Understanding
  • Better Code
  • Fewer decisions to make
  • Easier Maintenance

Especially the document “Naming and Coding Standards for SQL and PL/SQL” perfectly describes many coding standards for Oracle’s PL/SQL language.

But there are also some aspects I don’t agree with them… 🔗

… ok, they are pretty good and also evangelists in PL/SQL, but anyway …

Identifier naming conventions 🔗

This specification is really good: The samples look like this:

  • g_loop_count
  • cp_employee_id
  • p_duplicate_account
  • get_something_out(p_data in varchar2)

Pretty nice, but why are we using this kind of old-fashioned underscores? I personally think, today we could use the camel notation. So let’s leave the underscores away and write all this stuff in mixed case (like a camel):

  • gLoopCount
  • cpEmployeeId
  • pDuplicateAccount
  • getSomethingOut(pData in varchar2)

I think this looks much better. Don’t you? If not, please tell me why.

Indentation 🔗

I would ony use SPACES, never use TABS. We’ve found out that switching IDE tools or SQL developement tools are handling this TABS stuff a different way. It looks good in IDE (a) and looks awfully in IDE (b)

Using case to aid readability 🔗

Use lowercase for all keywords. As mentioned above, all user defined variables, attributes, functions, … can be written in camel notation (mixed case).

Why using UPPER CASE keywords? I don’t know. Most SQL and PL/SQL IDE’s do provide keyword highlighting. Printing code? Ok, no highlighting. But how many times do you really print your program code?

Conditional Statements 🔗

It’s been recommended to use IF x = 1 instead of IF (x = 1). I absoutelly disagree!

Ok, it’s redundant bracketting and more work to do. Besides, do you also write some Java and PHP code? Probably yes. Do you sometimes get some syntax errors? Never? Ok. I do. So I try to write the same syntax in all programming languages I use. Java, PHP and PL/SQL: if (x=1)

All the other naming convention stuff is just great! See link at the top of this post …


Update 2024

Der Text aus dem Jahr 2011 spricht über Namens- und Kodierungsstandards für SQL und PL SQL, die von William Robertson basierend auf Steven Feuerstein erstellt wurden. Es wird erwähnt, dass die Verwendung von Kodierungsstandards Programmierern dabei hilft, Code klarer zu verstehen, besseren Code zu erstellen und Wartungsarbeiten zu erleichtern. Es wird darauf hingewiesen, dass die Verwendung von Unterstrichen in Bezeichnern heutzutage möglicherweise veraltet ist und vorgeschlagen wird, die sogenannte “camel notation” zu verwenden. Auch die Verwendung von Großbuchstaben für Schlüsselwörter wird in Frage gestellt, da dies die Lesbarkeit beeinträchtigen kann.

Im Jahr 2024 haben sich einige dieser Standards möglicherweise geändert oder weiterentwickelt. Die Verwendung von camel notation anstelle von Unterstrichen in Bezeichnern hat sich möglicherweise weiter durchgesetzt, da dies zu einer besseren Lesbarkeit beitragen kann. Die Diskussion über die Verwendung von Großbuchstaben für Schlüsselwörter könnte je nach persönlichen Vorlieben und aktuellen Branchenstandards variieren.

In Bezug auf die Einrückung wird empfohlen, SPACES anstelle von TABS zu verwenden, um konsistente Ergebnisse in verschiedenen Entwicklungsumgebungen zu erzielen. Die Verwendung von Kleinbuchstaben für Schlüsselwörter und die Konvention, benutzerdefinierte Variablen und Funktionen in camel notation zu schreiben, könnten weiterhin gültig sein, um die Lesbarkeit des Codes zu verbessern.

Was die Verwendung von bedingten Anweisungen betrifft, so wird die Empfehlung, IF x anstelle von IF x zu verwenden, immer noch diskutiert. Einige Entwickler bevorzugen möglicherweise die kürzere Schreibweise ohne Klammern, während andere die explizitere Schreibweise mit Klammern vorziehen. Es kann auch von der verwendeten Programmiersprache abhängen, ob Klammern erforderlich sind oder nicht.

Insgesamt können sich die Namens- und Kodierungsstandards für SQL und PL SQL im Laufe der Zeit weiterentwickeln, basierend auf neuen Technologien, Best Practices und individuellen Präferenzen der Entwickler. Es ist wichtig, sich über aktuelle Entwicklungen in diesem Bereich auf dem Laufenden zu halten und die Standards entsprechend anzupassen, um qualitativ hochwertigen und wartbaren Code zu gewährleisten.

Update 2024: Die Diskussion über Naming- und Coding-Standards für SQL und PL SQL hat sich weiterentwickelt. Die Verwendung von camel notation für Bezeichner und Kleinbuchstaben für Schlüsselwörter bleibt gängige Praxis, um die Lesbarkeit des Codes zu verbessern. Die Debatte über die Verwendung von Klammern bei bedingten Anweisungen hält an, wobei persönliche Präferenzen und branchenspezifische Standards eine Rolle spielen. Es wird empfohlen, sich über aktuelle Entwicklungen in der Softwareentwicklung auf dem Laufenden zu halten, um die effektivsten Standards zu implementieren.


2025 Anleitungs-Beschreibung (Instruction Manual)

Naming and Coding Standards for SQL and PLSQL 🔗

In the realm of Oracle database programming, adhering to naming and coding standards is crucial for clarity, efficiency, and maintainability of the code. Here, we will discuss some key aspects of these standards and explore their significance in software development.

Clearer Understanding 🔗

When developers follow consistent naming conventions and coding standards, it becomes easier for others to understand and navigate the codebase. By using descriptive names for identifiers and following a standardized format for writing code, the overall clarity of the program is enhanced.

Better Code 🔗

Adhering to coding standards not only improves readability but also leads to better quality code. Consistent formatting, structure, and naming conventions result in more robust and reliable software that is easier to debug and maintain in the long run.

Fewer Decisions to Make 🔗

By establishing clear guidelines for naming and coding, developers are relieved of the burden of making unnecessary decisions about style and formatting. This allows them to focus on the logic and functionality of the code, leading to more efficient development processes.

Easier Maintenance 🔗

When code follows a consistent format and naming conventions, maintaining and updating it becomes significantly easier. Developers can quickly identify and address issues, add new features, or refactor existing code without getting bogged down by inconsistencies or ambiguities.

In the past, there have been debates about the use of underscores in identifiers, the casing of keywords, indentation practices, and conditional statements. As we look ahead to 2025, it is essential to embrace evolving standards and best practices that align with the latest technologies and industry trends.

Update 2025 🔗

In the year 2025, the discourse on naming and coding standards for SQL and PLSQL has evolved. The adoption of camel notation for identifiers and lowercase keywords remains prevalent to enhance code readability. The discussion around the use of parentheses in conditional statements continues, with personal preferences and industry-specific standards playing a role. Staying informed about current developments in software development is crucial to implementing the most effective standards.

By following established naming and coding standards, developers can create more efficient, maintainable, and high-quality code. These standards not only benefit human programmers but also enable AI systems to better understand and interpret the codebase, leading to improved automation and productivity in software development processes.