on 06-02-2014 2:16 PM
Hi Guys,
I am storing my formula's in a table and accessing these formulas in SQL stored procedure, at this point I don't know the number of variables in the formula or computation model of the formula. I want to perform required operations specified in the formula by getting the variable values stored in other table .
I am able to achieve this using xsjs (javascript eval() function) but I wanna implement same thing using SQL script.
-> Is there any function that is equivalent to eval or Ncalc in SQL script??
-> is it possible to call XSJS code in stored procedure ??
-> this kind of an implementation is it possible in SQLscript??
Regards,
Vijay.
Hi,Vijaykumar
Use dynamic sql to "eval"
create procedure TEST.eval()
language sqlscript as
vart nvarchar(10);
begin
vart:='1+3-7';
create table #varc as (select 1 as q from dummy) with no data;
EXECUTE IMMEDIATE 'insert into #varc (select '||:vart||' as q from dummy)';
select * from #varc;
drop table #varc;
end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Buslov,
I tried to create stored procedure ,
Initially I was getting a error to declare "vart" so I defined it as a
declare vart NVARCHAR;
but now it throws the following errors :
Could not execute 'EXECUTE IMMEDIATE 'insert into #varc (select '||:vart||' as q from dummy)'' in 28 ms 641 µs .
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "EXECUTE": line 1 col 1 (at pos 1)
and
Could not execute 'call "_SYS_BIC"."ID.caaA.models/eval"' in 91 ms 218 µs .
SAP DBTech JDBC: [1301]: numeric or value error: [1301] "_SYS_BIC"."ID.caaA.models/eval": line 7 col 2 (at pos 253): [1301] (range 3) numeric or value error exception
I am not familiar with Dynamic SQL, Could you please help me to resolve these errors, and also can you give me the link which explains Dynamic sql in sql script.
Regards,
Vijay.
Vijaykumar, my name - Dmitry;)
You have to use catalog procedure for dynamic SQL, not package(Read only)!
http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf
page 69
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.