Lost Password?

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

Vote on your favorite hash algorithm here!

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's Avatar   
orjan orjan is offline
Programmer
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 159
Credits: 187
Rep Power: 6
orjan will become famous soon enoughorjan 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 online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 7,399
Last Blog:
Tramp Variables
Credits: 1
Rep Power: 20
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 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
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
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's Avatar   
orjan orjan is offline
Programmer
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 159
Credits: 187
Rep Power: 6
orjan will become famous soon enoughorjan 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 13 09-23-2008 06:11 PM
Tutorial: PHP to MySQL Jordan PHP Tutorials 9 09-05-2008 12:12 PM
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 09:02 AM.

Contest Stats

Xav ........ 1357.94
MeTh0Dz|Reb0rn ........ 1083.85
WingedPanther ........ 919.18
marwex89 ........ 906.86
morefood2001 ........ 903.18
John ........ 902.37
Brandon W ........ 789.89
chili5 ........ 312.39
Steve.L ........ 264.99
dcs ........ 240.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads