Click here to Skip to main content
15,892,809 members
Home / Discussions / Database
   

Database

 
GeneralRe: Problem in finding sum of Columns in a Table Pin
Touseef Afzal12-May-04 13:08
Touseef Afzal12-May-04 13:08 
GeneralDataGrid and SQLDataReader Pin
Xaneb12-May-04 9:16
Xaneb12-May-04 9:16 
GeneralRe: DataGrid and SQLDataReader Pin
-Dr_X-12-May-04 16:36
-Dr_X-12-May-04 16:36 
Generalcheck Box and sqlDataReader Pin
Xaneb13-May-04 0:59
Xaneb13-May-04 0:59 
GeneralRe: check Box and sqlDataReader Pin
-Dr_X-13-May-04 11:05
-Dr_X-13-May-04 11:05 
GeneralDetect new record entered/updated in MS SQL Pin
Vu Truong11-May-04 17:08
Vu Truong11-May-04 17:08 
GeneralRe: Detect new record entered/updated in MS SQL Pin
Ian Darling11-May-04 23:24
Ian Darling11-May-04 23:24 
GeneralRe: Detect new record entered/updated in MS SQL Pin
cmk13-May-04 10:53
cmk13-May-04 10:53 
Ian Darling wrote:
Off the top of my head (I've never tried this, so YMMV), you could add a trigger to the database which on the relevant changes which calls into an extended stored procedure

I recently did just that.
I wrote several XP's to send messages to a specified server and port.
Of course there is an issue of protocol for the message format.

In general to write an XP you need the following :


1. Make sure you use the right srv header :
i.e. place
C:\PROGRAM FILES\MICROSOFT SQL SERVER\80\TOOLS\DEVTOOLS\INCLUDE
before
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
in the list of include directories.

#include <srv.h>    // MSSQL ODS header


2. Make sure you link with the OpenDS library :
#pragma  comment(lib, "opends60")    // MSSQL srv_*() functions


3. Make sure all your XP's are compiled as C not C++.
i.e. wrap with
#ifdef __cplusplus
extern "C" {
#endif 
...
#ifdef __cplusplus
}
#endif 
if functions are in a cpp file.


4. Provide a __GetXpVersion() function in your library :
__declspec(dllexport)  ULONG  __GetXpVersion( void )
{
	return(ODS_VERSION);
}


I ended up writing two sets of functions :
CMKMSSQL_API SRVRETCODE xp_cmkInitSvcMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkTermSvcMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkSendSvcMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkBroadcastSvcMsg ( SRV_PROC *SP );
and
CMKMSSQL_API SRVRETCODE xp_cmkInitGisMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkTermGisMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkSendGisMsg ( SRV_PROC *SP );
CMKMSSQL_API SRVRETCODE xp_cmkBroadcastGisMsg ( SRV_PROC *SP );

The *SvcMsg ones just send raw data to the specified server:port.
The *GisMsg ones send protocol formated messages to one of my GIS servers.

xp_cmkInit*Msg is called to create a connection to a specified server:port
Usage : EXEC xp_cmkInitSvcMsg <@server> <@port> [@handle OUTPUT]
The output handle is a long and is used to by the Term/Send functions.

xp_cmkTerm*Msg is called to close a connection.
Usage : EXEC xp_cmkTermSvcMsg <@handle>

xp_cmkSend*Msg sends a blob of data using the connection associated with the specified handle.
Usage : EXEC xp_cmkSendSvcMsg <@handle> <@msg>
Because the message is sent using
sock->Send( (byte*)srv_paramdata(SP, 2), srv_paramlen(SP, 2) );
The message can be any data type.

xp_cmkBroadcast*Msg sends a message to all connections.
Usage : EXEC xp_cmkBroadcastSvcMsg <@msg>
This is the one i call in the triggers.


...cmk

Save the whales - collect the whole set
GeneralcommandString Problem Pin
Anonymous11-May-04 12:52
Anonymous11-May-04 12:52 
GeneralRe: commandString Problem Pin
Edbert P11-May-04 16:49
Edbert P11-May-04 16:49 
GeneralRe: commandString Problem Pin
Aryadip12-May-04 0:09
Aryadip12-May-04 0:09 
GeneralADO UPDATE Problem Pin
petesfish11-May-04 12:31
petesfish11-May-04 12:31 
GeneralRe: ADO UPDATE Problem Pin
WoutL11-May-04 22:56
WoutL11-May-04 22:56 
GeneralRe: ADO UPDATE Problem Pin
petesfish12-May-04 6:27
petesfish12-May-04 6:27 
QuestionHow to get transformation result in DTS Pin
KSEI11-May-04 0:27
KSEI11-May-04 0:27 
Questioncan this query be optimized Pin
22491711-May-04 0:17
22491711-May-04 0:17 
AnswerRe: can this query be optimized Pin
WoutL11-May-04 23:07
WoutL11-May-04 23:07 
GeneralRe: can this query be optimized Pin
22491713-May-04 0:10
22491713-May-04 0:10 
GeneralRe: can this query be optimized Pin
WoutL13-May-04 0:24
WoutL13-May-04 0:24 
GeneralInsert Data into A table Pin
bighi10-May-04 23:27
bighi10-May-04 23:27 
GeneralRe: Insert Data into A table Pin
Edbert P11-May-04 16:50
Edbert P11-May-04 16:50 
GeneralRe: Insert Data into A table Pin
bighi12-May-04 8:36
bighi12-May-04 8:36 
Generalproblem with scope_identity using cmd.Parameters Pin
brunoskorepa10-May-04 22:44
brunoskorepa10-May-04 22:44 
GeneralRe: problem with scope_identity using cmd.Parameters Pin
Edbert P11-May-04 16:53
Edbert P11-May-04 16:53 
GeneralRe: problem with scope_identity using cmd.Parameters Pin
brunoskorepa11-May-04 19:44
brunoskorepa11-May-04 19:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.