Skip to main content
← PL/SQL Topics

SQL Integration

Explain SELECT ... INTO in PL/SQL

SELECT ... INTO

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

SELECT ... INTO fetches exactly one row from an embedded query straight into variables or a record.

How it works

SELECT col1, col2 INTO v1, v2 FROM ... WHERE ... is the simplest way to read a single row. The INTO targets must match the select list in number and be type-compatible; a record variable can receive a whole row. It must return one row — zero raises NO_DATA_FOUND, many raise TOO_MANY_ROWS. Add BULK COLLECT INTO for many rows. For 'maybe zero, maybe one' either handle NO_DATA_FOUND or wrap the column in an aggregate.

How it works
DECLARE
  r employees%ROWTYPE;
BEGIN
  SELECT * INTO r FROM employees WHERE employee_id = 100;
  DBMS_OUTPUT.PUT_LINE(r.first_name || ' ' || r.last_name || ' / ' || r.salary);
END;
/

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI