I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command:
I get the folloiwng:
Where as what I need is all of the above on one line.
Can anyone please help me out?
Thanks a lot
S. BASU
Last edited by Franklin52; 01-14-2015 at 09:56 AM..
Reason: Please use code tags
I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command:
echo "SELECT FIELD01 FROM TABLE_NAME;" | sqlplus -s <login>/<password>@<CONNECTION_NAME> I get the folloiwng:
Where as what I need is all of the above on one line.
Can anyone please help me out?
Thanks a lot
S. BASU
As an Oracle DBA, I'd strongly recommend some changes to the way you're doing things.
don't use:
That makes your password visible to anyone logged onto the system via
command
Instead ... consider doing something like:
The advantages of using this structure over what you have are many:
1) keeps your password slightly more protected from prying eyes. it's much harder to sniff out (probably not impossible, but I'm not aware of a simple way to do it at this time).
2) you can build sql scripts in stand alone files, that actually "LOOK" like sql scripts. So they can have "set" commands at the start, var commands set if needed, parameters passed into them (using "&1", "&2", etc to catch them), and many queries if need be. Or as you need, even a simple, single SQL.
3) you can wrap unix braces around that block to capture all output in log file, variable, or whatever you need:
ie:
or you can assign it to a variable:
(that one's untested, sorry, I don't use that format alot myself)
but yeah, two main points are:
a) don't expose your password - use the connect keyword to delay the login and keep the password off the command line, or use External Ids, or some other login mechanism to help protect your password.
b) keep your sql in standalone sql scripts so you can easily test/modify it. Then all you need is "pass it through" to sql, via some wrapper, or such as above.
Tried setting the line size using myriad commands. However I keep getting the error message 'linesize option not a valid number' which is really weird since I am giving 400 which is definitely a valid number.
To be clear I am launching both queries together which is:
set lines 400;SELECT <column_name> FROM <table_name>;
This is because I ideally would not like to again have to create a script file (since that would mean an extra component.
Tried setting the line size using myriad commands. However I keep getting the error message 'linesize option not a valid number' which is really weird since I am giving 400 which is definitely a valid number.
To be clear I am launching both queries together which is:
set lines 400;SELECT <column_name> FROM <table_name>;
This is because I ideally would not like to again have to create a script file (since that would mean an extra component.
Anywhere specific that I could be going wrong?
Irregardless of your final destination, you have a problem, and are troubleshooting.
Create a script file for test purposes .. and see how it behaves ...
You just might find how much easier it is to troubleshoot
Once you have things figured out, you can always splice it back into your "one-liner" solution if you need it
[edit]
fully working sample ... try to setup this working sample first .. then change "my.sql" to use your query instead of the select * from dual .. and see what changes.
Hello,
Can someone please share a Simple AWK command to append Carriage Return & Line Feed to the end of the file, If the Carriage Return & Line Feed does not exist !
Thanks (16 Replies)
Hi
I am using sed command to make SCORE=somevalue to SCORE=blank in a file.
Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line.
cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt
Why does sed command remove the... (3 Replies)
Hi
Is there any way GREP command can return word and not complete line.
My file has following data:
Hello Everyone I am NitinrajSrivastava
Hi Friends Welcome VrajSrivastava
I am using grep 'raj' which is returning me complete line.However I want only the word having keyword 'raj'.
Required... (11 Replies)
How to do I get the return code of a subroutine in a perl module if invoke the subroutine as standalone,
I have an module say TestExit.pm and in that i have a subroutine say myTest() which is returns 12, if i were to call the subroutine from
command line like
CASE:1 ( Without an explict... (2 Replies)
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
Hi All,
Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'.
I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
This is a high-level explanation, if more details are needed, please do not hesitate to ask.
I have a set of .ctl files which I want to execute:
AV1.ctl
AV2.ctl
AV3.ctl
I have a script which has a for loop in it:
for filename in AV1 AV2 AV3
do
. execute_another_script.sh
done
... (2 Replies)
This is probably the dumbest question you guys can get, but I'm trying, as a complete noob, to display the unix calendar for all the months without Saturday and Sunday showing. How can I remove those fields without having to type all the fields in individually such as:
cal -y | awk '{print $2,... (3 Replies)
Hi all,
Does anyone know how to ammend the .cshrc file in $HOME for your session to display the path as part of the command line? So that I dont need to keep on typing pwd to see where I am?
thanks
Ocelot (2 Replies)