How to run a .p with different database names.

ramesh.chander

New Member
Hi All,

I am developing a web application which is used to show data with different database(s). All databases have the same tables but different data. The name of the databases are test1, test2, test3, test4.
I am selecting the database from the login screen and after that connect the database using connect statement with different parameters like -H, -S etc. sometimes the programs giving me the correct result and sometimes not. if the interval between the request is large then correct result will come up otherwise not.

Please suggest how could i achieve this functionality.

Thanks
RC
 

RealHeavyDude

Well-Known Member
From you error description I'm not positive if this applies to you, _BUT_:

Every database connected from a client has to parameters that are relevant:
  • The physical database name (-db) which you need to connect to the database
  • The logical database name (-ld) which is compiled into the .r files
If you don't specify the logical database name it equals the physical database name (without path of course).

Therefore you could have different physical databases that are connected with the same logical database name and you will be fine. You could have several database with the same physical name but connect them with different logical database names and you will be fine.

If you reference a database table in your program and that table is not unique (given you are connected to more than one database) you need to specify the logical database name. For example: db-name.table-name.field-name ...

HTH, RealHeavyDude.
 

ramesh.chander

New Member
Hi RHD,

I know that concept. Actually in Application, we are selecting the database from the login page.
after that whenever we require the data. we just run three .p (s)
1. connect.p /* connect with database using logical database name */
2. run data.p /* fetches data from database */
3. disconnect.p /* disconnect the database */

Sometimes, the coming data is correct and sometimes it throws an error in the server log file.
database test 2 is not connected.Right now i want to connect with test 3 but earlier it was test 2

Note: Using Ajax, we are fetching data.
we did not create the .r for that .p

Thanks
Ramesh
 

SikandraShahid

New Member
Hi Ramesh,

Are databses not connected already with webbroker? Whats the operating mode you are using?

Do you disconnect from the db once request is completed?

It looks like session retains when the interval between the request is less.

Regards,
Sikandra
 

RealHeavyDude

Well-Known Member
I don't have much experience with the WebSpeed broker but I do have with the AppServer.

Letting the WebSpeed broker connect and disconnect the database per request seems odd to me. Mostly because of the latency involved connecting a dabase - even more so when the database resides on a different machine and you need to connect it via the network.

If I were you I would configure a dedicated WebSpeed broker for each database and redirect the request to the WebSpeed broker which has the database connected you need. There is not much overhead involved other than the additional processes for the brokers and agents.

HTH, RealHeavyDude.
 

ramesh.chander

New Member
Hi Sikandra,

Database are not connected with webbroker. Only main database is connect with webbroker.
In Web, we are using stateless mode.
After completion the request, I am disconnecting the database.

How can we resolve this issue?

Thanks,
Ramesh
 

RealHeavyDude

Well-Known Member
Hi Ramesh,

what is the reason you are not able to create additional WebSpeed brokers?

How and where do you connect and/or disconnect the databases?


Regards, RealHeavyDude.
 

mrobles

Member
Hi Ramesh

I'm using a 'dirty' way to solve this problem.
When I had this problem, I recive the error 1896 (crc).
Before run your program, compile it in the same caller program.

DEF VAR t_base AS CHAR NO-UNDO EXTENT 3.
t_base[1] = 'C:\base\adm'.
t_base[2] = 'C:\base\adm1'.
t_base[3] = 'C:\base\adm2'.

RUN C:\progs\conecta.p (t_base[1]).
COMPILE C:\progs\review.p SAVE INTO C:\progs.
RUN C:\progs\review.p.
RUN C:\progs\desconecta.p.

RUN C:\progs\conecta.p (t_base[2]).
COMPILE C:\progs\review.p SAVE INTO C:\progs.
RUN C:\progs\review.p.
RUN C:\progs\desconecta.p.

RUN C:\progs\conecta.p (t_base[3]).
COMPILE C:\progs\review.p SAVE INTO C:\progs.
RUN C:\progs\review.p.
RUN C:\progs\desconecta.p.

The code of conecta.p is:
DEF INPUT PARAMETER base AS CHAR NO-UNDO.
CONNECT VALUE(base) -1 -ld adm. /* -1 used for test */

The code of desconecta.p is:
DISCONNECT adm.

An example of review.p is:
FIND LAST tabla.
DISPLAY tabla.

M. Robles
 

ramesh.chander

New Member
Hi RHD,

I don't have the permission to create additional WebSpeed brokers. Even if i shall create additional broker, then i need to compile to related files.
So in theory, if i have 4 additional brokers and 1 main broker then there is 4 sets of programs. After that in future, if i am making any change in program
then i need to compile that program in all the places.

I am connecting the database before running the specifed programs and after fetching the data from the database,
disconnect the database. All these activity is done in a single request.

Regards, Ramesh
 

ramesh.chander

New Member
Hi Robles,

I think, you just read out the subject line. My question was related with web development where many users are connected at same time and they are fetching the data from different database.


Regards, Ramesh
 

Casper

ProgressTalk.com Moderator
Staff member
Hi RHD,

I don't have the permission to create additional WebSpeed brokers. Even if i shall create additional broker, then i need to compile to related files.
So in theory, if i have 4 additional brokers and 1 main broker then there is 4 sets of programs. After that in future, if i am making any change in program
then i need to compile that program in all the places.

I am connecting the database before running the specifed programs and after fetching the data from the database,
disconnect the database. All these activity is done in a single request.

Regards, Ramesh


I don't understand your architecture. If you need to recompile your code, then it probably means that it wont run against that specific database. Why would it run when you connect to it during the call?
Are all those databases different databases or do they have the same schema?
If they dont have the same schema then why make 1 point of entry for those databases?

One of the most important characteristics of a website is fast response time (preferable on average way below 400 ms). If you need to reconnect at each call then you wont get there.


The databases are linked to one another in some way, so why not make specific code for a specific database and reroute your calls to the appropiate broker when data from a specific database is needed? This way you keep the logic for that set of data (database) tied to that database. In the situation you are describing now you need to change stuff in the programs you have if there is a change to 1 of the databases involved. Which means you also need to recompile everything.

Well anyway, maybe it helps if you tell us the nature of those databases and how they are linked together. Because somehow it feels like either I'm missing something here or you are trying to overcomplicate things.

Regards,

Casper.
 

RealHeavyDude

Well-Known Member
Hi Ramesh,

Compiling on the fly is not what you want in a production environment. First, you need to buy a development license for that and, second, it adds up to latency as does connecting/disconnecting databases. I think Capser pointed that out.

I don't get "I don't have permission ...". Is is just your boss that said that or a Progress sales rep who wants to squeeze out some money (sometimes Progress sales reps don't understand Progress' pricing and licensing policy).

Whatever the licensing model ( concurrent user / named user / registered client ) of your installation is, it does not specify how many WebSpeed Brokers or databases you may run. Just how many users or devices you are allowed to support with your server backend.

If the databases have the same schema you need only one set of code. All WebSpeed Brokers have the same working directory. You use the same logical database name for all of them for compilation ( only the logical database name is compiled into the R-code ) and runtime and you'll be fine.

Do they have the same schema?

Regards, RealHeavyDude.
 
Top