Written by

Question Pedro Lopes · Aug 31, 2023

SELECT command within CSP

The program below works perfectly when I call it directly from the Terminal, however when I call it from within a CSP it does not work (It does not do the SELECT).

In the USER namespace, the program works both in the Terminal and on the CSP , but in another namespace it only works when called directly in the Terminal.

PropList(class) ;
 k pl S c=0 s class="'"_class_"'"
 K ^PropList s ^PropList=class
 S lista=$SYSTEM.SQL.Execute("SELECT * FROM Projet.GerePageCSP")
 while lista.%Next() {
 S c=c+1,pl(c)=lista.%Get("NomdePage")
 S ^PropList(c)=pl(c)
 }
 Q

________________________ CSP _______________________

<script language=cache method="montaDDList" arguments="">
S STR="<OPTION> ",c=0
&html<document.write('#(STR)#');>
;
D ^PropList("Projet.GerePageCSP") ; <<<-----------
;
S listaPropriedades=$SYSTEM.SQL.Execute("SELECT SequenceNumber,Name FROM ......
 &html<document.write('#(STR)#');>    }
</script>

_____________________________________________________

Can anyone explain to me?

Product version: IRIS 2023.2

Comments

Ashok Kumar T · Aug 31, 2023

You need to call. If it's was declared as method. I tried the below and it works.  

<script language=cache method="montaDDList" arguments="">
    Set listaPropriedades=$SYSTEM.SQL.Execute("SELECT * from Sample.Person")
</script>

	#(..montaDDList())#
0
Pedro Lopes · Sep 4, 2023

Hello Ashok Kumar

I may not have explained the problem correctly.

The program "PropList" works when used directly in the terminal, but when used from the CSP it also works partially, except for the SELECT that is in the program.

Everything works perfectly when I use the same CSP code in the "USER" namespace.

0
Danny Wijnschenk  Sep 4, 2023 to Pedro Lopes

Hi Pedro,
Probably it has something to do with access rights : do you login with csp, else CSP is using the UnknownUser.
Can you check the result of the %Execute() call (listaPropriedades.%SQLCODE and listaPropriedades.%Message will have error values if the SQL could not run properly)

0
Pedro Lopes  Sep 7, 2023 to Danny Wijnschenk

Perfect, that's the problem. Thanks a lot!

0