Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: RFC: Placeholder creation for SQL statementsby LanX (Saint) |
on Mar 09, 2018 at 19:20 UTC ( [id://1210590]=note: print w/replies, xml ) | Need Help?? |
> You didn't answer my question about package vars though, which is one of the potential issues with using closures: I read your post 3 times and I couldn't find a question about package vars. neither "our" nor "package" Package vars are actually easier to handle than lexicals, that's why it's not included in the first demo. PadWalker::peek_our and local are all you need. Though I haven't thought it thru yet. > if you don't know that this is what happens, you don't understand that you only have to use lexicals (assuming your code doesn't work with package vars). with "if you" you mean "if one" or "me" ? (English is confusing sometimes) > Also, what would the following do, search for Eily twice or work as intended? Search "Eily" twice is intended, prepare statements are meant to speed up repeated execution, i.e. $username is normally set inside a loop.
You could also use a DBI::do otherwise which prepares and executes in one run. Or one could also provide a prepare which stores the variables at preparation time, if really needed. Again, I didn't have time to think about the best API, because DBI is vast and allows plenty of approaches. > If they work as intended Hmm I think DBI doesn't work like you intend it to > the main issue might be package vars I don't see a difference. > my %vars = (rank => 'Pope', xp => 4); well I could also allow that bound variables are overriden if xexecute gets arguments. (not sure if that's what you mean) $req1->xexecute(username=>'value');
main issueLook my main problem is that I want to inspect into interpolation in a sane way, that's why I inspect the closed over variables inside an anonymous sub and replace them. Like this I don't need to write a SQL parser to find variables in strings. (the same technique can be used for other kind of embedded string DSL languages) This placeholder{"string"} function is analysing the interpolation and
The real problem is to identify the use cases and to find the right names for the methods.
updatebut you are raising good points, thanks! :)
Cheers Rolf
In Section
Meditations
|
|