Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CursorInOutParameter type #706

Closed
wants to merge 1 commit into from

Conversation

aashikam
Copy link
Contributor

@aashikam aashikam commented Apr 4, 2024

Purpose

Fixes:

Examples

Works for the following code:

Procedure definition:

        CREATE OR REPLACE FUNCTION GetUserInfo(INOUT curName refcursor)
        LANGUAGE plpgsql
        AS $$
        BEGIN
            OPEN curName FOR
            SELECT user_id, username, email, age
            FROM users;
        END;
        $$;

Code:

import ballerina/sql;
import ballerina/io;
import ballerinax/postgresql; 
import ballerinax/postgresql.driver as _;

public function main() returns error? {
    postgresql:Client dbClient = check new ("localhost", "myuser", "mypassword", "mydatabase", 5432);

    transaction {
        sql:CursorInOutParameter curResults = new;

        sql:ProcedureCallResult result = check dbClient->call(`{CALL GetUserInfo(${curResults})}`);
        stream<record{}, sql:Error?> resultSet = curResults.get();

        record{}[] data = check from record{} assetAllocation in resultSet
           select assetAllocation;

        io:println(data);
        check result.close();
        check commit;

    }
}

Checklist

  • Linked to an issue
  • Updated the specification
  • Updated the changelog
  • Added tests
  • Checked native-image compatibility

Copy link

sonarqubecloud bot commented Apr 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 10.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 79.90%. Comparing base (4c4f148) to head (b27702d).
Report is 13 commits behind head on master.

Files Patch % Lines
ballerina/types.bal 0.00% 4 Missing ⚠️
...processor/AbstractStatementParameterProcessor.java 25.00% 2 Missing and 1 partial ⚠️
...ballerina/stdlib/sql/nativeimpl/CallProcessor.java 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #706      +/-   ##
============================================
- Coverage     80.08%   79.90%   -0.18%     
  Complexity      109      109              
============================================
  Files            45       45              
  Lines          3997     4006       +9     
  Branches        753      756       +3     
============================================
  Hits           3201     3201              
- Misses          540      547       +7     
- Partials        256      258       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Apr 19, 2024
@aashikam aashikam removed the Stale label Apr 22, 2024
@aashikam aashikam closed this Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant