473,411 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

SQL scripts and Result set

Hi!

In my application I'd like to let the user run SQL snippets like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END

Is it possible to get a ResultSet from that?

Best regards,
Kovi

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Jan 26 '06 #1
13 1448
In article <op*****************@news.siol.net>, Gregor Kovac
(gr**********@mikropis.si) says...
Hi!

In my application I'd like to let the user run SQL snippets like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END

Is it possible to get a ResultSet from that?

Best regards,
Kovi


If you mean that you want to know which rows were updated then check
the article at
http://www.databasejournal.com/featu...le.php/3342211

Jan 26 '06 #2
Gert van der Kooij wrote:
In article <op*****************@news.siol.net>, Gregor Kovac
(gr**********@mikropis.si) says...
Hi!

In my application I'd like to let the user run SQL snippets like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END

Is it possible to get a ResultSet from that?

Best regards,
Kovi


If you mean that you want to know which rows were updated then check
the article at
http://www.databasejournal.com/featu...le.php/3342211


Hi!

Yes, interesting. I do know about those data-change-table-reference stuff,
but that does not help me much, since the statement:
SELECT * FROM FINAL TABLE(
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END
)

does not work.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Jan 27 '06 #3
Gregor KovaÄŤ wrote:
Gert van der Kooij wrote:

In article <op*****************@news.siol.net>, Gregor Kovac
(gr**********@mikropis.si) says...
Hi!

In my application I'd like to let the user run SQL snippets like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END

Is it possible to get a ResultSet from that?

Best regards,
Kovi


If you mean that you want to know which rows were updated then check
the article at
http://www.databasejournal.com/featu...le.php/3342211

Hi!

Yes, interesting. I do know about those data-change-table-reference stuff,
but that does not help me much, since the statement:
SELECT * FROM FINAL TABLE(
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = 3;
UPDATE TABLE ....
...
END
)

does not work.

No it doesn't needed to draw a line in the sand somewhere.. :-)
Can you use a stored procedure or an SQL Table function?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 27 '06 #4

Serge Rielau wrote:
Gregor Kovac wrote:
Gert van der Kooij wrote:

In article <op*****************@news.siol.net>, Gregor Kovac
(gr**********@mikropis.si) says...

Hi!

In my application I'd like to let the user run SQL snippets like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X >>> UPDATE TABLE ....
...
END

Is it possible to get a ResultSet from that?

Best regards,
Kovi

If you mean that you want to know which rows were updated then check
the article at
http://www.databasejournal.com/featu...le.php/3342211

Hi!

Yes, interesting. I do know about those data-change-table-reference stuff,
but that does not help me much, since the statement:
SELECT * FROM FINAL TABLE(
BEGIN ATOMIC
DECLARE X BIGINT;

SET X > UPDATE TABLE ....
...
END
)

does not work.

No it doesn't needed to draw a line in the sand somewhere.. :-)
Can you use a stored procedure or an SQL Table function?


NO, sorry. Since this SQL is dynamically made up in my application and
I don't want to create procedures onm the fly.

Best regards,
Kovi

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab


Feb 21 '06 #5
I did not know of this clause (the documentation on the internal
network here is not updated). Thanx for posting it.

B.

Feb 21 '06 #6
Kovi wrote:
>>>In my application I'd like to let the user run SQL snippets like:
>>>BEGIN ATOMIC
>>> DECLARE X BIGINT;
>>>
>>> SET X >>> UPDATE TABLE ....
>>> ...
>>>END
NO, sorry. Since this SQL is dynamically made up in my application and
I don't want to create procedures onm the fly.


What exactly are you doing in the dynamic compound statement? Maybe you can
simply do away with it and use parameter markers or something.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Feb 21 '06 #7
Knut Stolze wrote:
Kovi wrote:
>>>In my application I'd like to let the user run SQL snippets like:
>>>BEGIN ATOMIC
>>> DECLARE X BIGINT;
>>>
>>> SET X >>> UPDATE TABLE ....
>>> ...
>>>END

NO, sorry. Since this SQL is dynamically made up in my application and
I don't want to create procedures onm the fly.


What exactly are you doing in the dynamic compound statement? Maybe you
can simply do away with it and use parameter markers or something.

The query that is in the application looks like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT};
UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = X;
END

The marker {GET_VALUE_FROM_INPUT} gets the accual value that the user enters
in the input form. So these SQL has to be preparsed before it can be send
to the database.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Feb 22 '06 #8
Gregor KovaÄŤ wrote:
Knut Stolze wrote:

Kovi wrote:

>>>In my application I'd like to let the user run SQL snippets like:
>>>BEGIN ATOMIC
>>> DECLARE X BIGINT;
>>>
>>> SET X >>> UPDATE TABLE ....
>>> ...
>>>END

NO, sorry. Since this SQL is dynamically made up in my application and
I don't want to create procedures onm the fly.


What exactly are you doing in the dynamic compound statement? Maybe you
can simply do away with it and use parameter markers or something.


The query that is in the application looks like:
BEGIN ATOMIC
DECLARE X BIGINT;

SET X = SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT};
UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = X;
END

The marker {GET_VALUE_FROM_INPUT} gets the accual value that the user enters
in the input form. So these SQL has to be preparsed before it can be send
to the database.

Best regards,
Kovi

Will this do?
UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 22 '06 #9
Serge Rielau wrote:
UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});


And then the SELECT from the UPDATE wouldn't be an issue anymore...

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Feb 22 '06 #10
Knut Stolze wrote:
Serge Rielau wrote:

UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});

And then the SELECT from the UPDATE wouldn't be an issue anymore...

Oh, he wants to get the id back? No problem!
SELECT id FROM OLD TABLE(UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE
ID = (SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT}));

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 22 '06 #11
Serge Rielau wrote:
Knut Stolze wrote:
Serge Rielau wrote:

UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});

And then the SELECT from the UPDATE wouldn't be an issue anymore...

Oh, he wants to get the id back? No problem!
SELECT id FROM OLD TABLE(UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE
ID = (SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT}));

Cheers
Serge

:) This is all good and OK, but like thid you loose the flexibility of SQL
DECLARE's, SET's and alike that you can use in SQL procedures.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Feb 24 '06 #12
Gregor KovaÄŤ wrote:
Serge Rielau wrote:

Knut Stolze wrote:
Serge Rielau wrote:

UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});
And then the SELECT from the UPDATE wouldn't be an issue anymore...


Oh, he wants to get the id back? No problem!
SELECT id FROM OLD TABLE(UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE
ID = (SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT}));

Cheers
Serge


:) This is all good and OK, but like thid you loose the flexibility of SQL
DECLARE's, SET's and alike that you can use in SQL procedures.

What's it that you want to achieve?
The feature described above is more efficient than procedural logic.
Of course it's not the same and it isn't meant to be.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 24 '06 #13
Serge Rielau wrote:
Gregor Kovač wrote:
Serge Rielau wrote:

Knut Stolze wrote:

Serge Rielau wrote:

> UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE ID = (SELECT
>FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT});
And then the SELECT from the UPDATE wouldn't be an issue anymore...
Oh, he wants to get the id back? No problem!
SELECT id FROM OLD TABLE(UPDATE TABLE2 SET TS = CURRENT TIMESTAMP WHERE
ID = (SELECT FIELD1 FROM TABLE1 WHERE FIELD2 = {GET_VALUE_FROM_INPUT}));

Cheers
Serge


:) This is all good and OK, but like thid you loose the flexibility of
:SQL
DECLARE's, SET's and alike that you can use in SQL procedures.

What's it that you want to achieve?
The feature described above is more efficient than procedural logic.
Of course it's not the same and it isn't meant to be.

Cheers
Serge

What I want to achieve is this:
We have an application that has its input forms stored in a database. We
also have a database replication that is automatic to transfer those input
forms from our development database to our test database, but there is no
automatic replication of functions, stored procedures, database
structure, ...
So it is faster and more "under control" for me to specify a BEGIN ATOMIC
block on that input form than to create a procedure and distribute it on
two, three, ... databases. And this BEGIN ATOMIC block can also be edited
faster than stored procedures, functions, ...
And the most important thing is that in BEGIM ATOMIC block you HAVE the
flexibility of a plain stored procedure, meaning you can use DECLARE, FOR,
WHILE, ...

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Feb 27 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Florian Lindner | last post by:
Hello, I've a scripts that allows limited manipulation of a database to users. This script of course needs to save a password for the database connection. The users, on the other hand need read...
4
by: Florian Lindner | last post by:
Hello, given the following situation: I have a script which is readable and executable by a user, but not writable. The users executes the scripts, it reads in a value and based on this value...
1
by: George van den Driessche | last post by:
Hi folks, I'm looking at packaging a project I'm working on using distutils. The project is for Windows and contains a COM server which needs registration, so the installer needs to be a little...
3
by: Unregistered | last post by:
Hello! I came across two different scripts that I wanted to combine, and I thought I wa successful until I discovered a minor glitch. What was happening was that the page that was linked to...
0
by: PeterB | last post by:
Hi! I want to debug some ASP (VB) scripts on a ASP application I have. I am running a local IIS server on Win XP Professional, and use Visual Studio ..NET as debugger. I'm trying to debug the...
8
by: Leszek | last post by:
Hi. Could you help solve the problem: i have a file that has two includes: //my script <?php include(.'/prog1.php'); include(.'/prog2.php'); ?>
7
by: chakkaradeepcc | last post by:
HI all, How to execute bash scripts from python (other than using os.popen) and get the values that those bash scripts return. I would be happy if someone could help me out in this.. thanks...
3
by: Bob | last post by:
I have created some WSH scripts on my Webserver that are executed by the Windows Task Scheduler. I want to be able to execute some of these scripts using a web interface and don't want to duplicate...
11
by: cwhite | last post by:
i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3 mysql 4.1 and apache 2.0.52, and all of the php scripts i had which called specific entries from mysql are no longer working if...
3
by: Michel Bouwmans | last post by:
Hey everyone, I'm trying to strip all script-blocks from a HTML-file using regex. I tried the following in Python: testfile = open('testfile') testhtml = testfile.read() regex =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.