powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Создание DW с параметрами
6 сообщений из 6, страница 1 из 1
Создание DW с параметрами
    #33543661
Chistyakov Victor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Вопрос следующий. Есть окошко, ему передается SQL запрос и результаты этого запроса выводятся в DW. DW инициализирую следующим образом

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
ls_syntax = inv_BOG.itr_tr.SyntaxFromSQL(ls_query, &
		'Style(Type=Grid)', error_syntaxfromSQL)
If Trim(error_syntaxfromSQL) <> '' then
	MessageBox('Ошибка создания DataWindow','В процессе создания окна произошла ошибка - '+error_syntaxfromSQL)
	return - 1 
end if	
dw_list.Create(ls_syntax, error_syntaxfromSQL)
If Trim(error_syntaxfromSQL) <> '' then
	MessageBox('Ошибка создания DataWindow','В процессе создания окна произошла ошибка - '+error_syntaxfromSQL)
	return - 1 
end if	
Если запрос не содержит параметров то все нормально генерится. Но если там встречается параметр, то синтаксис не создается. Собственно вопрос: как вывести результат выполнения SQL запроса в DW, если запрос содержит параметры.
...
Рейтинг: 0 / 0
Создание DW с параметрами
    #33543723
Mykola
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
1. В ls_query вместо параметров указать сразу их значения.
...
Рейтинг: 0 / 0
Создание DW с параметрами
    #33543963
Chistyakov Victor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Дело в том что неизвестно сколько параметров и какие значени должны быть. В идеале их должен ввести оператор.
Т.е. стандартными средствами никак?
...
Рейтинг: 0 / 0
Создание DW с параметрами
    #33544460
Estets
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Стандартными никак ;))))))

Варианты решения:

1) Присать все процедуры так чтоб не было обязательных параметров, а при вызвае без параметров процедура не ругалась а возвращала ResultSet. Ето сложно, но можно.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
create procedure ap_test 
  @begin_date datetime = null, 
  @end_date datetime = null
AS
if @begin_date is null
  SELECT @begin_date = getdate()
...
2) Получить с сервера параметры процедуры, и создать строку запуска типа

Код: plaintext
"exec ap_test @begin_date = null, @end_date = null"
...
Рейтинг: 0 / 0
Создание DW с параметрами
    #33544577
PridobreY
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Chistyakov VictorЕсли запрос не содержит параметров то все нормально генерится. Но если там встречается параметр, то синтаксис не создается. Собственно вопрос: как вывести результат выполнения SQL запроса в DW, если запрос содержит параметры.

Secrets of Dynamic DataWindows
Undocumented PowerBuilder: As you know you can use SyntaxFromSQL function to generate DataWindow source code based on a SQL SELECT statement.Then you can pass the source code returned by SyntaxFromSQL directly to the Create function to create new datawindow dynamically. On-line helps says that for SyntaxFromSQL argument you can use only a string whose value is a valid SQL SELECT statement. However, in PowerBuilder 6.0 and above you can also use EXEC <procedure name> <parameters>, where you substitute <procedure name> with the actual stored procedure name and <parameters> with the actual parameter values instead of parameter names. For example, you can use NULL as a value for each required parameter. After you have the new datawindow created, you can use the Modify function to correct parameter names in the datawindow SQL.
Link
...
Рейтинг: 0 / 0
Создание DW с параметрами
    #33592619
Gadni
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
I use the following technique:

1) make SQL Select string in which arguments (eg. ":rs_id", ":rdt_start_date") are
replaced with some constant value (eg. " ' ' ", "SYSDATE") which would be
successfully interpreted by the DBMS for which DW is to be created. This way
Select statement won't contain any arguments.
2) use SyntaxFromSQL to create DW syntax for this SQL Select statement
3) parse the generated syntax string and locate "table(" section in it.
4) replace "retrieve=" part of this "table(" section with the original SQL Select
statement (with the arguments).
5) add new tag "arguments=" within the "table(" section, after "retrieve=" part
with description of argument names and types. For the exact syntax you can
investigate some DWs exported to SRD-files.
6) pass the modified syntax string (with replaced SQL Select and added arguments
definitions) to the final Create statement.

Of course these steps require some programming and experiments, but it works in
our commercial products! So programmers, you have a serious material for the long
nights :-)

There are additional issues regarding object naming in dynamically generated
DWs - sometimes header text objects' names don't match the corresponding
column names below them (plus suffix "_t"). This happens with some (not all)
SQL Select statements containing selection of equally named columns more
than 1 times. So additional modification of the names in the syntax string can be
performed in order to clean this mess.

I hope that this gives some light on the topic.

Wish you good luck!

Ivaylo Ivanov
Senior Software Developer
BULGARIA
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Создание DW с параметрами
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]