473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Run a block of sql commands using 'here document'

Hi,

I know that using 'Here Documents', we can otuput multiple lines. But is it possible to run a couple of commands?

Expand|Select|Wrap|Line Numbers
  1. $s = qx [sqlplus user/paswd\@schema <<ENDOFSQL
  2. select 2 from DUAL;
  3. exit
  4. ENDOFSQL];
  5.  
Any ideas on how to make the above code work??
(I do not want to install DBI module and then invoke the sql commands)

Thanks in advance!!!

Sailaja
Jun 8 '07 #1
3 1921
miller
1,089 Expert 1GB
My suggestion is that you output these commands to a file first, and then import the file. It certainly might be possible to do it the other way, but this way you could also pipe out the result.

Expand|Select|Wrap|Line Numbers
  1. `sqlplus user/paswd\@schema < test.sql > result.sql`;
  2.  
Yes, this is messy. But I believe that it's cleaner than what you were attempting before at least.

- Miller
Jun 8 '07 #2
Thanks for the response.

I was able to do in the following manner:
Expand|Select|Wrap|Line Numbers
  1. sub sqlplus {
  2.     my $param = shift;
  3.     my $script_text = shift;
  4.     open my $script, "| sqlplus $param" or die $!;
  5.     print $script $script_text;
  6.     close $script or die $!;
  7. }
  8.  
  9. sqlplus("devscu/devscu@dbkls", <<SCRIPT );
  10. select 2 from DUAL;
  11. exit
  12. SCRIPT
  13.  
Jun 8 '07 #3
miller
1,089 Expert 1GB
Very nice. Well done.

- Miller
Jun 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ÂÑTØÑ | last post by:
Hi, I was looking for a list of commands, but I can't find it. It's about commands you can type in the Internet Explorer adress bar, to get some information about a website. For instance...
12
by: Charles Law | last post by:
Hi guys A bit of curve ball here ... I have a document (Word) that contains a series of instructions in sections and subsections (and sub-subsections). There are 350 pages of them. I need to...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
2
by: ethandbrown | last post by:
Hi All-- I'm a bit stymied here. I need to display arbitrary HTML obtained through AJAX. The problem is when a <script> block is encountered one can't use innerHTML to set the content, because...
7
by: Janis | last post by:
I try to understand what could be the source of a problem with displaying and hiding rows of tables using display:block/none. I've read selfhtml but could not find any hint about that. Any...
2
by: masterofzen | last post by:
Hi, everybody -- first post for me, though I land here via Google all the time. This is the first time, though, that I just haven't been able to find anything even remotely resembling a solution to...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.