Ahmet Karakaya
Ahmet Karakaya

Reputation: 10129

Print all column values via only Record using PLSQL

I have following plsql script that prints record parameters. Is there a way to print all column values just passing country_record. I mean I do not want to write all column name like country_record.country_id

 DECLARE
       country_record   countries%ROWTYPE;
       countryid        countries.country_id%TYPE;
    BEGIN
       countryid := &countryid;

       SELECT *
         INTO country_record
         FROM countries
        WHERE country_id = countryid;

       DBMS_OUTPUT.put_line ('id: ' || country_record.country_id);
    END;

Upvotes: 0

Views: 3406

Answers (1)

Maheswaran Ravisankar
Maheswaran Ravisankar

Reputation: 17920

If printing it all you wanted, you can try out this. Using SQL*Plus

VARIABLE MYCUR SYSREFCURSOR;

 DECLARE
       country_record   countries%ROWTYPE;
       countryid        countries.country_id%TYPE;
       plsql_cursor SYS_REFCURSOR;
    BEGIN
       countryid := &countryid;

       OPEN :MYCUR for 
       SELECT *
         FROM countries
        WHERE country_id = countryid;

    END;
  /

  print mycur;

Upvotes: 1

Related Questions