SQL statements embedded into PowerScript code

Share

SQL statements can be embedded directly into PowerScript code, allowing you to include PowerScript variables in any area of the statement ,whereas you can’t include them if using PowerBuilder Database painter.
To work with variables, the SELECT statement accept the INTO clause, that enable assignment of the result to existent variables.
 For example:
SELECT COUNT(*) INTO :il_bools
FROM books;

PowerScript variables can be used in a statement as values in WHERE clause:
WHERE name = :ls_name;

In embedded SQL ,which produce multiple-row result, can be used cursor object for traverse the result. For cursor object was introduced a set of statements including DECLARE, OPEN and FETCH statements.
DECLARE statement it is used to declare variables.
DECLARE cursor_name CURSOR FOR
selected_statement
{USING transaction_object};

OPEN statement it is used to execute selected_statement.
OPEN cursor_name;

FETCH it is needed to step to the first row and then to the subsequent rows.
FETCH cursor_name INTO variable_list;

Same syntax can be used for stored procedures, except OPEN statement which need to be replaced with EXECUTE statement.

After an embedded SQL statements it is executed, is important to check it for failure. For this task PowerBuilder provide SQLCA transaction object with SQLCode property. SQLCode property has various values as 0 for command succeeded, -1 for SQL failed, 100 for no value returned.

Let’s look to an exemple:
DECLARE author_books CURSOR FOR
SELECT *
FROM books
WHERE author = :ls_author
USING SQLCA;
OPEN author_books;

FETCH author_books INTO :ls_author_name, :ls_author_book;
DO WHILE SQLCA.SQLCode = 0
FETCH author_books INTO :ls_author_name, :ls_author_book;
LOOP

CLOSE author_books;

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close