Print Thread
TOracleScript error
#9682 01/17/08 05:01 PM
Joined: Nov 2006
Posts: 44
Ukraine
D
Devil Offline OP
Member
OP Offline
Member
D
Joined: Nov 2006
Posts: 44
Ukraine
Hi, I'm using DOA 4.0.6.1.

TOracleScript.Text has a next value:

Code
    
/*operation_id = 30*/
DEFINE sv_owner = 'scott'
DEFINE sv_table = 'emp'

...

--type_script = before_script
update &sv_owner.&sv_table
   set depno = 10
 where emp_id = 1;
When I execute this script(OracleScript.Execute), get an error: Ora-00942: table or view does not exists, because TOracleScript replace substitution variable &sv_owner deletes together with a point(".").

Query in Oracle Monitor:
Code
  
--type_script = before_script
update scottemp
   set depno = 10
 where emp_id = 1
  
I found a function in which the delete of point(".") is executed together with the put variable:
Code
// Replace substitution variables
function TOracleCommand.ReplaceVariables(S: string): string;
var Vars: TStringList;
    i, p: Integer;
    Value: string;
begin
  Vars := FindVariables(S);
  for i := Vars.Count - 1 downto 0 do
  begin
    Value := OracleScript.GetVariable(Vars[i]);
    p := Integer(Vars.Objects[i]);
    Delete(S, p, Length(Vars[i]) + 1);
      if (Length(S) > p) and (S[p] = '.') then Delete(S, p, 1); //Problem line code: When I comment this line of code, substitute variables is replaced right.
    Insert(Value, S, p);
  end;
  Result := S;
  Vars.Free;
end;
  
When I comment this line of code, substitute variables is replaced right.
Code
 
--type_script = before_script
update scott.temp
   set depno = 10
 where emp_id = 1

  
Help me: Say why in a code the delete of point(".") is executed and how to correct this problem?

Re: TOracleScript error
#9683 01/17/08 05:06 PM
Joined: Nov 2006
Posts: 44
Ukraine
D
Devil Offline OP
Member
OP Offline
Member
D
Joined: Nov 2006
Posts: 44
Ukraine
As a variant of decision of problem - to put a blank before a point, but it is the not best decision:
Code
--type_script = before_script
update &sv_owner   .&sv_table
   set depno = 10
 where emp_id = 1;

Re: TOracleScript error
#9684 01/18/08 04:13 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
This is standard substitution variable behavior, just like in SQL*Plus. The dot terminates the variable name, so you need to use 2 dots:
Code
update &sv_owner..&sv_table
   set depno = 10
 where emp_id = 1;


Marco Kalter
Allround Automations
Re: TOracleScript error
#9685 01/18/08 05:33 PM
Joined: Nov 2006
Posts: 44
Ukraine
D
Devil Offline OP
Member
OP Offline
Member
D
Joined: Nov 2006
Posts: 44
Ukraine
Thanks.
As variant I can use new subst variable &sv_owner_table:
Code
update &sv_owner_table
   set depno = 10
 where emp_id = 1; 


Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.031s Queries: 13 (0.005s) Memory: 2.5109 MB (Peak: 3.0420 MB) Data Comp: Off Server Time: 2024-05-19 11:09:45 UTC
Valid HTML 5 and Valid CSS