dbTalk Databases Forums  

Re: DB2 prep bind needed everytime?

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Re: DB2 prep bind needed everytime? in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Knut Stolze
 
Posts: n/a

Default Re: DB2 prep bind needed everytime? - 10-04-2007 , 02:46 PM






crack.the.hack (AT) gmail (DOT) com wrote:

Quote:
Hi All,

If I am changing the database machine, what should I do not to prep
bind the sqc files everytime.

Because I need to build my application everytime the database is
changed?

Is there any way, to do prep bind with "defined timestamp" or
something which does not require any prep - binding even when the
database is changed.
When you precompile your SQC files, you specify the option BIND <bindfile>.
That will generate a so-called bindfile. All you have to do at the target
system is to bind that bind file. The bind step will create the necessary
packages and you don't have to precompile the source code at the target
system again.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany


Reply With Quote
  #2  
Old   
Serge Rielau
 
Posts: n/a

Default Re: DB2 prep bind needed everytime? - 10-05-2007 , 07:01 AM






crack.the.hack (AT) gmail (DOT) com wrote:
Quote:
If I am changing the database machine, what should I do not to prep
bind the sqc files everytime.

Because I need to build my application everytime the database is
changed?

Is there any way, to do prep bind with "defined timestamp" or
something which does not require any prep - binding even when the
database is changed.
You need to distinguish between PREP and BIND.
If you produce a bind file when doing the PREP you can deploy the bind
file with your compiled application.
All DB2 needs to do then is BIND the application against the database.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
  #3  
Old   
Knut Stolze
 
Posts: n/a

Default Re: DB2 prep bind needed everytime? - 10-10-2007 , 04:46 AM



Ankit wrote:

Quote:
Thanks man for your kind help, you mean to say I need to build the
application including the .bnd file?
You don't "need to" but if you want to deploy the application on a different
system than where it was build, bindfiles are the way to distribute the SQL
statements to the target system. With a bindfile, it is not necessary to
recompile (including precompile) an application at the target system. Just
copy the executables, shared libraries, bindfiles (and whatever else the
application may need) to the system, bind the bindfiles to create the
respective packages in DB2 and then start the application.

Quote:
I am now telling you the exact scenario! See suppose I am using a
database named DB1, I have .sqc files containing the sql commands. We
do prep by the following command at the db2 command line:

"db2 prep file1.sqc Version V1.0 bindfile "

then I do bind those .sqc by the following command:

"db2 bind filename.bnd"

Now, suppose we are migrating the application to the new database
named DaB2, do we again need to prep the files because if we do need
then again the new .C files are getting generated and I am bound to
rebuild the application.
As I mentioned above: since you don't change the code, there is no need to
precompile anything again. You won't get new .C files and you don't have
to recompile such .C files. (This assumes that you have the same platform
and don't change the actual code, of course.)

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany


Reply With Quote
  #4  
Old   
Knut Stolze
 
Posts: n/a

Default Re: DB2 prep bind needed everytime? - 10-10-2007 , 03:53 PM



Ankit wrote:

Quote:
Well what about the sqc file connection string?? Of course it would be
change, although I am trying to use system variable yet it is not
allowing me to do so.!!!!!

Sending you the sample code of connection.sqc

char * dname = getenv("DATABASE");
char * username = getenv("USER");
char * password = getenv("PASSWORD");

void Db2connect()
{
/*********************end of C code*******************************/

Now, even after I bind connection.bnd to the database 1 and database
2, it only accepts the connection to the first database, not the
second one..

Can i generalise my .C file so that there are no change required. I am
sure my problem is very clear to you.
If you hard-code database name, user-id and/or password, you have a problem.
You should parameterize your code to read such information either from some
config file (which can easily be adjusted with your favorite editor), or
receive that information via command line parameters.

Besides that, you can use the LEVEL option available for the PRECOMPILE
command to avoid recreating and rebinding a bind file if the code but not
the SQL statements within the code changes. That way, you would only change
the LEVEL if a SQL statement (and, thus, the package) will change. But
then, having the hard-coded connection information requires you to
recompile the code anyways. A new package is not a big deal then.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.