0

i want to select a random string in oracle TimesTen (in memory database), im EXEC query like this :

select DBMS_RANDOM.string('A', 6) AS "rnd" from dual

but the error code raised :

TT1001: Syntax error in SQL statement before or at: "(" Error at Line: 1 Column: 26

Does anyone know the reason for the problem?

1 Answers1

0

Currently Oracle TimesTen does not support calling PLSQL functions from within a SQL statement.

The best work-around is to create a PLSQL function [or package function] and call that function from PLSQL.

Calling a PLSQL function from a host language like JDBC, ODBC, OCI etc is the same in TimesTen as it is for the Oracle RDBMS.

This example works for TimesTen 11.2.2.8.x and 18.1.x:

create or replace function rand_string return varchar2 is
  str varchar2(255);
Begin
  str := DBMS_RANDOM.string('A', 6);
  Return str;
End;
/

set serveroutput on;

declare
  s1 varchar2(255);

begin
  dbms_output.put_line('Hi');
  s1 := rand_string;
  dbms_output.put_line('Random string is ' || s1);
end;
/

Hi

Random string is MlDYJy