Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New Rule: REF CURSER with return types #54

Closed
Assignees
kibeha
Labels
enhancementNew feature or requesthelp wantedExtra attention is needed
Milestone
@silviomarghitola

Description

@silviomarghitola

Language Usage / Control Structures / CURSOR orLanguage Usage / Variables & Types / General
Avoid usage of weak REF CURSOR types

fromSonarCube

Weak "REF CURSOR" types should not be used

Weak REF CURSOR types are harder to work with than ones with a return type. Indeed, the compiler's type-checker is unable to make some verifications, which are then delayed till runtime.

When the use of weak REF CURSOR is required, it is best to use the SYS_REFCURSOR built-in type instead of defining a new one.

This rule's sysRefCursorAllowed parameter can be used to control whether or not the usage of SYS_REFCURSOR is allowed.

Noncompliant Code Example

DECLARE  TYPE dualCursorType IS REF CURSOR;  dualCursor dualCursorType;  otherCursor SYS_REFCURSOR;-- Compliant or non-compliant, depending on the "sysRefCursorAllowed" parameterBEGIN  otherCursor := dualCursor;-- WorksEND;

Compliant Solution

DECLARE  TYPE dualCursorType IS REF CURSOR RETURN DUAL%ROWTYPE;  dualCursor dualCursorType;  TYPE otherCursorType IS REF CURSOR RETURN a%ROWTYPE;  otherCursor otherCursorType;BEGIN  otherCursor := dualCursor;-- raises PLS-00382: expression is of wrong type, which makes debugging easierEND;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp