Exemple #1
0
		public static void Main()
		{
			SQLRConnection con = new SQLRConnection("sqlrserver", 9000, "/tmp/example.socket", "user", "password", 0, 1);
			SQLRCursor cur = new SQLRCursor(con);

			cur.prepareQuery("begin  :result1:=addTwoIntegers(:integer1,:integer2);  :result2=addTwoFloats(:float1,:float2);  :result3=convertToString(:integer3); end;");
        		cur.inputBind("integer1", 10);
        		cur.inputBind("integer2", 20);
        		cur.inputBind("float1", 1.1, 2, 1);
        		cur.inputBind("float2", 2.2, 2, 1);
        		cur.inputBind("integer3", 30);
        		cur.defineOutputBindInteger("result1");
        		cur.defineOutputBindDouble("result2");
        		cur.defineOutputBindString("result3", 100);
        		cur.executeQuery();
        		Int64 result1=cur.getOutputBindInteger("result1");
        		Double result2=cur.getOutputBindDouble("result2");
        		String result3=cur.getOutputBindString("result3");
        		con.endSession();
Exemple #2
0
        private void copyOutBindValues()
        {
            for (Int32 i = 0; i < Parameters.Count; i++)
            {
                SQLRelayParameter param = (SQLRelayParameter)Parameters[i];

                if (param.Direction == ParameterDirection.Output)
                {
                    param.Size = _sqlrcur.getOutputBindLength(param.ParameterName);

                    switch (param.SQLRelayType)
                    {
                    case SQLRelayType.Clob:
                        param.Value = _sqlrcur.getOutputBindClob(param.ParameterName);
                        continue;

                    case SQLRelayType.Blob:
                        param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName);
                        continue;

                    case SQLRelayType.Cursor:
                        SQLRCursor cursor = _sqlrcur.getOutputBindCursor(param.ParameterName);
                        if (cursor.fetchFromBindCursor())
                        {
                            param.Value = new SQLRelayDataReader(_sqlrelaycon, cursor, false);
                        }
                        continue;
                    }

                    switch (param.DbType)
                    {
                    case DbType.AnsiString:
                    case DbType.AnsiStringFixedLength:
                    case DbType.String:
                    case DbType.StringFixedLength:
                    case DbType.Time:
                    case DbType.Guid:
                        param.Value = _sqlrcur.getOutputBindString(param.ParameterName);
                        break;

                    case DbType.Date:
                    case DbType.DateTime:
                    case DbType.DateTime2:
                    case DbType.DateTimeOffset:
                        Int16   year        = 0;
                        Int16   month       = 0;
                        Int16   day         = 0;
                        Int16   hour        = 0;
                        Int16   minute      = 0;
                        Int16   second      = 0;
                        Int32   microsecond = 0;
                        String  tz          = null;
                        Boolean isnegative  = false;
                        _sqlrcur.getOutputBindDate(param.ParameterName, out year, out month, out day, out hour, out minute, out second, out microsecond, out tz, out isnegative);
                        param.Value = new DateTime(year, month, day, hour, minute, second, microsecond / 1000);
                        break;

                    case DbType.Binary:
                        param.Value = _sqlrcur.getOutputBindBlob(param.ParameterName);
                        break;

                    case DbType.Boolean:
                        param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName);
                        break;

                    case DbType.Currency:
                    case DbType.Decimal:
                    case DbType.Single:
                    case DbType.Double:
                    case DbType.VarNumeric:
                        param.Value = _sqlrcur.getOutputBindDouble(param.ParameterName);
                        break;

                    case DbType.Byte:
                    case DbType.Int16:
                    case DbType.Int32:
                    case DbType.Int64:
                    case DbType.SByte:
                    case DbType.UInt16:
                    case DbType.UInt32:
                    case DbType.UInt64:
                        param.Value = _sqlrcur.getOutputBindInteger(param.ParameterName);
                        break;

                    case DbType.Object:
                    case DbType.Xml:
                        param.Value = _sqlrcur.getOutputBindString(param.ParameterName);
                        break;
                    }
                }
            }
        }