Giter Club home page Giter Club logo

Comments (2)

PhilippSalvisberg avatar PhilippSalvisberg commented on June 5, 2024

from SonarSource:

Strings should only be moved to variables or columns which are large enough to hold them

Trying to assign a large character value to a smaller variable or column will raise an error.

Noncompliant Code Example

create table persons (id number, name varchar2(4));

insert into persons (id, name) values (1, 'Alice'); -- Noncompliant, raises ORA-12899

create or replace procedure sp1
is
  foo varchar2(2);
begin
  select name into foo from persons where id = 1; -- Noncompliant, may raise ORA-06502
end;

Compliant Solution

create table persons (id number, name varchar2(8));

insert into persons (id, name) values (1, 'Alice');

create or replace procedure sp1
is
  foo varchar2(8);
begin
  select name into foo from persons where id = 1;
end;

from plsql-and-sql-coding-guidelines.

PhilippSalvisberg avatar PhilippSalvisberg commented on June 5, 2024

This rule requires data dictionary information. This is beyond the scope of this guidelines. Similar as for #24, #29. This applies also for variables, as we recommend to use anchored types whenever possible. See G-2110

from plsql-and-sql-coding-guidelines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.