This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Execute sql statement from within a script

Hi 1IM Gurus,

We have a template which refers to a custom script, which makes a call to a sequence on our 1IM DB to return a unique number:

"SELECT NEXT VALUE FOR NumGenerator"

To make this call we used the .net SQL client class:

Dim dbConnection As New SqlClient.SqlConnection

This included using a decryption method to pass in the DB connection parameters to setup the DB connection:

VID_GetValueOfDialogdatabases("ConnectionString")

All worked fine in normal operation, however we have found if we attempt to load data via data loader which fired this template, an exception would be thrown.

It appears that the call to decrypt the DB connection string is executing locally and can not find the key to decrypt the connection string.

It there a way to execute an SQL statement via the existing Session or Connection object in a 1IM script, therefore removing the need to create an SQL Client?

Parents
  • Grant,

    Have you considered using the DIalogNextID table to issue unique sequence numbers?  We used it quite successful for generating unique numbers for some of our identity records.  You need to create a row on the table for your sequence number and then call the Custom Method  "GetNextID" table to retrieve it.  Something like

    DIm UID as string = <UID of the row on the DialogNextID table

    Dim nextID = connection.CreateSingle ("DialogNextID", UID)

    Dim id as integer = CInt(nextID.Custom.CallMethod("GetNextID").

    Think I've typed it correctly.

    Ian.

Reply
  • Grant,

    Have you considered using the DIalogNextID table to issue unique sequence numbers?  We used it quite successful for generating unique numbers for some of our identity records.  You need to create a row on the table for your sequence number and then call the Custom Method  "GetNextID" table to retrieve it.  Something like

    DIm UID as string = <UID of the row on the DialogNextID table

    Dim nextID = connection.CreateSingle ("DialogNextID", UID)

    Dim id as integer = CInt(nextID.Custom.CallMethod("GetNextID").

    Think I've typed it correctly.

    Ian.

Children
No Data