Forum Stats

  • 3,814,896 Users
  • 2,258,927 Discussions
  • 7,892,883 Comments

Discussions

.sql file from a Unix shell script and saving the output in another file

2683187
2683187 Member Posts: 1
edited May 29, 2014 10:44AM in SQL & PL/SQL

SQL Query:

SELECT
cc2.cost_center "ORG_UNIT_ID",
cc2.COST_CENTER_SHORT_NAME "ALPHA_CODE",
cc2.cost_center_name "SHORT_NAME",
cc2.cost_center_name "LONG_Name",
substr(CC.COST_CENTER_SHORT_NAME,1,3) "PMU_ALPHA",
CC.cost_center_name "PMU_NAME",
cc.company_code "Org_Acronym"
FROM
[email protected] FC, [email protected] CC, [email protected] CC2 WHERE FC.FC_LEVEL3 = CC.COST_CENTER AND FC.FUND_CENTER = CC2.COST_CENTER
ORDER BY 1,2

----------------------.sql file in UNIX ------------------------------
SET echo off
SET verify off
SET colsep ,
SET pagesize 0
SET trimspool on
SET feedback off
SPOOL ON
SPOOL /data/CostCenterData.csv
SELECT
'"'||trim (cc2.cost_center "ORG_UNIT_ID)"||'","'
||trim (cc2.COST_CENTER_SHORT_NAME "ALPHA_CODE")||'","'
||trim (cc2.cost_center_name "SHORT_NAME")||'","'
||trim (cc2.cost_center_name "LONG_Name")||'","'
||trim (substr(CC.COST_CENTER_SHORT_NAME,1,3) "PMU_ALPHA")||'","'
||trim (CC.cost_center_name "PMU_NAME")||'","'
||trim (cc.company_code "Org_Acronym")||'",'
FROM

[email protected] FC, [email protected] CC, [email protected] CC2 WHERE FC.FC_LEVEL3 = CC.COST_CENTER AND FC.FUND_CENTER = CC2.COST_CENTER

ORDER BY 1,2
SPOOL OFF
EXIT

This query is working in sql developer, but not working in unix server...can you please anyone help me to conver into .sql file correctly....

Tagged:
This discussion has been closed.