Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Variables in Oracle SQL

Tee BirdNov 28 2023 — edited Nov 28 2023

Current Job: Make Reports containing data from our databases.

Problem: While Oracle comes with sophisticated procedural language of its own (the PL), my shop usually has to run SQL within software where the PL is not supported. As a result, my experience with PL is near zero.

Wondering: I am wondering if a very simple portion of the procedural language support in Oracle can be used in our situation. Specifically, can we setup variables in SQL for use in filters implemented as where clauses.

Reporting Architecture - The people who need the reports receive them as scheduled reports in email, either as Excel or a PDF. The reports are scheduled and emailed by SAP Business Objects. Our ways of using Business Objects does not support much if any PL, confinging us to SQL.

My QUESTION

How can variables be declared in Oracle for use as values in WHERE CLAUSES?

Pseudo Code Illustration

varName = “Mother Mary”

select firstname, lastname, other_fields, etc
from guestlist
where guestname= ".$varName

This post has been answered by mathguy on Nov 29 2023
Jump to Answer
Comments
Post Details
Added on Nov 28 2023
8 comments
201 views