Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> "Embed" command files inside queries?

"Embed" command files inside queries?

From: Eric Lilja <mindcooler_at_gmail.com>
Date: 19 Sep 2005 12:50:13 -0700
Message-ID: <1127159412.953437.138610@f14g2000cwb.googlegroups.com>


Hello, I've just started using Oracle and I'm using the command line client SQL*Plus to teach myself basic SQL.

As you know, you can write command files containing queries that you can execute by performing:
SQL> @name_of_command_file

Anyway, my problem is that my queries are starting to become rather long for my taste so I was wondering if I could embed a command file inside a query? Something like:

$ cat my_command_file.sql
SELECT key FROM supplier WHERE city IN (SELECT name FROM city WHERE state LIKE'Mass');

And then, inside SQL*Plus, do something like:

SQL> SELECT * FROM supply WHERE supplier IN (@my_command_file);

instead of:
SQL> SELECT * FROM supply WHERE supplier IN (SELECT key FROM supplier WHERE city IN (SELECT name FROM city WHERE state LIKE'Mass'));

Or maybe there's a way to create short aliases for an expression and use that alias inside another expression and have SQL*Plus expand it when executing the query?

Thanks for any replies Received on Mon Sep 19 2005 - 14:50:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US