Quantcast
Channel: Ivanti User Community: Message List
Viewing all articles
Browse latest Browse all 12704

Re: Running SQL script to get query data

$
0
0

Edit:

I misunderstood Your question, however maybe it will be a bit helpfull

 

------

 

Yes, it is, in calculation, but You have to use some .net :

 

import System

import System.Data.SqlClient

static def GetAttributeValue(Incident):

 

    try:

        Value=DateTime.UtcNow.ToString("yyyyMMdd")

 

        dbcon as SqlConnection = SqlConnection()

        command as SqlCommand = dbcon.CreateCommand()

 

        connectionString as string = 'Server=db;Database=LDSD;User Id=LD;Password=****'

        commandstring as string ="SELECT count(*)FROM [LDSD].[dbo].[pm_process]where pm_lifecycle_guid ='2E560C8C-71A2-4762-94E4-0AFB19F7C1E3' and CONVERT (date, pm_raise_date) = CONVERT (date, SYSDATETIME())"

 

        dbcon.ConnectionString = connectionString

        command.CommandText= commandstring

 

        dbcon.Open()   

 

        Value2=command.ExecuteScalar()+1

 

        dbcon.Close()

 

 

 

        if Value2<10:Value3=Value + String.Format('00{0}', Value2)

        elif Value2<100:Value3=Value + String.Format('0{0}', Value2)

 

        return Value3

 

    except e:

        raise String.Format('Error on {0}: {1}', e.StackTrace.Substring(e.StackTrace.LastIndexOf(':') + 1), e.Message)

 

In example above, I'm counting incidents logged today, to prepare my custom IPC Id.


Viewing all articles
Browse latest Browse all 12704

Trending Articles