Script

Hi,

I have some problems with creating a script. I want to access the values on my report. Depending on one of these values, I want to kick off another script. Is this possible? Can someone give me a start with this?

T.i.a.

Johan de Waardt
ABN AMRO Bank


Listserv Archives (BOB member since 2002-06-25)

Hi:

Are the values part of the query results or are they variables on a report?

If they are values in the query results, you can access the Columns class to retrieve the values in the Microcube. There is a sample script on my WEB site called Label Generator. This script reads the contents of a Data Provider and creates labels from the data. You can use the query interrogator section to examine the results of your query.

You then would use the Scripts class to execute the script if necessary.

Robert

Schmidt Interactive Software, Inc.

Hi,

I have some problems with creating a script. I want to access the values on
my report. Depending on one of these values, I want to kick off another script. Is this possible? Can someone give me a start with this?


Listserv Archives (BOB member since 2002-06-25)

I am trying to resolve my problem of looking for the current production dates using scripting. I have the following script, but it is not working…any ideas?

Sub Main

Dim strCon As Long
Dim rsBegin As long
Dim rsEnd as Long
Dim destination(1) as Variant
Dim rsResultBegin as long
Dim rsResultEnd as long
Dim sBegin as String
Dim sEnd as String
Dim doc as BODocument

set doc = Application.Documents.Item(1)

strCon =
SQLOpen(“DSN=report_control;UID=bouser;PWD=bouser;DATABASE=report_variab les”,outputStr,prompt:=3)

qryBegin = “select begin_date from prod_dates where current_date_val = getdate() and region = ‘CE’”
rsBegin = SQLExecQuery(connection,qryBegin) rsResultBegin =
SQLRetrieve(connection:=connection,destination:=destination, columnNames:=1,rowNumbers:=0,maxRows:= 1, maxColumns:=1,fetchFirst:=0)

sBegin = rsResultBegin

Application.Variables.Item(“BeginDate”).Value = sBegin

SQLClose(strCon)

End Sub

Basically, I am trying to get the script to get the value and place it in a string that can be set to a document variable.

Where am I going wrong?

Tim


Tim Heuer
PacifiCare Health Systems
(714) 825-5702 - office
(800) 946-4645 pin 1404017 - pager
heuer_tk@exchange.phs.com


Listserv Archives (BOB member since 2002-06-25)

I don’t know much about BO scripts, but I have a guess. I assume you are using Oracle.

Your query says: " select begin_date from prod_dates where current_date_val = getdate() and region = ‘CE’ ". If you are using an Oracle database, the “getdate()” function just returns SYSDATE, right? So your query is really: " select begin_date from prod_dates where current_date_val = SYSDATE and region = ‘CE’ ".

The problem is, Oracle’s SYSDATE is not only the current date, but the current TIME, too. If I were to query my database right now, SELECT SYSDATE FROM DUAL would display the value “16-JUL-98”. But that’s misleading. It’s really returning the value “July 16, 1998, 3:46:29 PM”. The time portion does not get displayed, though, because my default date display format is ‘dd-MON-yy’. (How do you change the default date display format? I leave that as an exercise for the student.)

Now, suppose you inserted a record into PROD_DATES where CURRENT_DATE_VAL was ‘16-JUL-98’. Because you did not specify a time, this value is really “July 16, 1998, 12:00:00 AM”. This value does not equal the SYSDATE “July 16, 1998, 3:46:29 PM”, so your SELECT does not retrieve any rows!

Could this be the problem with your script?

Try changing your query to say this:

select begin_date from prod_dates where current_date_val = TRUNC( SYSDATE ) and region = ‘CE’

The TRUNC() function will strip off the time portion of SYSDATE; TRUNC( SYSDATE ) will return the value “July 16, 1998, 12:00:00 AM”.


Erich Hurst
IQDC Systems Analyst
Compaq Computer Corporation

I am trying to resolve my problem of looking for the current production dates using scripting. I have the following script, but it is not working…any ideas?


Listserv Archives (BOB member since 2002-06-25)