|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <sqldb.h> //RSqlColumnReadStream, RSqlParamWriteStream |
|
17 #include "SqlStatementImpl.h" //CSqlStatementImpl |
|
18 |
|
19 //////////////////////////////////////////////////////////////////////////////////////////////////// |
|
20 ///////////////////// RSqlColumnReadStream //////////////////////////////////// |
|
21 //////////////////////////////////////////////////////////////////////////////////////////////////// |
|
22 |
|
23 /** |
|
24 Gives access to column data as a read-only stream of characters, |
|
25 |
|
26 The function can only be used for text and binary column types. |
|
27 |
|
28 @param aStmt The RSqlStatement object to which the referred column belongs. |
|
29 @param aColumnIndex The index value identifying the column; this is 0 for the first column. |
|
30 |
|
31 @return KErrNone, the text column data stream has been opened successfully; |
|
32 KErrNoMemory, an out of memory condition occurred; |
|
33 KErrArgument, the column type is neither text nor binary. |
|
34 Note that database specific errors categorised as ESqlDbError, and |
|
35 other system-wide error codes may also be returned. |
|
36 |
|
37 @capability None |
|
38 */ |
|
39 EXPORT_C TInt RSqlColumnReadStream::ColumnText(RSqlStatement& aStmt, TInt aColumnIndex) |
|
40 { |
|
41 SQLUTRACE_PROFILER(this); |
|
42 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aColumnIndex)); |
|
43 |
|
44 TRAPD(err, Attach(aStmt.Impl().ColumnSourceL(aColumnIndex))); |
|
45 return err; |
|
46 } |
|
47 |
|
48 /** |
|
49 Gives access to column data as a read-only stream of bytes. |
|
50 |
|
51 The function can only be used for text and binary column types. |
|
52 |
|
53 @param aStmt The RSqlStatement object to which the referred column belongs. |
|
54 @param aColumnIndex The index value identifying the column; this is 0 for the first column. |
|
55 |
|
56 @return KErrNone, the text column data stream has been opened successfully; |
|
57 KErrNoMemory, an out of memory condition occurred; |
|
58 KErrArgument, the column type is neither text nor binary. |
|
59 Note that database specific errors categorised as ESqlDbError, and |
|
60 other system-wide error codes may also be returned. |
|
61 |
|
62 @capability None |
|
63 */ |
|
64 EXPORT_C TInt RSqlColumnReadStream::ColumnBinary(RSqlStatement& aStmt, TInt aColumnIndex) |
|
65 { |
|
66 SQLUTRACE_PROFILER(this); |
|
67 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aColumnIndex)); |
|
68 |
|
69 TRAPD(err, Attach(aStmt.Impl().ColumnSourceL(aColumnIndex))); |
|
70 return err; |
|
71 } |
|
72 |
|
73 /** |
|
74 Gives access to column data as a read-only stream of characters, |
|
75 |
|
76 The function can only be used for text and binary column types. |
|
77 |
|
78 @param aStmt The RSqlStatement object to which the referred column belongs. |
|
79 @param aColumnIndex The index value identifying the column; this is 0 for the first column. |
|
80 |
|
81 @leave KErrNoMemory, an out of memory condition occurred; |
|
82 KErrArgument, the column type is neither text nor binary. |
|
83 Note that database specific errors categorised as ESqlDbError, and |
|
84 other system-wide error codes may also be returned. |
|
85 |
|
86 @capability None |
|
87 */ |
|
88 EXPORT_C void RSqlColumnReadStream::ColumnTextL(RSqlStatement& aStmt, TInt aColumnIndex) |
|
89 { |
|
90 SQLUTRACE_PROFILER(this); |
|
91 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aColumnIndex)); |
|
92 |
|
93 Attach(aStmt.Impl().ColumnSourceL(aColumnIndex)); |
|
94 } |
|
95 |
|
96 /** |
|
97 Gives access to column data as a read-only stream of bytes. |
|
98 |
|
99 The function can only be used for text and binary column types. |
|
100 |
|
101 @param aStmt The RSqlStatement object to which the referred column belongs. |
|
102 @param aColumnIndex The index value identifying the column; this is 0 for the first column. |
|
103 |
|
104 @leave KErrNoMemory, an out of memory condition occurred; |
|
105 KErrArgument, the column type is neither text nor binary. |
|
106 Note that database specific errors categorised as ESqlDbError, and |
|
107 other system-wide error codes may also be returned. |
|
108 |
|
109 @capability None |
|
110 */ |
|
111 EXPORT_C void RSqlColumnReadStream::ColumnBinaryL(RSqlStatement& aStmt, TInt aColumnIndex) |
|
112 { |
|
113 SQLUTRACE_PROFILER(this); |
|
114 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aColumnIndex)); |
|
115 |
|
116 Attach(aStmt.Impl().ColumnSourceL(aColumnIndex)); |
|
117 } |
|
118 |
|
119 //////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 ///////////////////// RSqlParamWriteStream //////////////////////////////////// |
|
121 //////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 |
|
123 /** |
|
124 Gives access to parameter data as a stream of characters. |
|
125 |
|
126 NB You need to close the stream after the execution of the statement operation for |
|
127 which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()). |
|
128 |
|
129 @param aStmt The RSqlStatement object to which the referred parameter belongs. |
|
130 @param aParameterIndex The index value identifying the parameter; this is 0 for the first parameter. |
|
131 |
|
132 @return KErrNone, the binary parameter data stream has been opened successfully; |
|
133 KErrNoMemory, an out of memory condition occurred. |
|
134 Note that database specific errors categorised as ESqlDbError, and |
|
135 other system-wide error codes may also be returned. |
|
136 |
|
137 @see RSqlStatement::Next() |
|
138 @see RSqlStatement::Exec() |
|
139 |
|
140 @capability None |
|
141 */ |
|
142 EXPORT_C TInt RSqlParamWriteStream::BindText(RSqlStatement& aStmt, TInt aParameterIndex) |
|
143 { |
|
144 SQLUTRACE_PROFILER(this); |
|
145 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aParameterIndex)); |
|
146 |
|
147 TRAPD(err, Attach(aStmt.Impl().ParamSinkL(ESqlSrvStmtTxtParamSink16, aParameterIndex))); |
|
148 return err; |
|
149 } |
|
150 |
|
151 /** |
|
152 Gives access to parameter data as a stream of bytes. |
|
153 |
|
154 NB You need to close the stream after the execution of the statement operation for |
|
155 which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()). |
|
156 |
|
157 @param aStmt The RSqlStatement object to which the referred parameter belongs. |
|
158 @param aParameterIndex The index value identifying the parameter; this is 0 for the first parameter. |
|
159 |
|
160 @return KErrNone, the binary parameter data stream has been opened successfully; |
|
161 KErrNoMemory, an out of memory condition occurred. |
|
162 Note that database specific errors categorised as ESqlDbError, and |
|
163 other system-wide error codes may also be returned. |
|
164 |
|
165 @see RSqlStatement::Next() |
|
166 @see RSqlStatement::Exec() |
|
167 |
|
168 @capability None |
|
169 */ |
|
170 EXPORT_C TInt RSqlParamWriteStream::BindBinary(RSqlStatement& aStmt, TInt aParameterIndex) |
|
171 { |
|
172 SQLUTRACE_PROFILER(this); |
|
173 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aParameterIndex)); |
|
174 |
|
175 TRAPD(err, Attach(aStmt.Impl().ParamSinkL(ESqlSrvStmtBinParamSink, aParameterIndex))); |
|
176 return err; |
|
177 } |
|
178 |
|
179 /** |
|
180 Gives access to parameter data as a stream of characters. |
|
181 |
|
182 NB You need to close the stream after the execution of the statement operation for |
|
183 which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()). |
|
184 |
|
185 @param aStmt The RSqlStatement object to which the referred parameter belongs. |
|
186 @param aParameterIndex The index value identifying the parameter; this is 0 for the first parameter. |
|
187 |
|
188 @leave KErrNoMemory, an out of memory condition occurred. |
|
189 Note that database specific errors categorised as ESqlDbError, and |
|
190 other system-wide error codes may also be returned. |
|
191 |
|
192 @see RSqlStatement::Next() |
|
193 @see RSqlStatement::Exec() |
|
194 |
|
195 @capability None |
|
196 */ |
|
197 EXPORT_C void RSqlParamWriteStream::BindTextL(RSqlStatement& aStmt, TInt aParameterIndex) |
|
198 { |
|
199 SQLUTRACE_PROFILER(this); |
|
200 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aParameterIndex)); |
|
201 |
|
202 Attach(aStmt.Impl().ParamSinkL(ESqlSrvStmtTxtParamSink16, aParameterIndex)); |
|
203 } |
|
204 |
|
205 /** |
|
206 Gives access to parameter data as a stream of bytes. |
|
207 |
|
208 NB You need to close the stream after the execution of the statement operation for |
|
209 which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()). |
|
210 |
|
211 @param aStmt The RSqlStatement object to which the referred parameter belongs. |
|
212 @param aParameterIndex The index value identifying the parameter; this is 0 for the first parameter. |
|
213 |
|
214 @leave KErrNoMemory, an out of memory condition occurred. |
|
215 Note that database specific errors categorised as ESqlDbError, and |
|
216 other system-wide error codes may also be returned. |
|
217 |
|
218 @see RSqlStatement::Next() |
|
219 @see RSqlStatement::Exec() |
|
220 |
|
221 @capability None |
|
222 */ |
|
223 EXPORT_C void RSqlParamWriteStream::BindBinaryL(RSqlStatement& aStmt, TInt aParameterIndex) |
|
224 { |
|
225 SQLUTRACE_PROFILER(this); |
|
226 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KHexIntParam, &aStmt, aParameterIndex)); |
|
227 |
|
228 Attach(aStmt.Impl().ParamSinkL(ESqlSrvStmtBinParamSink, aParameterIndex)); |
|
229 } |
|
230 |