473,669 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need sample DB2 script called by AIX script

Hi,
I am new to DB2. Does someone have a sample DB2 script they can post
here? All I want to do is execute a SQL query like this:
SELECT * FROM TABLE

Also, can someone post a sample AIX script that calls executes this
DB2 script ?

I am guessing that AIX script would looks like this:
"db2" < "C:\db2SQL.SCRI PT"
echo status: (RC=%errorlevel % )
Nov 12 '05 #1
4 9719
David wrote:
Hi,
I am new to DB2. Does someone have a sample DB2 script they can post
here? All I want to do is execute a SQL query like this:
SELECT * FROM TABLE

Also, can someone post a sample AIX script that calls executes this
DB2 script ?

I am guessing that AIX script would looks like this:
"db2" < "C:\db2SQL.SCRI PT"
echo status: (RC=%errorlevel % )


That looks very much Windows-like.

How about the following...

SQL script named "query.sql" :
-------------------
SELECT *
FROM syscat.tables;
-------------------

AIX shell script (assuming ksh or bash or so):
-------------------
#!/bin/sh

db2 -t -f query.sql
if [ $? ]; then
echo "Script failed"
fi
-------------------
Or you do something like this:
-------------------
db2_out=`db2 -t -v -f query.sql`
echo $db2_out
--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
David wrote:
Hi,
I am new to DB2. Does someone have a sample DB2 script they can post
here? All I want to do is execute a SQL query like this:
SELECT * FROM TABLE

Also, can someone post a sample AIX script that calls executes this
DB2 script ?

I am guessing that AIX script would looks like this:
"db2" < "C:\db2SQL.SCRI PT"
echo status: (RC=%errorlevel % )


That looks very much Windows-like.

How about the following...

SQL script named "query.sql" :
-------------------
SELECT *
FROM syscat.tables;
-------------------

AIX shell script (assuming ksh or bash or so):
-------------------
#!/bin/sh

db2 -t -f query.sql
if [ $? ]; then
echo "Script failed"
fi
-------------------
Or you do something like this:
-------------------
db2_out=`db2 -t -v -f query.sql`
echo $db2_out
--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3
"Knut Stolze" <st****@de.ibm. com> wrote in message
news:c6******** **@fsuj29.rz.un i-jena.de...
David wrote:
Hi,
I am new to DB2. Does someone have a sample DB2 script they can post
here? All I want to do is execute a SQL query like this:
SELECT * FROM TABLE

Also, can someone post a sample AIX script that calls executes this
DB2 script ?
[snip] How about the following... [snip] AIX shell script (assuming ksh or bash or so):
-------------------
#!/bin/sh

db2 -t -f query.sql
if [ $? ]; then
echo "Script failed"
fi
-------------------


Another option is to inline your SQL like so

#-------------------
#!/bin/sh
echo "
SELECT * FROM sometable
;" | db2 +p -vt
#-------------------

which has the benefit of allowing expansion of shell variables, e.g.:

#-------------------
#!/bin/sh
months="01 02 03 04 05 06 07 08 09 10 11 12"

for t in $months; do echo "
CREATE TABLE FACT_2004_$t
( I INT NOT NULL
, C CHAR(5)
)
;
" | db2 +p -vt ;done
#-------------------

Regards
Paul Vernon
Business Intelligence, IBM Global Services
Nov 12 '05 #4
"Knut Stolze" <st****@de.ibm. com> wrote in message
news:c6******** **@fsuj29.rz.un i-jena.de...
David wrote:
Hi,
I am new to DB2. Does someone have a sample DB2 script they can post
here? All I want to do is execute a SQL query like this:
SELECT * FROM TABLE

Also, can someone post a sample AIX script that calls executes this
DB2 script ?
[snip] How about the following... [snip] AIX shell script (assuming ksh or bash or so):
-------------------
#!/bin/sh

db2 -t -f query.sql
if [ $? ]; then
echo "Script failed"
fi
-------------------


Another option is to inline your SQL like so

#-------------------
#!/bin/sh
echo "
SELECT * FROM sometable
;" | db2 +p -vt
#-------------------

which has the benefit of allowing expansion of shell variables, e.g.:

#-------------------
#!/bin/sh
months="01 02 03 04 05 06 07 08 09 10 11 12"

for t in $months; do echo "
CREATE TABLE FACT_2004_$t
( I INT NOT NULL
, C CHAR(5)
)
;
" | db2 +p -vt ;done
#-------------------

Regards
Paul Vernon
Business Intelligence, IBM Global Services
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2243
by: Brian Murphy | last post by:
<?php /* I need your help. I'd be very thankfull if write me this script.I need a script that displays a list of categories and subcategories like this: <select name="category"> <option value="1">Main</option> <option value="2">Main > Computers</option> <option value="4">Main > Computers > Hardware </option>
5
9198
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
1
4266
by: Dan | last post by:
Hi, I am using the Employee.fdb sample that comes with Firebird 1.5.1. Everything resides on a WinXP Pro pc. I set up an ODBC connection called "FB Employee Sample" and tested it with MS Access and Brio; works OKAY. When I try to run the following script: *************************** <html> <body>
3
11465
by: John MacIntyre | last post by:
Hi, Can anybody give me a hint as to how to convert a javascript array into a vbscript array? BTW-it only needs to work in IE5 & 6 Thanks in advance, John MacIntyre VC++ / VB / ASP / Database Developer
4
5043
by: Bob | last post by:
Below is sample code that illustrates what I'm trying to do. For sake of brevity I didn't include the properties of buildBtn that determine what data to request. The problem is I never see "Processing request" and depending on server utilization the response can take several seconds to load leading the users to wonder if the system is working. Unfortunately getting rid of the users is not an option :) so any help I can get on making...
0
463
by: David | last post by:
Hi, I am new to DB2. Does someone have a sample DB2 script they can post here? All I want to do is execute a SQL query like this: SELECT * FROM TABLE Also, can someone post a sample AIX script that calls executes this DB2 script ? I am guessing that AIX script would looks like this: "db2" < "C:\db2SQL.SCRIPT"
17
2078
by: freemann | last post by:
Can anyone provide example code showing how to send form results to a results page, email and a comma delimited file? Notice that I need it going to all three locations. Details: I have forms created and working. The first form the user fills out and submits. The form properties are set to Send to other: "Custom ISAPI, NSAPI, CGI, OR ASP SCRIPTING. The method is "POST" and the action is "secondpage.asp". I had to go this route because...
7
2525
by: fox | last post by:
Hi, Lacking javascript knowledge, I just realized why my project has a bug. I am using ASP to loop through a set of records while it creates URLs with a querystring that has a single value pair. This URL needs to open in a floating window if clicked. (this is for an administrator and so opening a small floater gives them more efficient access to the data that will be displayed). I now understand that because the ASP executes first, that...
4
1681
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script> <script type="text/javascript"> // <!.indexOf('='); if( pos == -1 ) { continue; // Look for "name=value"
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8894
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8587
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.