Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

change stored procedure of dw at runtime

67 views
Skip to first unread message

MH

unread,
Sep 13, 2005, 12:11:05 PM9/13/05
to
I have multiple stored procedures that return the same
result set; therefore, I want to create one datawindow from
a stored procedure and then change to other stored procedure
at runtime.

from PB, I have
datastore lds
lds = create datastore
lds.dataobject = ‘d_common’
this d_common datawindow is created by stored-procedure-1.
at runtime, I want to change the d_common stored-procedure-1
to stored-procedure2.
Is it possible. If so, please show me how
(PB9).
TIA.

Doug Porter

unread,
Sep 13, 2005, 12:20:55 PM9/13/05
to
one way is to use LibraryExport( ) to export to source, change the procedure
name in the source and then use LibraryImport( ) to bring it back in.

Doug Porter
DailyAccess Corporation

<MH> wrote in message news:4326fa05.39a...@sybase.com...

philipsalgannik

unread,
Sep 13, 2005, 1:16:27 PM9/13/05
to
Take the syntax of the one you have at runtime and from that
syntax CREATE new datawindows replacing sqlselect portion
with the calls to the other procs...

brian....@saic.com

unread,
Sep 15, 2005, 3:56:03 AM9/15/05
to
M,

Rather than create the DW from the first SP why not create dynamicaly
at run time. I have cut the following code from something we use but
hopefully I have left enough to give you the idea.

If you have create a datastore object (base_n_ds) and put the following
code into a function of_SetSPName.

ls_FROMSQL = "execute " + as_spname + ";"
ls_SQL = SQLCA.SyntaxFromSQL(ls_FROMSQL, 'Style(Type=Form)',
is_Errtext)

IF Len(is_Errtext) > 0 THEN
lb_status = FALSE
ELSE
// Generate datawindow with the SQL
This.Create(ls_SQL, is_Errtext)

IF Len(is_Errtext) > 0 THEN
lb_status = FALSE
END IF
END IF

IF (lb_status) THEN
//set trans object and test for errors
li_rtn_val = This.of_settransobject ( SQLCA ) // Sets Transaction
Object
IF li_rtn_val <> 1 THEN
is_Errtext = 'ERROR;On Setting TransactionObject for the
Datastore'
lb_status = FALSE
END IF
END IF

IF (lb_status) THEN
// 2. set each column as updateable
li_colcount = Integer(This.Object.DataWindow.Column.Count)
FOR li_col = 1 TO li_colcount
This.Modify(This.Describe( "#"+string(li_Col)+".Name") +
'.Update=Yes')
//ids_data.Modify(lds_TabTo.Describe(
"#"+string(li_Col)+".Name") + '.Key=Yes')
NEXT

//3. set table name and set as updateable and set parameters for
default where
DWObject ldw
ldw = This.Object.DataWindow
ldw.Table.UpdateTable = as_TableName
ldw.Table.UpdateWhere = 0 // key columns only in
where
ldw.Table.UpdateKeyInPlace = 'yes' // key changes treated as
Updates
END IF


Then use above by:

lds_xxx = CREATE base_n_ds
ls_TAB = 'name_of_base_table'
IF NOT lds_xxx.of_SetSPName(ls_INS, ls_TAB) THEN
of_ReportError ( FunctionName, lds_xxx.is_ErrText )
Return Failure
END IF

If you only intend the DW for retrieve you can remove the use of
as_TableName

0 new messages