473,748 Members | 9,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Packages, Bind, Prepare and Execute

Hi,

I have started using DB2 UDB ESE v8.2 in Linux recently. I have
seen a lot of articles on packages, prepare statement, bind and execute
statement.

I havent got a clear idea.

I have written a few stored procedures but havent used prepare and
execute.
what are its advantages. ?

What is a package in DB2 UDB and how do you bind and rebind (I really
dont know what to bind, even) ?
Thanks in advance.

Mar 3 '06 #1
1 2939
rAinDeEr wrote:
Hi,

I have started using DB2 UDB ESE v8.2 in Linux recently. I have
seen a lot of articles on packages, prepare statement, bind and execute
statement.

I havent got a clear idea.

I have written a few stored procedures but havent used prepare and
execute.
what are its advantages. ? You use PREPARE and EXECUTE if the SQL statement text s not known in
advance. SQL allows only values to be passed in at execution (through
parameter markers or variables).
Identifiers (such as a table name) cannot be variable.
That is:
'SELECT * FROM ? WHERE ?.? = 5' is not legal SQL.
So, if you want to compose SQL on the fly you have to glue together the
SQL string:
SET txt = 'SELECT * FROM ' || mytable || 'WHERE ' || mytable || '.' ||
mycolumn || '= 5'
And then prepare (compile) and execute the statement.
Note that queries (as above) are executed by opening a CURSOR, while
UPDATE/DELETE/INSERT/MERGE/CALL and DDL statements get executed using
the EXECUTE statement (they don't return resultsets).

What is a package in DB2 UDB and how do you bind and rebind (I really
dont know what to bind, even) ?

If are are using SQL Procedures you can afford to stay reasonably
ignorant on those.
Compilation of any procedure happens in up to three phases:
1. PREP
Separate the SQL from the programming logic (e.g. C)
2. BIND compile the SQL and store the result in a PACKAGE on the server
3. Compile and Link the programming logic for external procedure

For an SQL Procedure there are really only 2 interfaces you have with
the package:
REBIND_ROUTINE_ PACKAGE() which you call after statistics for tables used
in the procedure have been updated or e.g. an index has been dropped.
http://publib.boulder.ibm.com/infoce...n/r0009863.htm

SET_ROUTINE_OPT S()
which you can call before creating a procedure to change its semantics
(such as the isolation level) from the default.
http://publib.boulder.ibm.com/infoce...n/r0011873.htm

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Mar 3 '06 #2

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

Similar topics

7
5675
by: Anthony Robinson | last post by:
Have been encountering an odd issue. Every now and again, certain packages of stored procedures just become invalid. I'm aware that dropping or altering an underlying table would render a package invalid, but we are doing no such thing... After banging my head on the wall for a bit I noticed that the two stored procedures that are experiencing this behavior are procedures that are called from within another procedure (they're not both...
2
2200
by: virgilio | last post by:
Hi all, "Administrator Guide Implementation" DB2 8.2, chapter 7, section "Indirect privileges through a package" states: (highlight >>>>!!!<<<<) "Privileges granted to individuals binding the package and to PUBLIC are used for authorization checking when static SQL is bound. Privileges granted through groups are >>>>not!!!!<<<< used for authorization checking when static SQL is bound. The user with a valid authID who binds a package...
2
3852
by: claus.hirth | last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement in order to play with the PREPARE and EXECUTE keywords. In transcript 1 below the call to that stored procedure does not work. Yet transcript 2 shows that the stored procedure does its job, if only the table name is provided directly in the statement text string, instead of as a host variable to a prepared statement like in 'EXECUTE stmt USING tabName, fldValue'. --...
0
1093
by: tfs | last post by:
I am having a problem with executing DTS packages on my clients machine. The exact same code (except for the Server Name) and packages work fine on my machine. We are running Sql Server 2000 and ASP.Net 1.1. When you look at my code you will see a few lines that will all be commented out but 1 where I am setting sqlString to the code I want to execute. I find that on my client machine the same code will execute a stored procedure(as...
3
3453
by: DavidPL | last post by:
Hello, I have some problem with bind method in PDO on Oracle with clob | long column type. I have table named TEST_TABLE where I have two columns: ID (int 10, 0) and TEXT (varchar 4000 or long or clob). When I try execute PHP code (based on example in manual): <?php
1
3658
by: gmccammon | last post by:
I'm having problems with my Prepare and Execute statements. I get a syntax error onmy prepare and of course the execute won't run on an undefined value. I don't know what I am overlooking. #!/Perl/bin/perl # Program to read information sent to the server # from the form in the contact_list.xhtml document.
1
1847
by: itsraghz | last post by:
Hello All, I am using a Dynamic SQL Statement inside a Stored Procedure. I am using IBM DB2 V8.1 database. When i want to have the values to be filled in dynamically, i use the parameter marker (?). I dont have any issues if the value is of type VARCHAR. But I get an error if i bind a value other than Varchar (String) say, an Integer. The error I get is "The statement "<stmt what i prepare>" is too long". See the statements i use : ...
2
4711
by: beena | last post by:
Hi ! All, Question on binding packages on UDB 8.x on AIX 5.x... Is there is way to bind all the packages like a BIND ALL? Thanks - beena
1
1667
by: mtanquary | last post by:
I have a script that runs in my DEV and PROD environment, but for some reason on my TEST server, I am getting the following error: The script's function is to read from an XML file and load the data to an Oracle table. I believe this error is actually caused by the environment, not sure what yet, but I have checked the DBI and DBD version against our PROD server and they are matched. I am running the script against the exact same XML...
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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
9537
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
9243
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
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
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
3
2213
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.