473,657 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 prep bind needed everytime?

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.

Help is urgently needed!!

Thanks in Advance
Regards,
Ankit Rawat
M.S.

Oct 4 '07 #1
6 5680
cr************@ gmail.com wrote:
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
Oct 4 '07 #2
cr************@ gmail.com wrote:
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
Oct 5 '07 #3
On Oct 5, 8:01 am, Serge Rielau <srie...@ca.ibm .comwrote:
crack.the.h...@ gmail.com wrote:
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
Thanks man for your kind help, you mean to say I need to build the
application including the .bnd file?

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.

Regards,
Ankit R.
M.S

Oct 10 '07 #4
Ankit wrote:
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.
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
Oct 10 '07 #5
On Oct 10, 5:46 am, Knut Stolze <sto...@de.ibm. comwrote:
Ankit wrote:
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.
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
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
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sql.h"
//#include "ibmdadb2.h "

#include "sqlca.h"
#include "sqlenv.h"
#include "sqlcodes.h "
#include "sqlutil.h"
#include "db2ApiDf.h "

char * dname = getenv("DATABAS E");
char * username = getenv("USER");
char * password = getenv("PASSWOR D");

void Db2connect()
{
EXEC SQL INCLUDE sqlca;
//struct sqlca sqlca;

/* connect to a database */

EXEC SQL CONNECT TO dname USER user USING password;
if (sqlca.sqlcode != 0)
{
MessageBox(0,"C onnection Fail","Msg",0);
}
} /* end main */
/*************** *************** ******end of
sqc************ *************** *************** *****''/

Now the C file is generated looks like:
/*************** *************** **C generated code from .sqc
file*********** *************** */
static char sqla_program_id[162] =
{
43,0,65,68,65,7 4,65,72,67,79,7 8,78,69,67,84,7 3,71,66,99,118,
70,75,75,88,48, 49,49,49,49,50, 32,32,9,0,83,86 ,67,82,69,80,
79,53,80,0,0,0, 0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,0,0,0,0,
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0, 0,0,0,0,0,
0,0
};

#include "sqladef.h"

static struct sqla_runtime_in fo sqla_rtinfo =
{{'S','Q','L',' A','R','T','I', 'N'}, sizeof(wchar_t) , 0, {' ',' ',' ','
'}};
#line 1 "connection.sqc "
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sql.h"
//#include "ibmdadb2.h "

#include "sqlca.h"
#include "sqlenv.h"
#include "sqlcodes.h "
#include "sqlutil.h"
#include "db2ApiDf.h "

char * dname = getenv("DATABAS E");
char * username = getenv("USER");
char * password = getenv("PASSWOR D");

void Db2connect()
{

/*
EXEC SQL INCLUDE sqlca;
*/

/* SQL Communication Area - SQLCA - structures and constants */
#include "sqlca.h"
struct sqlca sqlca;
#line 26 "connection.sqc "

//struct sqlca sqlca;

/* connect to a database */
/*
EXEC SQL CONNECT TO dname USER username USING password;
*/

{
#line 31 "connection.sqc "
sqlastrt(sqla_p rogram_id, &sqla_rtinfo , &sqlca);
#line 31 "connection.sqc "
sqlaaloc(2,3,1, 0L);
{
struct sqla_setd_list sql_setdlist[3];
#line 31 "connection.sqc "
sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 6;
#line 31 "connection.sqc "
sql_setdlist[0].sqldata = (void*)dname;
#line 31 "connection.sqc "
sql_setdlist[0].sqlind = 0L;
#line 31 "connection.sqc "
sql_setdlist[1].sqltype = 460; sql_setdlist[1].sqllen = 9;
#line 31 "connection.sqc "
sql_setdlist[1].sqldata = (void*)username ;
#line 31 "connection.sqc "
sql_setdlist[1].sqlind = 0L;
#line 31 "connection.sqc "
sql_setdlist[2].sqltype = 460; sql_setdlist[2].sqllen = 9;
#line 31 "connection.sqc "
sql_setdlist[2].sqldata = (void*)password ;
#line 31 "connection.sqc "
sql_setdlist[2].sqlind = 0L;
#line 31 "connection.sqc "
sqlasetda(2,0,3 ,sql_setdlist,N ULL,0L);
}
#line 31 "connection.sqc "
sqlacall((unsig ned short)29,5,2,0, 0L);
#line 31 "connection.sqc "
sqlastop(0L);
}

#line 31 "connection.sqc "

if (sqlca.sqlcode != 0) {
MessageBox(0,"C onnection Fail","Msg",0);

}
} /* end main */
/*************** ******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.
Thanks in advance!!

Oct 10 '07 #6
Ankit wrote:
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("DATABAS E");
char * username = getenv("USER");
char * password = getenv("PASSWOR D");

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
Oct 10 '07 #7

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

Similar topics

7
4121
by: D | last post by:
I have been working with Oracle as web developer for three years, I have 13 years of database (SQL Server, DB2) experience and I'm getting a masters degree in CS, but don't expect to finish for 2 more years. I can do all the aspects of Oracle I need for my jobn- PL/SQL, performance tuning, backup and recovery, etc. I have not done well on the OCP practice tests I took and I believe I am ready for one of those courses that teaches to the...
17
7050
by: Jochen Luebbers | last post by:
Hi, I've a problem: I compile modules of embedded SQL (for a dynamic lib) on multiple platforms (AIX,Linux,Windows). They are compiled from the same source code. To be able to provide all platforms at the same time on ONE database (server), I want different package names - e.g. module1.sqc should produce packages AMOD1, LMOD1, and WMOD1. So I tried the following db2 call for preparing:
1
2377
by: Analyst | last post by:
I'm trying to figure out how, from the Visual C++ GUI, to run a precompiler on my .SQC files, and create the corresponding .C files. I know about the DB2 command window, and how to do a DB2 PREP from there. That's not the information I'm looking for. I have a workspace set up in Developer Studio where some of the projects have ..SQC files, and others don't. I want to be able to build the whole workspace from the GUI. I don't want to...
17
2747
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
1
6862
by: Vijay | last post by:
CSQA & CSTE Prep Courses for International Certifications by QAI,USA @Hyderabad After receiving overwhelming response to our last 50+ batches, SpectraMindSolutions.com now announces a new batch of Prep Courses for CSQA & CSTE so as to prepare you thoroughly for the most prestigious certification exams conducted by QAI, USA (www.qaiusa.com). We have consistent record of 100% passing results for last 5+ years.
0
6734
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, SPECTRAMIND SOLUTIONS now announces a new batch of Prep Courses for CSQA & CSTE& ISEB & ISTQB & Business Analyst & SOA so as to prepare you thoroughly for the most prestigious certification exams conducted by International organizations. We...
1
1966
by: gsgskms | last post by:
our code is written in C++ (unix) with SQL for connecting to db2 DB. we have dev (d30), systest(m30) schemas on same db (db2u). we need a solution to build once and use it on dev & systest environments. please suggest me some thing. we are totally stuck. we are using: db2 prep bindfile using abc.bnd qualifier d30 collection d30_col db2 bind abc.bnd qualifier d30 collection d30_col.
0
1680
by: Vijay | last post by:
Prep Courses for International Certifications by QAI,USA After receiving overwhelming response to our last 95 batches, Spectramind now announces a new batch of Prep Courses for CSQA & CSTE so as to prepare you thoroughly for the most prestigious certification exams conducted by QAI, USA .We have consistent record of almost 100% passing results for last 8+ years. 1. Certified Software Quality Analyst (CSQA) What is CSQA?
4
1649
by: bz | last post by:
Hi, I need to create a win service that lookup a file ina folder, ands when received, read it then fir an event. Then I need a desktop app that, when runs, bind to the event from the win service, and when the event fires, read the eventarg data and do some processing with. Can anyone point me to the right direction to do this?
0
8395
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
8826
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
8732
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
8503
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
7330
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...
0
5632
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
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.