Author |
Message
|
mfractal |
Posted: Mon Apr 07, 2008 2:37 pm Post subject: "Reflection" in ESQL |
|
|
Novice
Joined: 07 Apr 2008 Posts: 14
|
Good time of day to everybody!
I am having a problem ...
And the problem is that I am looking for a way to dynamically invoke ESQL procedures.
The flow is as following :
Inside ESQL i am parsing an XML file that describes a table in the DB. (I am inserting values in that table)
For every field in that DB table there is a NAME OF ESQL FUNCTION that needs to be invoked to get the value to be inserted to that field.
I'll give an example :
Consider the following XML :
Code: |
<Table name="TTIITM001XXX">
<Fields>
<Field IN="T$CTYP" TYPE="CHAR" LENGTH="3" CALL="getProductType" />
<Field IN="T$CSIG" TYPE="CHAR" LENGTH="3" CALL="getBlockedValue" />
<Field IN="T$CUNI" TYPE="CHAR" LENGTH="3" CALL="getMetrics" />
<Field IN="T$CWAR" TYPE="CHAR" LENGTH="3" CALL="getAlCode" />
</Fields>
</Table>
|
Where getProductType/getMetrics/getAlCode are the names of the functions i need to invoke to get the values for the INSERT.
Any ideas ? |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 07, 2008 3:27 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You mean you want to evaluate a dynamic string? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Tue Apr 08, 2008 12:54 am Post subject: Re: "Reflection" in ESQL |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
I think it is not possible in ESQL.
I also think it is not a good idea to send method or function name in your input XML. _________________ Marcin |
|
Back to top |
|
 |
JLRowe |
Posted: Tue Apr 08, 2008 1:20 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
|
Back to top |
|
 |
fschofer |
Posted: Tue Apr 08, 2008 1:41 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
|
Back to top |
|
 |
marcin.kasinski |
Posted: Tue Apr 08, 2008 1:54 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
The EVAL statement takes a character value, interprets it as an SQL statement.
The question was about ESQL . _________________ Marcin |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 08, 2008 1:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
No.
EVAL can run any ESQL statement....
It may be easier to do something like
CALL Procedure {myVar} ...
On the other hand that may not work at all
The real difficulty with this approach is dealing with method signatures. _________________ I am *not* the model of the modern major general.
Last edited by jefflowrey on Tue Apr 08, 2008 1:59 am; edited 1 time in total |
|
Back to top |
|
 |
fschofer |
Posted: Tue Apr 08, 2008 1:58 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Hi,
EVAL can produce ESQL code
Quote: |
If it is a complete ESQL statement, the character string derived from the first stage evaluation is executed as if it were an ESQL statement |
From samples:
Quote: |
EVAL('SET ' || scalarVar1 || ' = 2;'); |
Greetings
Frank |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Tue Apr 08, 2008 2:08 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
JLRowe wrote: |
Do it in java |
... but in JAVA I can't invoke ESQL procedures. _________________ Marcin |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Tue Apr 08, 2008 2:11 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
fschofer wrote: |
Hi,
EVAL can produce ESQL code
Quote: |
If it is a complete ESQL statement, the character string derived from the first stage evaluation is executed as if it were an ESQL statement |
From samples:
Quote: |
EVAL('SET ' || scalarVar1 || ' = 2;'); |
Greetings
Frank |
Sorry, my fault  _________________ Marcin |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 08, 2008 2:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
marcin.kasinski wrote: |
JLRowe wrote: |
Do it in java |
... but in JAVA I can't invoke ESQL procedures. |
This is *very* true. The Java method for running SQL statements only lets you run a single statement. And I am pretty sure it won't let you run EVAL...  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mfractal |
Posted: Tue Apr 08, 2008 5:13 am Post subject: Re: "Reflection" in ESQL |
|
|
Novice
Joined: 07 Apr 2008 Posts: 14
|
marcin.kasinski wrote: |
I think it is not possible in ESQL.
I also think it is not a good idea to send method or function name in your input XML. |
Well, while i generally agree with you, in this case the XML i am talking about is a service description XML, it won't be sent or recieved by anybody, it just sits there on the file system and being red when nessesary.
jefflowrey wrote: |
EVAL can run any ESQL statement....
It may be easier to do something like
CALL Procedure {myVar} ...
On the other hand that may not work at all
The real difficulty with this approach is dealing with method signatures.
|
All my functions are parameterless, so i guess that eliminates one of the issues
Thanks to everybody, i will go and give it a try. I will report back ASAP with the results! |
|
Back to top |
|
 |
mfractal |
Posted: Tue Apr 08, 2008 5:25 am Post subject: Re: "Reflection" in ESQL |
|
|
Novice
Joined: 07 Apr 2008 Posts: 14
|
mfractal wrote: |
Thanks to everybody, i will go and give it a try. I will report back ASAP with the results! |
Works like a charm!
Code: |
EVAL('CALL genereateBaanIDByRules();'); |
Called the procedure, not problems there! |
|
Back to top |
|
 |
|