Re: calling stored procedure of two database?
Posted in 1995
Topics: Stored Procedures & SPL
> > I have a stored Procedure (say, SPsample) in two identical > > databases (Db1 and Db2) for two clients. > > > > ----------- > > | GUI | > > ----------- > > | > > | > > | > > ------------ > > | MY SERVER| > > ------------ > > > > The GUI can send data for either client 1 > > or client 2. Based on the client data, I have to call > > either the SP of database 1 or SP of database 2. > > > > Can somebody suggest a way to do this? (I don't > > want to use two $execute procedure statements for this). > > > > > > I tried the following: > > $char string[100]; > > > > if (client1_data) { > > sprintf(string, "%s:%s", "Db1", "Spsample"); > > } > > else { > > sprintf(string, "%s:%s", "Db2", "Spsample"); > > } > > > > $execute procedure :string(...); > > > > But I get syntax error (33051) for this. > > > > > > Environment: > > Online 5.0, Sol 2.3 > > > > Thanks, > > > > I would use Dynamic SQL, something like > > > $begin declare section; > char pszqry[512]; > $end declare section; > > if (client1_data) > sprintf(pszqry, "execute procedure %s:%s()", Db1, Spsample); > else > sprintf(pszqry, "execute procedure %s:%s()", Db2, Spsample); > > $prepare StmtId from :pszqry; > > $execute StmtId; > > Hope this helps. > > -raj