Connecting Tech Pros Worldwide Forums | Help | Site Map

running pl/sql from php

Newbie
 
Join Date: Sep 2007
Posts: 1
#1: Sep 21 '07
Hi all,
I am trying to run a pl/sql block from php script.But it generates a warning:
Warning: oci_execute() [function.oci-execute]: ORA-00900: invalid SQL statement in D:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 42

here is my php code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con = oci_pconnect('SCOTT','TIGER');
  3. $sql = "DECLARE"
  4. ."v_Image BLOB;"
  5. ."v_BFile BFILE :=
  6. BFILENAME('LOB_DIR','earthrise_500.jpg');"
  7. ."v_Title VARCHAR2(100);"
  8. ."v_OffSetIn INTEGER := 1;"
  9. ."v_OffSetFrom INTEGER := 1;"
  10. ."BEGIN"
  11. ."INSERT INTO blob_tab (id,blo) VALUES (5,EMPTY_BLOB());"
  12. ."SELECT blo"
  13. ."INTO v_image"
  14. ."FROM blob_tab WHERE id = 5;"
  15. ."DBMS_LOB.OPEN(v_BFile, DBMS_LOB.LOB_READONLY);"
  16. ."DBMS_LOB.OPEN(v_Image, DBMS_LOB.LOB_READWRITE);"
  17. ."DBMS_LOB.LOADFROMFILE(v_Image, v_BFile, DBMS_LOB.GETLENGTH(v_BFile),"
  18. ."v_OffSetIn, v_OffSetFrom);"
  19. ."DBMS_LOB.CLOSE(v_Image);"
  20. ."DBMS_LOB.CLOSE(v_BFile);"
  21. ."END;";
  22. $stid = oci_parse($con,$sql);
  23. if (!oci_execute($stid, OCI_DEFAULT))
  24. {
  25. oci_rollback($con);
  26. die ("Error saving BLOB\n");
  27. }
  28. oci_commit($con);
  29. oci_close($con);
  30. }
  31. }
  32. ?>
  33.  
when i run the pl/sql part, it goes well without showing any warning.
am i missing something?plz help..thanks in advance....

bergy's Avatar
Member
 
Join Date: Mar 2007
Posts: 90
#2: Sep 21 '07

re: running pl/sql from php


It really helps us read your code if you put [ code=php ] ....code.... [ /code ] around your code. You do get a warning, but does the SQL statement actually run anyway on your database anyway? If so just put an @ sign in front of the function causing the warning and you won't see it any more.
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#3: Sep 21 '07

re: running pl/sql from php


Heya, chintito. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Reply