Help cursor/procedure

Reply

Join Date: Oct 2009
Posts: 24
Reputation: gpss is an unknown quantity at this point 
Solved Threads: 0
gpss gpss is offline Offline
Newbie Poster

Help cursor/procedure

 
0
  #1
Oct 10th, 2009
Hi! I need a great favor... if someone could help i really appreciate...

heres the deal:

i made one year ago a webpage with a database on isQL*plus (pl/sql) language..

on my webpage i have this (i will show images to you understand better what i mean):
http://img36.imageshack.us/img36/578...rjogadores.jpg

code:
  1. PROCEDURE gerir_jogadores IS
  2. CURSOR c_jogadores IS
  3. SELECT * FROM jogadores, equipas, tipoposic
  4. WHERE joga_equi_id = equi_id AND joga_tipoposic_id = tipoposic_id;
  5. BEGIN
  6. htp.p('<html>');
  7. htp.p('
  8. <body style="background-color: #339F2A;">
  9. <h2>JOGADORES</h2>
  10. <table width="100%" border="1">
  11. <tr>
  12. <th>Nome</th>
  13. <th>Data Nascimento</th>
  14. <th>Local Nascimento</th>
  15. <th>Nacionalidade</th>
  16. <th>Posição</th>
  17. <th>Personalidade</th>
  18. <th>Equipa</th>
  19. <th>&nbsp;</th>
  20. </tr>
  21. ');
  22. -- Cursor para preencher tabela com os resultados da tabela jogadores
  23. FOR r_jogadores IN c_jogadores LOOP
  24. htp.p('<tr>');
  25. htp.p('<td align="center">'||r_jogadores.joga_nome||'</td>');
  26. htp.p('<td align="center">'||to_char(r_jogadores.joga_data_nsc,'dd.mm.yyyy')||'</td>');
  27. htp.p('<td align="center">'||r_jogadores.joga_local_nsc||'</td>');
  28. htp.p('<td align="center">'||r_jogadores.joga_nacionalidade||'</td>');
  29. htp.p('<td align="center">'||r_jogadores.tipoposic_posicao||'</td>');
  30. htp.p('<td align="center">'||r_jogadores.joga_personalidade||'</td>');
  31. htp.p('<td align="center">'||r_jogadores.equi_nome||'</td>');
  32. htp.p('<td align="center"><input type="button" value="Editar" onclick="window.location=''est.form_editar_jogador?p_joga_id='||r_jogadores.joga_id||''';"></td>');
  33. htp.p('</tr>');
  34. END LOOP;
  35. htp.p('<tr><td align="center" colspan="11"><input type="button" value="Criar Novo Jogador" onclick="window.location=''est.form_inserir_jogador'';"></td></tr>');
  36. htp.p('</table>');
  37. htp.p('<br></br><br></br><br></br><p align="center"><input type="button" value="Voltar" onclick="window.location=''est.home'';"></p>');
  38. htp.p('</body></html>');
  39. END;

and when i click on the "Editar" (means edit) button (check the image), i enter on this:

http://img203.imageshack.us/img203/3...tarjogador.jpg

Code:
  1. PROCEDURE form_editar_jogador(p_joga_id IN NUMBER) IS
  2. CURSOR c_jogadores IS
  3. SELECT * FROM jogadores WHERE joga_id = p_joga_id;
  4. CURSOR c_tipoposic IS
  5. SELECT * FROM tipoposic;
  6. r_jogadores c_jogadores%ROWTYPE;
  7. BEGIN
  8. OPEN c_jogadores;
  9. FETCH c_jogadores INTO r_jogadores;
  10. CLOSE c_jogadores;
  11. htp.p('<html>');
  12. htp.p('
  13. <body>
  14. <h2>Alterar/Apagar Jogador </h2>
  15. <form action="est.actualizar_jogador" method="post">
  16. <input type="hidden" name="p_joga_id" value="'||r_jogadores.joga_id||'">
  17. <table>
  18. <tr>
  19. <td>Nome:</td><td><input type="text" size="50" name="p_joga_nome" value="'||r_jogadores.joga_nome||'"></td>
  20. </tr>
  21. <tr>
  22. <td>Data de Nascimento:</td><td><input type="text" size="10" name="p_joga_data_nsc" value="'||to_char(r_jogadores.joga_data_nsc,'dd.mm.yyyy')||'"></td>
  23. </tr>
  24. <tr>
  25. <td>Local de Nascimento:</td><td><input type="text" size="50" name="p_joga_local_nsc" value="'||r_jogadores.joga_local_nsc||'"></td>
  26. </tr>
  27. <tr>
  28. <td>Nacionalidade:</td><td><input type="text" size="50" name="p_joga_nacionalidade" value="'||r_jogadores.joga_nacionalidade||'"></td>
  29. </tr>
  30. ');
  31. htp.p('<tr><td>Posição:</td><td><select name="p_joga_tipoposic_id">');
  32. FOR r_tipoposic IN c_tipoposic LOOP
  33. htp.p('<option value="'||r_tipoposic.tipoposic_id||'"');
  34. IF r_jogadores.joga_tipoposic_id = r_tipoposic.tipoposic_id THEN
  35. htp.p(' selected ');
  36. END IF;
  37. htp.p('>'||r_tipoposic.tipoposic_posicao);
  38. END LOOP;
  39. htp.p('</select></td></tr>');
  40. htp.p('
  41. <tr>
  42. <td>Personalidade:</td><td><input type="text" size="50" name="p_joga_personalidade" value="'||r_jogadores.joga_personalidade||'"></td>
  43. </tr>
  44. <tr>
  45. <td align="center" colspan="2">
  46. <input type="submit" value="Alterar">&nbsp
  47. <input type="button" value="Apagar" onclick="window.location=''est.apagar_jogador?p_joga_id='||r_jogadores.joga_id||''';">&nbsp
  48. <input type="button" value="Voltar" onclick="window.location=''est.gerir_jogadores'';">
  49. </td>
  50. </tr>
  51. </table>
  52. </form>
  53. </body>
  54. </html>
  55. ');
  56. END;

You understand what i'm making? i click on button to edit a player, that i choose from his id...


NOW, my problem is that i'm making a webpage but with a database on postgreSQL (PL/pgSQL) and the page is in PHP, i wanted to make something like that i made on that page...

In short: i want to show a page with my table with my client's name and when i click on the button that is in front of each name, i want to open a new page (sending that client ID), so on the next page i can edit them...


Thanks
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for Oracle
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC