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 -> Running SQLPlus from command line

Running SQLPlus from command line

From: RLN <rlntemp-newsgroup_at_yahoo.com>
Date: 11 Oct 2006 07:58:16 -0700
Message-ID: <1160578696.174696.66410@i3g2000cwc.googlegroups.com>


Re: Oracle 8i

New to SQLPlus so bear with me.

I am trying to get SQLPlus to run from a command line in a batchfile which executes a .SQL file.
(The files here are TEST12.BAT which runs TEST12.SQL)

Right now, TEST12.SQL runs fine in Toad via the GUI and returns 33 rows of data. So I know syntactically the SQL script works. I tried running Toad from the command line but many threads (and days of brick walls) I was advised to try using SQLPlus from the command line via a batchfile, so here I am (with questions).

My 5 line batch file runs, (listed below) but there are four problems I can't seem to resolve.
1. echo statement (line 5) when completed: "Echo done running TEST12.BAT"
2. After Line 4 executes SQLPlus the batch file hangs. I do not see data, don't know if the query is finished, etc. 3. Is there a statement that I can use that will return whether SQLPlus successfully connected to the database? I think it connects, but am unsure actually.
4. I need to save the data output. When the query is completed, how do I tell SQLPlus (via another line in the batch file) to save the contents to either a .csv file or .xls file, and exit, thus passing control back to the final line of the batch file to display the 'process completed' message?
I need to save this output file (be it .csv, .txt, or .xls) to the local drive so an Access program can pick it up and do more processing with it.

When using the SQLPlus Command Line in a batch file in silent mode, is there a limitation of filetypes the data retreival to be exported to? I think choosing between .txt, .csv, and .xls woud be fine.

(line numbering is for reference here only) Here is my Batch File:
<begin code for TEST12.BAT>

1. @echo off
2. echo  Running TEST12.SQL
3. echo  SQLPlus running from a command line.....please wait....
4. SQLPLUS  -s myLogOn/myPass_at_MyDBName@TEST12.SQL
5. Echo done running TEST12.BAT

<end code for TEST12.BAT>

TEST12.SQL: (runs ok in Toad)
<begin code for TEST12.SQL>

SELECT DISTINCT A.PROCESS_INSTANCE,

                            A.BUSINESS_UNIT,
                            A.VOUCHER_ID,
                            A.VOUCHER_LINE_NUM,
                            A.BUSINESS_UNIT_PO,
                            A.PO_ID, A.LINE_NBR,
                            A.SCHED_NBR,
                            A.BUSINESS_UNIT_RECV,
                            A.RECEIVER_ID,
                            A.RECV_LN_NBR,
                            A.RECV_SHIP_SEQ_NBR,
                            A.MATCH_RULE_ID,
                            A.SETID,
                            A.MATCH_CNTRL_ID,
                            A.BUYER_ID,
                      B.MERCHANDISE_AMT,
                            B.QTY_VCHR,
                            C.IMAGE_REF_ID
       FROM PS_VCHR_MTCH_EXCPT A,
                 PS_VOUCHER_LINE B,
                 PS_VOUCHER C
       WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT
     AND A.VOUCHER_ID = B.VOUCHER_ID
     AND A.VOUCHER_LINE_NUM = B.VOUCHER_LINE_NUM
     AND B.BUSINESS_UNIT = C.BUSINESS_UNIT
     AND B.VOUCHER_ID = C.VOUCHER_ID
     And A.PO_ID in('0000877894')

<end code for TEST12.SQL>>
 

 Thanks for your assistance. Received on Wed Oct 11 2006 - 09:58:16 CDT

Original text of this message

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