Пример #1
0
        internal void ReadResultTuple(ResultTuple tuple, ColumnMetaData[] columnInfos, CubridStatementype stmtType, CubridConnection con)
        {
            tuple.Index = ReadInt();
            tuple.Oid   = ReadOid();

            for (int j = 0; j < columnInfos.Length; j++)
            {
                int    size = ReadInt();
                object val;

                if (size <= 0)
                {
                    val = null;
                }
                else
                {
                    CubridDataType type = CubridDataType.Null;

                    if (stmtType == CubridStatementype.Call ||
                        stmtType == CubridStatementype.Evaluate ||
                        stmtType == CubridStatementype.CallStoredProcedure ||
                        columnInfos[j].Type == CubridDataType.Null)
                    {
                        type = (CubridDataType)ReadByte();
                        size--;
                    }
                    else
                    {
                        type = columnInfos[j].Type;
                    }

                    val = ReadValue(j, type, size, con);
                }

                tuple[j] = val;
                tuple[columnInfos[j].Name] = val;
            }

            Debug.WriteLine(tuple);
        }
Пример #2
0
        private void CheckType(CubridDataType type)
        {
            int collectionType = 0;

            collectionType = ((byte)type) & ((byte)0x60);

            Debug.WriteLine("collectionTypeOrNot = {0}" + collectionType);

            switch (collectionType)
            {
            case 0x00:
                this.type             = type;
                collectionElementType = CubridDataType.Null;
                break;

            case 0x20:
                this.type             = CubridDataType.Set;
                collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                break;

            case 0x40:
                this.type             = CubridDataType.Multiset;
                collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                break;

            case 0x60:
                this.type             = CubridDataType.Sequence;
                collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                break;

            default:
                this.type             = CubridDataType.Null;
                collectionElementType = CubridDataType.Null;
                break;
            }
        }
Пример #3
0
 internal void Bind(int index, CubridDataType type, object value, ParameterDirection mode)
 {
     Bind(index, type, value);
     parameters[index].Mode = mode;
 }
Пример #4
0
 internal void Bind(int index, CubridDataType type, object value)
 {
     parameters[index]       = new CubridParameter();
     parameters[index].Type  = type;
     parameters[index].Value = value;
 }
Пример #5
0
 public int Add(CubridDataType type)
 {
     return(param.Add(new CubridParameter(type)));
 }
Пример #6
0
        private void CheckType(CubridDataType type)
        {
            int collectionType = 0;
            collectionType = ((byte)type) & ((byte)0x60);

            Debug.WriteLine("collectionTypeOrNot = {0}" + collectionType);

            switch (collectionType)
            {
                case 0x00:
                    this.type = type;
                    collectionElementType = CubridDataType.Null;
                    break;
                case 0x20:
                    this.type = CubridDataType.Set;
                    collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                    break;
                case 0x40:
                    this.type = CubridDataType.Multiset;
                    collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                    break;
                case 0x60:
                    this.type = CubridDataType.Sequence;
                    collectionElementType = (CubridDataType)(((byte)type) & ((byte)0x1F));
                    break;
                default:
                    this.type = CubridDataType.Null;
                    collectionElementType = CubridDataType.Null;
                    break;
            }
        }
Пример #7
0
 internal void Bind(int index, CubridDataType type, object value, ParameterDirection mode)
 {
     Bind(index, type, value);
     parameters[index].Mode = mode;
 }
Пример #8
0
 internal void Bind(int index, CubridDataType type, object value)
 {
     parameters[index] = new CubridParameter();
     parameters[index].Type = type;
     parameters[index].Value = value;
 }
Пример #9
0
        internal object ReadValue(int index, CubridDataType type, int size, CubridConnection con)
        {
            switch (type)
            {
            case CubridDataType.Char:
            case CubridDataType.Nchar:
            case CubridDataType.String:
            case CubridDataType.Varnchar:
                return(ReadString(size, Encoding.Default));

            case CubridDataType.Short:
                return(ReadShort());

            case CubridDataType.Int:
                return(ReadInt());

            case CubridDataType.Float:
                return(ReadFloat());

            case CubridDataType.Double:
            case CubridDataType.Monetary:
                return(ReadDouble());

            case CubridDataType.Date:
                return(ReadDate());

            case CubridDataType.Time:
                return(ReadTime());

            case CubridDataType.Timestamp:
                return(ReadDateTime());

            case CubridDataType.Object:
                return(ReadOid());

            case CubridDataType.Bit:
            case CubridDataType.Varbit:
                return(ReadBytes(size));

            case CubridDataType.Set:
            case CubridDataType.Multiset:
            case CubridDataType.Sequence:
                CubridDataType baseType = (CubridDataType)ReadByte();
                int            count    = ReadInt();
                object[]       seq      = new object[count];

                for (int i = 0; i < count; i++)
                {
                    int elesize = ReadInt();
                    if (elesize <= 0)
                    {
                        seq[i] = null;
                    }
                    else
                    {
                        seq[i] = ReadValue(i, baseType, elesize, con);
                    }
                }

                return(seq);

            case CubridDataType.ResultSet:
                int           handle = ReadInt();
                CubridCommand cmd    = new CubridCommand(con, handle);
                return(cmd.GetDataReaderFromStoredProcedure());

            default:
                return(null);    //throw exception ??
            }
        }
Пример #10
0
 internal DbType SqlType2DbType(CubridDataType sqltype)
 {
     return(DbType.AnsiString);
 }
Пример #11
0
 internal DbType SqlType2DbType(CubridDataType sqltype)
 {
     return DbType.AnsiString;
 }
Пример #12
0
        internal object ReadValue(int index, CubridDataType type, int size, CubridConnection con)
        {

            switch (type)
            {
                case CubridDataType.Char:
                case CubridDataType.Nchar:
                case CubridDataType.String:
                case CubridDataType.Varnchar:
                    return ReadString(size, Encoding.Default);

                case CubridDataType.Short:
                    return ReadShort();

                case CubridDataType.Int:
                    return ReadInt();

                case CubridDataType.Float:
                    return ReadFloat();

                case CubridDataType.Double:
                case CubridDataType.Monetary:
                    return ReadDouble();

                case CubridDataType.Date:
                    return ReadDate();

                case CubridDataType.Time:
                    return ReadTime();

                case CubridDataType.Timestamp:
                    return ReadDateTime();

                case CubridDataType.Object:
                    return ReadOid();

                case CubridDataType.Bit:
                case CubridDataType.Varbit:
                    return ReadBytes(size);

                case CubridDataType.Set:
                case CubridDataType.Multiset:
                case CubridDataType.Sequence:
                    CubridDataType baseType = (CubridDataType)ReadByte();
                    int count = ReadInt();
                    object[] seq = new object[count];

                    for (int i = 0; i < count; i++)
                    {
                        int elesize = ReadInt();
                        if(elesize <= 0)
                        {
                            seq[i] = null;
                        }
                        else
                        {
                            seq[i] = ReadValue(i, baseType, elesize, con);
                        }
                    }

                    return seq;

                case CubridDataType.ResultSet:
                    int handle = ReadInt();
                    CubridCommand cmd = new CubridCommand(con, handle);
                    return cmd.GetDataReaderFromStoredProcedure();

                default:
                    return null; //throw exception ??
            }
        }
Пример #13
0
 public int Add(CubridDataType type)
 {
     return param.Add(new CubridParameter(type));
 }
Пример #14
0
 public CubridParameter(CubridDataType type)
 {
     this.type = type;
 }
Пример #15
0
 public CubridParameter(CubridDataType type)
 {
     this.type = type;
 }