Yonathan Rizky
Yonathan Rizky

Reputation: 59

function search select oracle

i have a function like this,

create or replace procedure carinamapekerjaan (kode number) as
        pekerjaan varchar(50);
    begin
        select job_id as NAMADEP_141510926 into pekerjaan
        from employees where employee_id=kode;
        dbms_output.put_line (pekerjaan);
    end;

when i run, the result is like this enter image description here

how to display title alias to NAMADEP_1411510926 enter image description here

Upvotes: 0

Views: 47

Answers (1)

Kaushik Nayak
Kaushik Nayak

Reputation: 31666

You could use REFCURSOR instead of dbms_output.put_line()

CREATE OR replace PROCEDURE Carinamapekerjaan (kode  NUMBER,
                                               c_emp OUT SYS_REFCURSOR)
AS
  pekerjaan VARCHAR(50);
BEGIN
    OPEN c_emp FOR
      SELECT job_id AS NAMADEP_141510926
      FROM   employees
      WHERE  employee_id = kode;

END;  
/

VARIABLE x REFCURSOR;
EXECUTE carinamapekerjaan(&inputkode,:x);
Enter value for inputkode: 101

PL/SQL procedure successfully completed.

PRINT x;

NAMADEP_141510926
------------------------------
AD_VP

Upvotes: 1

Related Questions