This is the Tcl binding, right?
You could replace the variable by its value using [string map]:
db eval [string map [list USER_ID $user_id ...] $sql_statement]
or more directly:
db eval \
"CREATE TABLE view_report_01 AS ...
WHERE u.id = $user_id
..."
Regards,
Arjen
On 2009-02-27 15:28, Alexey Pechnikov wrote:
> Hello!
>
> Is there way to careate view such as
>
> db eval {
> CREATE TABLE view_report_01 AS
> ?SELECT s.name ?AS service_name,
> ? t_l_r.cost AS cost
> ?FROM work.users ? AS u,
> ? work.user_contracts ?AS u_c,
> ? work.user_services ?AS u_s,
> ? work.services ? AS s,
> ? telephony.telephony_log_rating AS t_l_r,
> ? telephony.telephony_log ?AS t_l
> ?WHERE u.id = $user_id
> ?AND u.id = u_c.user_id
> ?AND u_c.id = u_s.owner_id
> ?AND u_s.service_id = s.id
> ?AND u_s.id = t_l_r.user_service_id
> ?AND t_l_r.log_id = t_l.rowid
> ?AND ($date_from = '' OR julianday(date2iso($date_from)) < t_l.date_start)
> ?AND ($date_to = '' OR (julianday(date2iso($date_to)) + 1) > t_l.date_start)
> }
>
> I have params $user_id, $date_from, $date_to. There are a lot of queries to
> this view and is needed to place params in the view.
>
> Best regards.
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Delft Hydraulics, GeoDelft, the Subsurface and Groundwater unit of TNO and
parts of Rijkswaterstaat have joined forces in a new independent institute for
delta technology, Deltares. Deltares combines knowledge and experience in the
field of water, soil and the subsurface. We provide innovative solutions to
make living in deltas, coastal areas and river basins safe, clean and
sustainable.
DISCLAIMER: This message is intended exclusively for the addressee(s) and may
contain confidential and privileged information. If you are not the intended
recipient please notify the sender immediately and destroy this message.
Unauthorized use, disclosure or copying of this message is strictly prohibited.
The foundation 'Stichting Deltares', which has its seat at Delft, The
Netherlands, Commercial Registration Number 41146461, is not liable in any way
whatsoever for consequences and/or damages resulting from the improper,
incomplete and untimely dispatch, receipt and/or content of this e-mail.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users