The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 09:08:24 AM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: What can I do with stored procedures  (Read 4324 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #15 on: June 03, 2008, 02:50:44 PM »

OK. That works IF you adhere to not using direct SQL statements against your database. If you restrict yourself to access to features of the DB via the stored procs ONLY then you are in control of the logic, because you've channelled the access. If you anticipate that you or others will access/modify the data via direct SQL then you've got the same problem where all (entities touching the DB) MUST implement the exact same logic or the DB can become corrupt (or at least outside of integrity guidelines). In this case, triggers help because the logic is unavoidable by anyone touching the database. But, at the expense of complexity, which you aptly point out.

Right, i think we are on the same page. basically, the short version is that i feel triggers are to do things, AGAINST THE WILL of the accessing party.
but when you are controlling the gates with SP access only, then triggers become a bit irrelevant it seems.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #16 on: June 03, 2008, 02:56:46 PM »

...
A secondary reason this is nice is because again, it create a separation of data and logic. PHP=logic, SQL=data (even if its remote data not even in SQL).
...

"even if its remote data not even in SQL"  ??

Are you saying that the 'data' could be something other than sql?  Like, maybe, a code fragment, snippet, or a full-blown procedure?

"Remote" == not necessarily on the same server where the SP's reside?

This is getting cooler by the day.   Grin

I guess I overstated this. SQL (at least MS) can parse XML, allowing you to dump it to a table. Also allows you to output XML. but, to select data, it still needs to be in a table. Reading what I wrote, it does sound like I was saying that you can query remote sources realtime. I didnt mean that, though, technically you can with temp tables.

For some reason I am having a hard time explaining what I mean in this case. I must be low on sugar or something.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #17 on: June 03, 2008, 06:30:43 PM »


I guess I overstated this. SQL (at least MS) can parse XML, allowing you to dump it to a table. Also allows you to output XML. but, to select data, it still needs to be in a table. Reading what I wrote, it does sound like I was saying that you can query remote sources realtime. I didnt mean that, though, technically you can with temp tables.

For some reason I am having a hard time explaining what I mean in this case. I must be low on sugar or something.

The thing is nuts, using a stored procedure and the Amazon API I could implement that exact functionality and it would be relatively trivial.

Code:
select ASIN from amazon where keyword='car seat';

Very doable using UDF and the Amazon API. Likewise what VS said about if there is no scraped content for a keyword in the database then go out and scrape some.

When we are talking UDF then you are only limited by what you can do in a C (C++) program, which is pretty much only restricted by the imagination.

Now the performance of said system, well, it may leave a little to be desired ;-)

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #18 on: June 03, 2008, 07:12:17 PM »

i wasn't intending to imply UDFs and C++, which frankly I think just brings you back to the whole logic vs data conversation. I hate UDFs and vowed to never use them again, until of course I change my mind Wink

I was being retarded about the "select blah from amazon". to do that you would need a UDF. But, What I meant to actually say...

from PHP you could execute an SP, that would automagically grab the amazon XML, save it to a table, and regurgitate it as a selection recordset.
so instead of a bunch of XML parsing at the PHP level, you would just have a call like
mysql_query($dbconn, "CALL getProductName(@asin)");

Thats what I actually meant.

BTW, does mySQL do XML in/out like msSQL?
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #19 on: June 03, 2008, 09:35:22 PM »

BTW, does mySQL do XML in/out like msSQL?

LOL, I know there's a UDF that will give you XML output.

libmyxml or something like that.

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
dink
Expert
****
Offline Offline

Posts: 332


View Profile
« Reply #20 on: June 03, 2008, 11:19:51 PM »

...BTW, does mySQL do XML in/out like msSQL?

I don't know about msSql, but php/mySql does the 'out' part.
http://www.kirupa.com/web/mysql_xml_php.htm

Pretty basic and slanted toward a blog or for flash, but .....

Another basic one
http://articles.techrepublic.com.com/5100-10878_11-5035149.html

Haven't seen (or even looked for) XML into mySql.
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!