Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > Database & Database Programming

Database & Database Programming MySQL, Oracle, SQL, PL/SQL, ABAP, Smart Forms, and other databases and languages. A database is an organized body of related information used in many websites (including CC).

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-2008, 02:05 AM
orjan orjan is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 36
Rep Power: 3
orjan will become famous soon enough
Question writing stored procedure in mysql

Hello there. In order to improve speed of my php code, I would like to rewrite it to an MySQL Stored Procedure, is there anyone who can help med with this? is it even possible to do?

what I want to do is this, written in some kind of pseudocode

Code:
for each post in table x
   select * from table y where y.id=x.yid
   if match not found
       insert into y
   else
       if x.value = y.value
           update y set y.date = now();
       else 
           update y set y.value = x.value
        endif
    endif
endfor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 03-25-2008, 06:46 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 4,514
Last Blog:
Zend: PHP Security Web...
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default Re: writing stored procedure in mysql

Yes, that is possible. It doesn't look like the code in PHP will slow your script down that much though. In my experience (working with DBs and PHP), PHP is always faster to execute conditional statements than using the database to execute these statements.

Here is a guide that will help you write your stored procedure though: MySQL :: MySQL 5.0 Reference Manual :: 18 Stored Procedures and Functions
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-25-2008, 03:26 PM
orjan orjan is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 36
Rep Power: 3
orjan will become famous soon enough
Default Re: writing stored procedure in mysql

yepp, that is the very manual, yes
unfortunately, it doesn't really explain how you really make them work

i guess i would need an sp for dummies or an howto-sp-file about it instead, which describes sp from the user perspective rather from the database perspective.

any suggestions of anything online?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
mysql, stored procedure



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Storing Images in MySQL with PHP Jordan PHP Tutorials 10 06-22-2008 07:02 PM
Tutorial: PHP to MySQL Jordan PHP Tutorials 5 04-22-2008 09:15 AM
MYSQL CheatSheet - A must for MySQL Users reachpradeep Database & Database Programming 1 03-03-2007 03:05 PM
Toad for MySQL Lop Database & Database Programming 0 12-06-2006 11:07 AM
MySQL Resources dirkfirst Database & Database Programming 1 05-25-2006 02:31 AM


All times are GMT -5. The time now is 11:05 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads