22/05/2021 Execute a SQL query and assign output | OutSystems
Community / Forums / Questions
Rank:
Ajithkumar Radhakrishnan 555 20
#823
Execute a SQL query and assign output
Question
Hi All,
Please find the SQL query skeleton used
I have defined the logical database.
Now after executuing this i want to return the spacedetails value assigned in
it. How can I do that?
0 0 on 2019-03-30
pranav pandey Rank: #445
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 1/11
22/05/2021 Execute a SQL query and assign output | OutSystems
Hi Ajithkumar Radhakrishnan,
You are almost done . Just add a select statement at the end of you
query:
Select spacedetails ;
and in the output add a variable of type text.
Give it a try it will do the work.
0 0 on 2019-03-30
Reply
1 reply Hide thread
Rank:
Ajithkumar Radhakrishnan #823
Pranav Pandey wrote:
Hi Ajithkumar Radhakrishnan,
You are almost done . Just add a select statement at the end
of you query:
Select spacedetails ;
and in the output add a variable of type text.
Give it a try it will do the work.
Im getting syntax error in the query. Can u show me sample
0 0 on 2019-03-30
Reply
Post your answer
pranav pandey Rank: #445
Ajithkumar Radhakrishnan, Please find the sample screen shot in the Follow Post
attachment .
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 2/11
22/05/2021 Execute a SQL query and assign output | OutSystems
Create a structure with 1 attribute of type text and use the same
structure in the AdvSql output
Collapse
threads
1.png
Want threaded
replies to
always default
0 0 on 2019-03-30 to collapsed?
Reply Change this
view in the
forum settings.
1 reply Hide thread
Forum
Rank: Settings
Ajithkumar Radhakrishnan #823
Pranav Pandey wrote:
Ajithkumar Radhakrishnan, Please find the sample screen
shot in the attachment .
Create a structure with 1 attribute of type text and use the
same structure in the AdvSql output
I have tried the same getting above error at select line.
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 3/11
22/05/2021 Execute a SQL query and assign output | OutSystems
0 0 on 2019-03-30
Reply
pranav pandey Rank: #445
ok try creating an input parameter and use that .Please see the sample
screen shot.
11.png
0 0 on 2019-03-30
Reply
1 reply Hide thread
Rank:
Ajithkumar Radhakrishnan #823
Pranav Pandey wrote:
ok try creating an input parameter and use that .Please see
the sample screen shot.
No it doesnt help
0 0 on 2019-03-30
Reply
pranav pandey Rank: #445
May be your query is having some error. Have you tested the query ??
What actully you want the get from the query ??
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 4/11
22/05/2021 Execute a SQL query and assign output | OutSystems
0 0 on 2019-03-30
Reply
1 reply Hide thread
Rank:
Ajithkumar Radhakrishnan #823
Pranav Pandey wrote:
May be your query is having some error. Have you tested
the query ??
What actully you want the get from the query ??
Query is running fine. I want to pass the output generated in
that query
0 0 on 2019-03-30
Reply
pranav pandey Rank: #445
Can you send me a sample oml file.
0 0 on 2019-03-30
Reply
Sravan Vanteru Rank: #439
Hi Ajithkumar Radhakrishnan,
Looks like some issue with query, if you can paste that query rather
than taking screenshot. It helps us to provide you the solution.
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 5/11
22/05/2021 Execute a SQL query and assign output | OutSystems
0 0 on 2019-03-31
Reply
1 reply Hide thread
Rank:
Ajithkumar Radhakrishnan #823
Sravan Vanteru wrote:
Hi Ajithkumar Radhakrishnan,
Looks like some issue with query, if you can paste that query
rather than taking screenshot. It helps us to provide you the
solution.
Attached the query below I have executed the query it fine and
working
0 0 on 2019-03-31
Reply
Rank:
Eduardo Jauch
MVP #6
Hi Ajithkumar.
What "exactly" are you trying to achieve?
Are you using the OutSystems database? Or is it an external source,
imported through Integration Studio?
Cheers.
0 0 on 2019-03-31
Reply
1 reply Hide thread
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 6/11
22/05/2021 Execute a SQL query and assign output | OutSystems
Rank:
Ajithkumar Radhakrishnan #823
Eduardo Jauch wrote:
Hi Ajithkumar.
What "exactly" are you trying to achieve?
Are you using the OutSystems database? Or is it an external
source, imported through Integration Studio?
Cheers.
SyntaxEditor Code Snippet
/* %LogicalDatabase%=GetLogicalDatabase({OS_DUAL}) */
declare spacedetails VARCHAR(300);
cursor l_spaces
is
select df.tablespace_name nam,
totalusedspace Used,
(df.totalspace - tu.totalusedspace) free,
df.totalspace Total,
round(100 * ( (df.totalspace - tu.totaluseds
pace)/ df.totalspace)) persfree
from
(select tablespace_name,
round(sum(bytes) / 1048576) TotalSpac
e
from dba_data_files
group by tablespace_name) df,
(select round(sum(bytes)/(1024*1024)) tot
alusedspace, tablespace_name
from dba_segments
group by tablespace_name) tu
where df.tablespace_name = tu.tablespace_
name ;
r_spaces l_spaces%rowtype;
BEGIN
-- TODO: Implementation required for procedure MO
NITOR.checkspaces
for r_spaces in l_spaces
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 7/11
22/05/2021 Execute a SQL query and assign output | OutSystems
loop
--dbms_output.put_line('Inside loop');
if spacedetails is null
then
spacedetails := r_spaces.nam||'-'||r_
spaces.free;
--dbms_output.put_line('Data ' || sp
acedetails);
else
spacedetails := spacedetails||','||r_
spaces.nam||'-'||r_spaces.free;
--dbms_output.put_line('Data ' || sp
acedetails);
end if;
end loop;
--dbms_output.put_line('END ' || spacedetails);
end;
This is what Im doing now I want to assign the spacedetails to an
output param.
0 0 on 2019-03-31
Reply
Rank:
Jorge Martins
MVP #19
Hi Ajithkumar,
Are you trying to run this code from within the SQL tool? You may find
this post an interesting read.
0 0 on 2019-03-31
Reply
2 replies Hide thread
Rank:
Ajithkumar Radhakrishnan #823
Jorge Martins wrote:
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 8/11
22/05/2021 Execute a SQL query and assign output | OutSystems
Hi Ajithkumar,
Are you trying to run this code from within the SQL tool? You
may find this post an interesting read.
Im running this through SQL query in service studio. And the
query is running fine. My only concern is i want to get back the
return of that
0 0 on 2019-04-01
Reply
Rank:
Ajithkumar Radhakrishnan
#823
Jorge Martins wrote:
Hi Ajithkumar,
Are you trying to run this code from within the SQL tool? You
may find this post an interesting read.
I'm not calling any stored procedure. I have written a sql snippet
it has an output and has to be returned.
0 0 on 2019-04-01
Reply
Rank:
Eduardo Jauch
#6
MVP
Hello Ajithkumar,
You can execute multiple statements in SQL tool.
So, you can execute a SELECT after your statement in order to return
whatever you are creating.
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 9/11
22/05/2021 Execute a SQL query and assign output | OutSystems
Cheers.
0 0 on 2019-04-01
Reply
Hans Rank: #354
Create an Entity, e.g. SpaceDetails
In your advanced SQL use an 'insert into { SpaceDetails} (att1, att2)
value (...,...)
The next block in your flow could be an aggregate that will select the
records from the Entity SpaceDetails
0 0 on 2019-04-01
Reply
Hans Rank: #354
you might use dynamic sql when nessary
e.g.
varchar2 myInsertStatement = 'Insert into {SpaceDetails} (a,b,c) values
';
myInsertStatement += '('||spacedetails||','||r_spaces.nam||'-
'||r_spaces.free||');
execute immediate myInsertStatement;
0 0 on 2019-04-01
Reply
Rank:
Eduardo Jauch
MVP #6
Hi Ajithkumar,
And between the suggestions given to you to you to return the result
of your SQL snippet, like do a SELECT or INSERT into an entity, there is
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 10/11
22/05/2021 Execute a SQL query and assign output | OutSystems
any other problem?
Cheers.
0 0 on 2019-04-01
Reply
Post your answer...
OutSystems © - All Rights Reserved
55 Thomson Place
2nd Floor
Boston, MA 02210
Tel: +1 617 837 6840
More office locations
Legal
Terms and conditions
Cookie Policy
https://www.outsystems.com/forums/discussion/46624/execute-a-sql-query-and-assign-output/ 11/11