-2

I am using sys_exec but not able to find the right way to execute in right way, Please Anyone helps me that's better for me. I am using Oracle sql

Following is my code.

CREATE or REPLACE TRIGGER sms_trigger
AFTER INSERT ON student
FOR EACH ROW
ENABLE
DECLARE lclcmd CHAR(255);
 res VARCHAR(255);
 BEGIN

   lclcmd := CONCAT('php C:/xampp/htdocs/sample/sms_send.php','something');
  res := sys_exec(lclcmd);

END;
/
Martin
  • 22,212
  • 11
  • 70
  • 132
ALPHA
  • 15
  • 1
  • 6

1 Answers1

0

You may be simply missing a space between the .php file and the parameter. With your code, the invocation command line would look like this;

php C:/xampp/htdocs/sample/sms_send.phpsomething

I doubt you have a file with that name. Add a space after .php and see what happens:

lclcmd := CONCAT('php C:/xampp/htdocs/sample/sms_send.php ','something');

Do post the error messages you may be receiving.

Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • I am using like this lclcmd := CONCAT('php ','C:/xampp/htdocs/sample/sms_send.php'); – ALPHA Dec 10 '18 at 14:12
  • @ALPHA This is not what your question says. In any event, try specifying the full path to php – Aleks G Dec 10 '18 at 14:13
  • this is the full path to PHP, While executing from windows command prompt line is executing perfectly. – ALPHA Dec 10 '18 at 14:18
  • @ALPHA No, this is not the full path; the full path would be something like `C:\PHP7.1\bin\php.exe` and not just `php` – Aleks G Dec 10 '18 at 14:19
  • here I am running a file. – ALPHA Dec 10 '18 at 14:28
  • @ALPHA No, you are not running a file. You are running php interpreter, passing your file as a parameter. Here's a simple test: open a new command prompt and type `php` followed by Enter - what do you get? – Aleks G Dec 10 '18 at 14:31
  • Nothing the cmd stops there itself. – ALPHA Dec 10 '18 at 14:37
  • Ok, that's a good start. Now what happens if you invoke your command line: `php C:/xampp/htdocs/sample/sms_send.php`? – Aleks G Dec 10 '18 at 14:38
  • File is executing getting output too. – ALPHA Dec 10 '18 at 14:45
  • Then what happens when you try to invoke your sys_exec? With a simple `select sys_exec('php C:/xampp/htdocs/sample/sms_send.php')` in mysql console – Aleks G Dec 10 '18 at 14:55
  • I am not getting but someone said about UTL_HTTP. – ALPHA Dec 12 '18 at 04:16