473,416 Members | 1,733 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,416 software developers and data experts.

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 5661
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("DATABASE");
char * username = getenv("USER");
char * password = getenv("PASSWORD");

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,"Connection 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,74,65,72,67,79,78,78,69,67,84,73,71, 66,99,118,
70,75,75,88,48,49,49,49,49,50,32,32,9,0,83,86,67,8 2,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_info 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("DATABASE");
char * username = getenv("USER");
char * password = getenv("PASSWORD");

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_program_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,NULL,0L);
}
#line 31 "connection.sqc"
sqlacall((unsigned short)29,5,2,0,0L);
#line 31 "connection.sqc"
sqlastop(0L);
}

#line 31 "connection.sqc"

if (sqlca.sqlcode != 0) {
MessageBox(0,"Connection 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("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
Oct 10 '07 #7

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

Similar topics

7
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...
17
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...
1
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...
17
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...
1
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...
0
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, ...
1
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...
0
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
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...
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,...
0
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...

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.