<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On Dec 10, 2007, at 2:07 PM, Mike McGonagle wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br>---------- Forwarded message ----------<br><span class="gmail_quote">From: <b class="gmail_sendername">Mike McGonagle</b> &lt;<a href="mailto:mjmogo@gmail.com">mjmogo@gmail.com</a>&gt;<br>Date: Dec 10, 2007 1:07 PM <br>Subject: Re: [PD] [psql] object hand-holding<br>To: <a href="mailto:jamie@postlude.co.uk">jamie@postlude.co.uk</a><br><br></span><br><br><div><span class="q"><span class="gmail_quote">On 12/10/07, <b class="gmail_sendername"> Jamie Bullock</b> &lt;<a href="mailto:jamie@postlude.co.uk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jamie@postlude.co.uk</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"> Good point! I think Hans' recent suggestion addresses the problem. It<br>also occurs to me that for Postgres at least, we have the PREPARE<br>statement, which addresses the optimisation and injection issues you<br>have raised. Technically [psql] already supports PREPARE except that <br>PREPARE uses the '$' character as its placeholder identifier, and '$1'<br>can't be passed around as a symbol in Pd. I think it might be<br>interesting to use the '?' notation currently under discussion as an <br>interface to PREPARE though.</blockquote><div><br> </div></span><div>One of the things that I have been reading on this is that when you use these 'pre-complied' SQL statements, you need to 'bind' each of the variables with their types to a specific function. (Also, I kind of like the ':' syntax, as it puts a name to the data within the statement.) I also think that we would need to do something like </div><div><br> </div><div>[insert into table (id, name) values (:id, :name) ( &lt;-- sent to the cold inlet</div><div>[bind :id float( &lt;-- sent to hold inlet</div><div>[bind :name symbol( &lt;-- sent to hold inlet </div><div><br> </div><div>[:id 1 ( &lt;-- sent to hold inlet</div><div>[:name john ( &lt;-- sent to hold inlet</div><div>[bang ( &lt;-- sent to hold inlet</div><div><br> </div><div>and then we would be able to put all the data into the database with the expected types. At least SQLite and libdbi use these 'bind' functions to associate the expected datatype with the input data.</div></div></blockquote><br></div><div>(What is the "hold" inlet, by the way?)</div><div><br class="webkit-block-placeholder"></div><div>It would be really nice to be able to have inlets for the sql placeholders, but I couldn't think of a clean way to do it.  We could try the dynamic allocation like you say here, I don't know if I have a specific objection to it, but it could get weird.  Since the SQL inlet has to be cold to support the comma hack, then these dynamic inlets  shouldn't be hot since they are the right of a cold inlet.   But that's not a big deal.</div><div><br class="webkit-block-placeholder"></div><div>Also, I don't know if any objects do this kind of dynamic inlet creation after the object itself has been instantiated.  It might not even be possible.  I figure that you can easily make a subpatch or abstraction around the SQL message generation, then manage the inlets there.  Perhaps not ideal, but it's not difficult to do and follows existing practice.</div><div><br class="webkit-block-placeholder"></div><div>As for the SQL binding, I was thinking it would happen inside of the object, binding the placeholder names to the selectors.  As long as there wasn't any new input on the SQL inlet, then the SQL statement wouldn't need to be recompiled.</div><div><br class="webkit-block-placeholder"></div><div>Another question I just thought of it how to handle returning multiple results from s single query.  If it followed the [textfile] style, then you would have to bang to get each individual result, then keep banging until you get a bang on the status/second outlet, meaning the query was done.  I think this could work.</div><div><br class="webkit-block-placeholder"></div><div>.hc</div><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br style="font-family: Tahoma; "></div><div>----------------------------------------------------------------------------</div><div><br style="font-family: Tahoma; "></div><div>There is no way to peace, peace is the way.       -A.J. Muste</div><br class="Apple-interchange-newline"></span></span> </div><br></body></html>