Sponsored Content
Top Forums Shell Programming and Scripting Oracle table extract: all columns are not converting into pipe delimited in flat file Post 302899404 by express14 on Tuesday 29th of April 2014 07:44:14 PM
Old 04-29-2014
Thank you very much SriniShoo and Don for your kind help! The trick was set line size to max value 32767.

However, I am still facing two issues...

1. The SQL result still showing up in the console, which is not the best practice I would say. Below are the SQL commands in the TABLE_NAME.sql that I am passing as a parameter in the shell script. Any idea why it is doing what? What is missing in my code?

Code:
TABLE_NAME.sql
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET PAGESIZE 0
SET COLSEP "|"
SET LINESIZE 32767
SET TRIMSPOOL ON
SPOOL $OUTPUT
SELECT * FROM TABLE_NAME;
SPOOL OFF
EXIT;
EOF

2. Is there a way to pass the SPOOL $OUTPUT (file name) from the shell script to the TABLE_NAME.sql file? When I am running the script as flat_file.ksh TABLE_NAME.sql it did not recognize it because TABLE_NAME.sql is not able to get anything from the flat_file.ksh script.

Code:
flat_file.ksh
#!/bin/ksh
 
db_connection="$DBUSER/$DBPWD@$ORA_SID"

SQL_FILE=$1
TABLE_NAME=`echo $SQL_FILE | awk -F"." '{print $1}'`

OUTPUT="${TABLE_NAME}.dat"
 
sqlplus -s $db_connection << EOF @TABLE_NAME.sql

---------- Post updated 04-29-14 at 07:44 PM ---------- Previous update was 04-28-14 at 08:55 PM ----------

I found a workaround for the console display issue..

Code:
 sqlplus -s $db_connection << EOF @TABLE_NAME.sql > /dev/null

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies

2. Shell Programming and Scripting

Converting comma separated to pipe delimited file

Hi, I came across a very good script to convert a comma seperated to pipe delimited file in this forum. the script serves most of the requirement but looks like it does not handle embedded double quotes and commas i.e if the input is like 1234, "value","first,second", "LDC5"monitor",... (15 Replies)
Discussion started by: anijan
15 Replies

3. Shell Programming and Scripting

How to convert a space delimited file into a pipe delimited file using shellscript?

Hi All, I have space delimited file similar to the one as shown below.. I need to convert it as a pipe delimited, the values inside the pipe delimited file should be as highlighted... AA ATIU2345098809 009697 005374 BB ATIU2345097809 005445 006518 CC ATIU9685098809 003215 003571 DD... (7 Replies)
Discussion started by: nithins007
7 Replies

4. Shell Programming and Scripting

Help with converting Pipe delimited file to Tab Delimited

I have a file which was pipe delimited, I need to make it tab delimited. I tried with sed but no use cat file | sed 's/|//t/g' The above command substituted "/t" not tab in the place of pipe. Sample file: abc|123|2012-01-30|2012-04-28|xyz have to convert to: abc 123... (6 Replies)
Discussion started by: karumudi7
6 Replies

5. Shell Programming and Scripting

Remove white spaces from flat file generated from Oracle table...

I have to export data from table into flat file with | delimited. In the ksh file, I am adding below to do this activity. $DBSTRING contains the sqlplus command and $SQL_STRING contains the SQL query. File is created properly with the data as per SQL command. I am getting white spaces in the... (1 Reply)
Discussion started by: mgpatil31
1 Replies

6. Shell Programming and Scripting

Remove few columns from pipe delimited file

I have file as below column1|column2|column3|column4|column5| fill1|fill2|fill3|fill4|fill5| abc1|abc2|abc3|abc4|abc5| . . . . i need to remove column2,3, from that file column1|column4|column5| fill1|fill4|fill5| abc1|abc4|abc5| . . . (3 Replies)
Discussion started by: greenworld123
3 Replies

7. Shell Programming and Scripting

Insert empty columns inside a pipe delimited file

Hi All , I have pipe delimiter file with 11 columns . I need to insert 4 empty columns after column 10 . and After 11 column I need to insert a column which is having the same value for all the rows . My file 1|2|3|4|5|6|7|8|9|10|11 New file ... (11 Replies)
Discussion started by: Hypesslearner
11 Replies

8. Shell Programming and Scripting

Shuffle Columns in Pipe delimited data

My sample data contains escape characters followed by delimiter. I'm stuck in writing awk comand to swap the columns. please help me out. Sample Data: 12345678|ABN\|XYZ MED CHEM PTY. LTD.|C||100.00|22|AB"C\|Corp|"XYZ|CDEF"| Expected Output Data: 12345678|C|ABN\|XYZ MED CHEM PTY.... (10 Replies)
Discussion started by: BrahmaNaiduA
10 Replies

9. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies

10. Shell Programming and Scripting

Parameterizing to dynamically generate the extract file from Oracle table using Shell Script

I have below 2 requirements for parameterize the generate the extract file from Oracle table using Shell Script. Could you please help me by modifying the script and show me how to execute it. First Requirement: I have a requirement where I need to parameterize to generate one... (0 Replies)
Discussion started by: hareshvikram
0 Replies
SET SESSION 
AUTHORIZATION(7) SQL Commands SET SESSION AUTHORIZATION(7) NAME
SET SESSION AUTHORIZATION - set the session user identifier and the current user identifier of the current session SYNOPSIS
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT RESET SESSION AUTHORIZATION DESCRIPTION
This command sets the session user identifier and the current user identifier of the current SQL-session context to be username. The user name may be written as either an identifier or a string literal. The session user identifier is valid for the duration of a connection; for example, it is possible to temporarily become an unprivileged user and later switch back to become a superuser. The session user identifier is initially set to be the (possibly authenticated) user name provided by the client. The current user identi- fier is normally equal to the session user identifier, but may change temporarily in the context of ``setuid'' functions and similar mecha- nisms. The current user identifier is relevant for permission checking. The session user identifier may be changed only if the initial session user (the authenticated user) had the superuser privilege. Other- wise, the command is accepted only if it specifies the authenticated user name. The SESSION and LOCAL modifiers act the same as for the regular SET [set(7)] command. The DEFAULT and RESET forms reset the session and current user identifiers to be the originally authenticated user name. These forms are always accepted. EXAMPLES
SELECT SESSION_USER, CURRENT_USER; current_user | session_user --------------+-------------- peter | peter SET SESSION AUTHORIZATION 'paul'; SELECT SESSION_USER, CURRENT_USER; current_user | session_user --------------+-------------- paul | paul COMPATIBILITY
SQL99 SQL99 allows some other expressions to appear in place of the literal username which are not important in practice. PostgreSQL allows iden- tifier syntax ("username"), which SQL does not. SQL does not allow this command during a transaction; PostgreSQL does not make this restriction because there is no reason to. The privileges necessary to execute this command are left implementation-defined by the stan- dard. SQL - Language Statements 2001-04-21 SET SESSION AUTHORIZATION(7)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy