Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Hi!
The SQLEXEC() Command simply executes a sql command on the server.
There are often many ways of achieving the same result in SQL.
I guess my difficulty in understanding this comes from my unfamiliarity with the
SQLExec() command. It seems to me that I really must pass through this
string "lcSQL" literal values for the variables as opposed to the variables
themselves.
>This is just a matter of opinion both methods should work fine.
>
My reasoning (again, I am a novice and may be over analyzing) is
that once we pass the "lcSQL" it goes on over to some Oracle driver that will
be unaware as to the values of "charvar1" and "charvar2". The solution would
be simple if I was only dealing with characters and numbers and not dates. If it
were just characters, then I could do this:
>It is not that the server is unaware of the values in your variables
as it is.
Run the following commands
with SQLEXEC
a simple test.
h=SQLCON()
SQLEXEC(h,"CREATE TABLE TEST (col1 number, col2 date)")
var1=1
var2=datetime()
SQLEXEC(h,"insert into test values(?var1,?var2)")
var1=2
var2=datetime()
SQLEXEC(h,"insert into test values(?var1,?var2)")
SQLEXEC(h,"select * from test","test")
brow
SQLEXEC(h,"drop table test")
The only advantage to this approach is that the Oracle server does not need to Reparse the SQL statement because
there is an identical statement in it's cache.
As you can see it is aware of the changes to the variables...
>
However, what does Oracle expect as the date delimiter in lcSQL? I know it is
not the brackets below. Or, is all this unnecessary?
charvar1="09120920"
charvar2="20992"
datevar=datetime()
Either use: Easier!
lcSQL="{Call pwadm.PSINSRT(?charvar1,?charvar2,?datevar) }"
OR
charvar1="09120920"
charvar2="20992"
?????
datevar="to_date("+ttoc(datetime())+"?????"
???I can't remember how to do this!
You will need to look up the to_date() function in your oracle documentation!
I hope that helps you understand what I am getting at here.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement