question
stringlengths
19
6.88k
answer
stringlengths
38
33.3k
Problem Statement: An ODBC System DSN is configured and connects successfully to a SQL Server database. However when adding that as a linked server in SQLplus, the following error occurs: Linked server from SQLplus: Failed to connect to link MyLink: Login failed for user . The user is not associated with a trusted SQL Server connection How can this be resolved?
Solution: Usually this problem happens when attempting to connect using domain credentials. Instead define both the ODBC DSN itself and the link within SQLplus referring that DSN using credentials for a local SQL Server user that has rights to the database. Keywords: References: None
Problem Statement: Query currently executing in an IQ task is not completing so it is not allowing the remaining scheduled queries in the queue to execute at the scheduled time. There is a need to stop the current query and then have the IQ task continue processing. Sometimes the queue needs to be 'flushed'. This
Solution: shows how to do that.Solution To see what the TSK_IQ# is actually executing, right click on the task record and select Properties, select the external task tab. It will display what is currently executing and what is next in the queue. Normally these will be empty. You can stop the query that is currently executing by making the record unusable. This will not flush the queue however. To flush the queue, please follow the procedure listed below: 1. Use Windows Explorer to determine what drive the AspenTech software resides on. 2. Open a command prompt and type the following: ..> cd %setcimcode% < enter > ..\AspenTech\InfoPlus.21\db21\code> set SETCIM_PROCESS_NAME=TSK_IQ2 < enter > ..\AspenTech\InfoPlus.21\db21\code> plantap < enter > 3. If the C prompt does not return within a couple of minutes, kill the command prompt window. 4. Try again to start TSK_IQ1 from the AspenTech InfoPlus.21 Manager (DO NOT USE TERMINAL SERVICES if the version of the Aspen Infoplus.21 software is v2006 or older.) 5. Check the External Task tab from TSK_IQ#. Currently processing and Next to Process should be empty ! If this doesn't work then go to the AspenTech InfoPlus.21 Manager and double click on TSK_IQ# in the bottom left corner. This shows what the PID is for that task. Then go to Windows Task Manager and end this process. Recommendations: 1. You should create another TSK_IQ#+1 and then move the problem queries to this new task so that all the other queries for the other Tsk_IQ# will execute. 2. You should run the problem queries in the Aspen SQLplus Query Writer and determine what changes need to take place before starting TSK_IQ#+1. Keywords: SQLplus TSK_IQ References: None
Problem Statement: Tags in Aspen InfoPlus.21 can have history stored at different times and frequencies. Even for tags scanned at regular intervals, data compression stores history at irregular intervals. How can you normalize historical time stamps for tags for easy comparison and analysis?
Solution: The Aspen SQLplus HISTORY pseudo table presents Aspen InfoPlus.21 historical data as if it were stored at regular intervals. This sample query illustrates using the HISTORY pseudo table with full joins and without using temporary tables to display historical values as if history was collected at one minute intervals for three tags defined against IP_AnalogDef when a tag defined against IP_DiscreteDef is a particular value . The query produces output similar to: Time Stamp A1113E A1113F ATCAI Machine State -------------------- -------- -------- -------- -------------- 14-OCT-09 12:09:00.0 50.0 10 11.713 2 14-OCT-09 12:10:00.0 50.0 9 12.362 2 14-OCT-09 12:14:00.0 34.0 8 1.291 2 14-OCT-09 12:15:00.0 39.0 7 7.864 2 14-OCT-09 12:20:00.0 41.0 1 0.731 2 14-OCT-09 12:23:00.0 31.0 7 8.551 2 14-OCT-09 12:41:00.0 2.0 2 5.584 2 14-OCT-09 12:48:00.0 6.0 0 4.051 2 14-OCT-09 12:49:00.0 7.0 9 5.657 2 14-OCT-09 12:52:00.0 21.0 10 2.778 2Solution 126973 (Sample query to compare tag values when history timestamps do not line up exactly) shows how to achieve a similar result using CROSS BY and ORDER BY clauses. Keywords: HISTORY pseudo table full join sample query References: None
Problem Statement: When a SELECT query involves the use of the AGGREGATE function, the GROUP BY statement often needs to be added. The result return does not return in the order in which the tag names are specified. In fact, it seems to have perform an ORDER BY in ascending order for the column specified first in the GROUP BY statement. As can be seen from the above screen capture, even though the Aspen SQLplus query has listed the order atcdai, atcai, atcl103, atcl101 and atcl102, however the result return is in ascending order which is atcai, atcdai, atcl101, atcl102 and atcl103.
Solution: This issue can be work around by declaring a TEMPORARY TABLE as can be seen in the screen capture below. Instead of listing out the tag names in the Aspen SQLplus SELECT query, a SELECT query can be used to query from the TEMPORARY table. SELECT a.name, ip_description, max1 FROM MODULE.X AS t LEFT OUTER JOIN (SELECT name, ip_description, MAX(ip_trend_value) AS MAX1 FROM ip_analogdef WHERE name IN (SELECT name FROM MODULE.X) -- Changed to SELECT from TEMPORARY table AND ip_trend_time < CURRENT_TIMESTAMP AND ip_trend_time > (CURRENT_TIMESTAMP - 25920000) GROUP BY name, ip_description) AS a ON t.Name = a.name ORDER BY t.Id; Keywords: AGGREGATE functions GROUP BY References: None
Problem Statement: On the Aspen InfoPlus.21 (IP.21) server, TSK_SQL_SERVER listens on a socket (usually 10014) for any SQLPlus client trying to connect. Once a client connects, TSK_SQL_SERVER spawns a Windows process called SQLplus.exe to service the SQLPlus client. One SQLplus.exe process will be started for each client that connects. Thus, by counting the number of SQLplus.exe processes running in Windows Task Manager, you'll be able to tell how many SQLplus clients are connected to the server. Based on the above, the following question may arise: How to identify the systems/clients who are using the SQLplus interface?
Solution: The following two queries do just that (NOTE: the query assumes your SQLplus service is named like Sqlplus. If your SQLplus service is named differently, you would need to substitute that name into this query): Query 1: select substring(3 of line) as Local Address, substring(4 of line) as Foreign Address from system 'netstat -a | find /i sqlplus' Query 2: For (select substring(3 of line) as Service, substring(4 of line) as IPAddress from system 'netstat -a') do if Service like '%sqlplus%' then write Service||' '||IP Address; end end The output would look like this, with one line item for each user connected. There should always be at least two lines. The first one, with the 0.0.0.0:0, is the Listening service. The 2nd one, with the localhost, is from the computer that just ran this query. All others would be users connected from around your plant. zbigniew:sqlplus 0.0.0.0:0 zbigniew:sqlplus TUMEY.hou.aspentech.com:3544 zbigniew:sqlplus WERT.hou.aspentech.com:2004 zbigniew:sqlplus localhost:1122 Keywords: None References: None
Problem Statement: This
Solution: provides a summary of statements and examples on how to manage permission for a group of records using Aspen SQLplus. For further details about it please consult Adding Record Level Security or Removing Record Level Security topics in Aspen SQLplus Help File. Solution There are three main statements that are needed to manage permission from a SQLplus query: GRANT will set permission over a record, general syntaxes is: GRANT {permission} ON {RecordName} TO {role} REVOKE will remove permission granted over a record, general syntaxes in: REVOKE {permission} ON {RecordName} FROM {role} information_schema.role_table_grants table to consult permission over a record. Permission that can be set are: All, Read, WriteGeneral, WriteRestricted, Delete, ChangeSecurity and Create. Here is a query example on how to use this: --Selecting records to change permissions Select Name from all_records where name like 'atcl10_'; --Grant ALL permission for role Admin to this records GRANT ALL ON (Select Name from all_records where name like 'Record_') TO Admin; --Displaying permission granted Write 'Permission granted:'; SELECT table_name, grantee width 25, privilege_type FROM information_schema.role_table_grants WHERE table_name in (Select Name from all_records where name like 'Record_'); --Removing Write permission REVOKE WriteGeneral, WriteRestricted, WriteSystem ON (Select Name from all_records where name like 'Record_') FROM Admin; --Displaying permission again after revoke action Write 'Permission granted after revoke Writes:'; SELECT table_name, grantee width 25, privilege_type FROM information_schema.role_table_grants WHERE table_name in (Select Name from all_records where name like 'Record_') Note that Admin role name is written using this will work for roles name with space within. Keywords: Security Record permission SQLplus References: None
Problem Statement: How do you modify the database parameters from SQLPlus on a client that does not have the Administrator installed?
Solution: Using the SYSTEM command, run the setdbparam.exe file in the SETCIMCODE directory. There is help available via the command line: C:\Program Files\AspenTech\InfoPlus.21\db21\code>setdbparam ? Usage: setdbparam [-timeoff=<time offset>] setdbparam [-dbsize=<db size>] [-numrecs=<# records>] [-inconly] <time offset> is either in Setcim time offset format or in minutes <db size> is new number of database words <# records> is new number of database records Keywords: dbclock size References: None
Problem Statement: An SQLplus 'System' command executes an Operating System Command such as DIR, or such as execution of an EXE or BAT file - just as if you were executing it at the DOS or Command Prompt. If I am running the SQLplus Query Writer on the same PC as IP.21 is running, and my query contains a System command, then it is obvious that we want that command executed on that same PC, and that is what it will do. Now, suppose I run SQLplus Query Writer on a PC that is Remote to the IP.21, there is a lot of confusion over where that command executes, and what setup is needed for it to run successfully.
Solution: The answers are: 'By default', the 'System' command will execute on, and look for files on, the PC to which you are connected - NOT the remote PC from which you are running Sqlplus Query Writer, When any remote PC is used, the directory MUST HAVE SHARED ACCESS There is a way to over-ride the default Let's try and demonstrate this with 4 different examples :- Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on MYPC, then the following query to execute a .BAT file on MYPC will be successful : System 'Test.Bat'; Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on YOURPC, then the simple query System 'Test.Bat'; will only run if Test.Bat exists on YOURPC, AND, Test.Bat is on YOURPC in a directory that is SHARED Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on YOURPC, If I want to run system commands pointing back to MYPC, I would have to execute something like System '\\MYPC\share\test.bat'; I could also run something like System 'DIR \\MYPC\share'; (where 'share' is a Shared directory on MYPC) Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on MYPC, If I want to run system commands pointing forward to YOURPC, I would have to execute something like System '\\YOURPC\share\test.bat'; Or System ' DIR \\YOURPC\share'; (where 'share' is a Shared directory on YOURPC) Keywords: References: None
Problem Statement: Can I stop and start Aspen InfoPlus.21 tasks using Aspen SQLplus queries?
Solution: This knowledge base article describes how to stop and start Aspen InfoPlus.21 tasks using Aspen SQLplus queries. Aspen InfoPlus.21 is shipped with a command line utility (tsk_client.exe) for managing Aspen InfoPlus.21. This utility is located in Program Files\AspenTech\InfoPlus.21\db21\code. Using this utility in conjunction with the SYSTEM command in Aspen SQLplus, it is possible to stop and start Aspen InfoPlus.21 tasks. It is necessary to include the path to the tsk_client executable. Example: SYSTEM 'd:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /stop_task TSK_IQ1'; Wait 50; SYSTEM 'd:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /start_task_by_name TSK_IQ1'; You may use environment variables in lieu of the full path. Example: SYSTEM '%SETCIMCODE%\tsk_client /stop_task TSK_IQ1'; Wait 50; SYSTEM '%SETCIMCODE%\tsk_client /start_task_by_name TSK_IQ1'; Note: For some Aspen InfoPlus.21 tasks that do not have an external task record, such as TSK_APEX_SERVER you will be prompted to provide a yes or no answer. To remedy this you could create a small text file which includes the yes or no response or use the DOS echo command. Example: Create the file named t.txt containing the letter Y and execute the code below. SYSTEM 'C:\program files\aspentech\infoplus.21\db21\code\tsk_client /stop_task TSK_APEX_SERVER < c:\t.txt' Where t.txt just contains Y. Example: Use the DOS echo command: SYSTEM 'echo Y | c:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /stop_task_by_name TSK_APEX_SERVER'; Or SYSTEM 'echo Y |%SETCIMCODE%\tsk_client /stop_task_by_name TSK_APEX_SERVER'; Keywords: stop task start task References: None
Problem Statement: If an SQLplus client is attempting to connect to an unresponsive or powered down SQLplus server, the client can take a (seemingly) long time to return a no connect error. However, it is possible to minimize the timeout period by adjusting TCP/IP registry settings. The following Tech Tip provides directions on changing one such variable.
Solution: The timeout period for connecting either the Query Writer or Desktop ODBC to an SQLplus server is partially controlled by the registry setting TcpMaxConnectRetransmissions. This parameter specifies the number of times the server will attempt to retransmit a connection acknowledgement before aborting the connection. On a Windows NT 4.0 computer, the default value for TcpMaxConnectRetransmissions is set to 3. The timeout period for each reconnection is doubled, with an initial timeout period of 3 seconds. This gives a total timeout of 45 seconds (3+6+12+24 = 45) for an NT computer. To help decrease the total timeout period, it is possible to change the TcpMaxConnectRetransmissions setting. This will help lower the amount of time the client needs to acknowledge that the SQLplus server is not responding. This variable is set on the SQLplus client, since it is the machine initiating the request. To set this registry key: Open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters on the SQLplus client. Create a DWORD value called TcpMaxConnectRetransmissions Set the value to 1, which will give a total timeout value of about 9 seconds (3+6). Reboot the computer for the parameter to take effect. Note: This timeout is the default for all TCP/IP connections, not just SQLplus. Keywords: tcp/ip timeout References: None
Problem Statement: What Aspen InfoPlus.21 tasks are the ProcedureDef records run on? Are these records run by a single Aspen InfoPlus.21 task?
Solution: The Aspen SQLplus product uses external TSK_IQ tasks (i.e. tasks that start an occurrence of the C:\Program Files\AspenTech\InfoPlus.21\db21\code\iqtask.exe executable) to run queries and procedures. Stored Procedures are always executed on the same task as the query that calls them. For example, if a QueryDef record is on TSK_IQ2 and it calls a stored procedure, the stored procedure will also be executed by TSK_IQ2. So, there is no reason to try to change the EXTERNAL_TASK_RECORD for a stored procedure. SQLplus recognizes that a record is a stored procedure by the fact that its definition record has a record activation code of 4 and an external task record of TSK_IQ1. If you change the External_Task_Record for ProcedureDef it will not be recognized as a stored procedure definition record. Keywords: procedure, task References: None
Problem Statement: How to find an InfoPlus.21 record's folder and the various sequence of parent folders.
Solution: This example will return a string with the name of the record and the folder structure. Function FolderTree(n1 record) local tmp string; tmp = '/' || n1; n1 = (SELECT name FROM Folderdef WHERE record_name = n1); WHILE n1 IS NOT NULL DO tmp = '/' || n1->name || tmp ; n1 = (SELECT FOLDER_PARENT FROM Folderdef WHERE name = n1->name); end; return tmp; end; Save this function as a ProcedureDef record in InfoPlus.21. Call the procedure and pass it the name of the desired record. For example: write FolderTree('atcai'); The output will look similar to this '/RootFolder/Folders/OPC_tags/3down/ATCAI' Keywords: References: None
Problem Statement: Is there a way to use SQLplus, either in the Query Writer Tool or via ODBC, to connect to an Excel spreadsheet while the spreadsheet is open and avoid this error: failed to connect to link....it is already opened exclusively by another user or you need permission to view its data...
Solution: Make the Excel Workbook shared. To do this: 1. Open the workbook in Excel. 2. Selected Tools/Share Workbook... from the menu. 3. Check the Allow changes by more than one user at the same time box. 4. Click OK. SQLplus will them be able to read the spreadsheet even if it is open by someone else. Keywords: References: None
Problem Statement: Can parameters be passed via the IQ or IQNP commands?
Solution: Yes, they are passed just like standard DOS parameters to a *.bat file. See the following example: Create a file C:\temp\query1.sql that contains: select &1, ip_description from &2; Use this command in a DOS box: C:\>C:\Program Files\AspenTech\InfoPlus.21\db21\code\iq.exe C:\temp\query1.sql name atcai returns: name ip_description ATCAI Sine Input Keywords: syntax arguments variables References: None
Problem Statement: Is it possible to subtract a large number of days from a timestamp value?
Solution: You can subtract (or add) values from a timestamp in SQLplus by subtracting the value in 1/10 second intervals. So to subtract 1 day this would be 1*24*60*600 (1 day * 24 hours * 60 minutes * 600 tenths seconds). For example: local dayvalue int; local t1 timestamp; t1 = '01-Mar-14 10:25:30.1'; dayvalue = 35; write (t1 - dayvalue*24*60*600); This works fine until you try and use a value of greater than 2485 days, after which the results are incorrect. This is due to specifying local variable type integer. In SQLplus integer is 4 byte value (32-bit) and can store numbers in the range -2147483648 to 2147483647. A day value of 2486 for the calculation uses 2486 * 24 * 60 * 600 = 2147904000 and this exceeds the integer range. To avoid this problem you can specify the dayvalue as real. Keywords: integer 32-bit 2147483647 References: None
Problem Statement: When executing an SQL script, the following error messages may appear: Invalid TIMESTAMP value YEAR field out of range when converting CHARACTER to TIMESTAMP Invalid timestamp <timestamp>, check format is YYYY-MM-DD HH:MM:SS and numbers are in range All of these error messages indicate a problem with a timestamp setting within the SQL script.
Solution: Check on the version of Aspen SQLplus used. ISO timestamp formats are only supported in v6.0 and above. A query using ISO timestamp being executed on a pre-v6.0, will result in error messages. Ensure that Aspen InfoPlus.21 database and the SQL script are configured with the same time setting. To check the time setting for the Aspen InfoPlus.21 database, 1. Launch Aspen InfoPlus.21 Administrator. 2. Right-click on the nodename. 3. Select Properties from the context menu. 4. Select Time Parameters tab. The Time Parameters tab in the Properties dialog is where the time format setting for Aspen InfoPlus.21 database is configured. In the SQL script, if CAST function is used to cast an expression to timestamp, the date and time format of the expression in the query must match with the date and time format set in the Time Parameters tab in Aspen InfoPlus.21 Administrator. For example, the date format had been set to DD/MM/YY in the Time Parameters tab. CAST('06-Sep-07 2:18:00' AS TIMESTAMP); When the above SQL script is run, the following error message is encountered. Casting a timestamp character value from the format DD-MON-YY HH:MI:SS to another format using CAST FORMAT results in the error message below. The below is an example which will give the error message above. CAST('06-Sep-07 14:18:00' AS TIMESTAMP FORMAT 'MM/DD/YYYY HH:MI:SS' ); There are a few thing to note. 1. The expression given is of the data type CHARACTER. Running CAST('06-Sep-07 14:18:00' AS TIMESTAMP) will just simply convert it from one data type to another. In this case from CHARACTER to TIMESTAMP. 2. The expression is represented in Aspen InfoPlus.21 format and not in ANSI format. Running TIMESTAMP '06-Sep-07 14:18:00' will give the following error message. So it would not be possible to use the following SQL script. CAST(TIMESTAMP '06-Sep-07 14:18:00' AS CHAR FORMAT 'MM/DD/YYYY HH:MI:SS') The YYYY-MM-DD HH:MM:SS format is the representation of timestamp in ANSI format and SQL is regulated by the American National Standards Institute (ANSI) which Aspen SQLplus is based on. In order to CAST FORMAT, the expression need to be CAST into a TIMESTAMP data type first as shown below. CAST(CAST('06-Sep-07 14:18:00' AS TIMESTAMP) AS CHAR FORMAT 'MM/DD/YYYY HH:MI:SS') Keywords: ISO timestamp character cast format References: None
Problem Statement: The EXECUTE and EXEC commands allow you to execute queries on remote nodes. The remote query appears in single quotes following the EXECUTE or EXEC command. If the remote query is long or is complex, it can be difficult to handle in the Aspen SQLplus query writer. This
Solution: describes how to work around this problem.Solution Knowledge base article 138104 describes how to split a long EXECUTE command over several lines. You can also place the command into a text file and read the query from the file as follows: 1) Save the query in a text file, for example C:\Temp\MyQuery.txt 2) Use next SQLplus code: Local QueryLine; QueryLine = (Select LINE from 'C:\Temp\MyQuery.txt'); Execute QueryLine On MyIP21; Replace the file path inside the QueryLine variable for the path to your file. Note, there is still an absolute limit - LINE pseudo column supports up to 4048 characters. Keywords: SQLplus EXECUTE References: None
Problem Statement: An enhancement was requested to add the ability to convert a time interval to 10ths of a second. There were two suggestions for how to do this - one using a new variable type and the other using a function call. Sample of code using a variable type (interval): local ti1 interval; local tix1 integer; local ti2 interval; local tix2 integer; ti1=+000:05:00.0; tix1=ti1; write ti1; write tix1; tix2=100; ti2=tix2; write ti2; write tix2; Output: +000:05:00.0 3000 +000:00:10.0 100 Sample code using functions (itvstr and stritv): local ts char(20); local ti integer; -- interval to string ts=itvstr(100); -- string to interval ti=stritv(+000:05:00.0); write ts; write ti; Output: +000:00:10.0; 3000
Solution: Time intervals in tenths of seconds can be stored in integer variables and formatted as time intervals. The CAST function with the DT12 format can do what the proposed itvstr and stritv functions would do. Sample code using existing capabiltiies: local ts char(20); local ti integer; -- interval to string ts=cast(100 as char using ''dt12''); -- string to interval ti=cast(''+000:05:00.0'' as int using ''dt12''); write ts; write ti; Output: +000:00:10.0 3000 Fixed in Version: The example above will be added to the documentation in v4.1. Keywords: References: None
Problem Statement: Having problems querying Selector Record Text Information from SQLPlus.
Solution: Check the Integers sent as character check box on the Advanced page of the ODBC data source setup. If this box is not checked it causes the select record values to appear as integers. After checking the box, you would need to start a new SQLplus session. In other words, restart the Query Writer (if that is where the query is executed) or restart the iqtask (if it is a record based query). To be 100% certain, reboot the SQLplus server machine. Keywords: selector record sqlplus References: None
Problem Statement: How can you display the ASCII state of a record defined by IP_DiscreteDef when querying the History table?
Solution: Using the syntax HISTORY(n) means that you want to display an n-character field from the history pseudo table instead of a number. For tags defined against IP_DiscreteDef, the character formatting comes from the field IP_VALUE_FORMAT. For example, the query select ts as Trend Time, value as Machine Status right from HISTORY(12) where ts between '10:00:00' and '10:15:00' and period = 00:01:00 and name = 'Machine State'; displays the following results: Trend Time Machine Status -------------------- -------------- 21-MAR-11 10:00:00.0 Broke 21-MAR-11 10:01:00.0 Broke 21-MAR-11 10:02:00.0 Broke 21-MAR-11 10:03:00.0 Broke 21-MAR-11 10:04:00.0 Broke 21-MAR-11 10:05:00.0 Broke 21-MAR-11 10:06:00.0 Broke 21-MAR-11 10:07:00.0 Broke 21-MAR-11 10:08:00.0 Running 21-MAR-11 10:09:00.0 Maintenance 21-MAR-11 10:10:00.0 Maintenance 21-MAR-11 10:11:00.0 Broke 21-MAR-11 10:12:00.0 Down 21-MAR-11 10:13:00.0 Running 21-MAR-11 10:14:00.0 Running Using this syntax allows you to use the tag's ASCII state in searches. For example, the query select ts as Trend Time, a.value as A1113E, b.value as Machine Status right from history a full join history(12) b using (ts, period) where a.name = 'A1113E' and b.name = 'Machine State' and ts between '10:00' and '10:15' and period = 00:01:00 and b.value = 'Maintenance'; displays the following results: Trend Time A1113E Machine Status -------------------- -------------- -------------- 21-MAR-11 10:09:00.0 10 Maintenance 21-MAR-11 10:10:00.0 12.99 Maintenance Keywords: History IP_DiscreteDef Sample query References: None
Problem Statement: What is the meaning of the '80' parameter in SELECT ts, value FROM HISTORY(80) WHERE name='mytextdef';?
Solution: When documenting the use if the HISTORY pseudo-table, the Aspen SQLplus help file says: The history table can also be used to return character data by specifying the maximum column size as a parameter. Example: SELECT ts, value FROM HISTORY(80) WHERE name='mytextdef'; Although the help files indicates that the parameter is the maximum column size; here are some additional details to help clarify the description. Here is a screenshot of the fixed area of a record defined by IP_TextDef: Here is a screenshot of the history repeat area with some sample data: Here is the 'Fields' object for the IP_TextDef definition family. The Fields object shows details about the fields in the defintion (the screenshot shows a partial listing). Note that the three fields holding the text strings in the IP_TextDef records all have a Field Length of 80. That 80 corresponds to the parameter in the sample code. Here is a sample Aspen SQLplus query - note that the 80 parameter affects the results: The 80 is required - observe what happens if you leave it off: If a value of less than 80 is used (60 is used in this example) then an error is returned: The parameter can be made bigger than the column width - it will just make the resulting column wider: Keywords: References: None
Problem Statement: How to query remote databases using Aspen Technology SQLplus product
Solution: A remote database can be queried using SQLplus. I will use as an example, a Setcim database. The remote database has to be set up as a datasource. This can be done by doing the following: 1. Go into Start/Settings/Control Panel/ODBC Data Sources... 2. On the ODBC Data Source Administration dialog box, select the System DSN tab. 3. Click on Add. 4. Select Aspentech SQLplus from the listed choices. 5. Click on the Finish button. You are now at the SQLplus Set Up dialog box. You can now add a link to that remote database in ASpen's SQLplus query tool. 1. Click on the Tables icon. 2. Click Add Link. 3. In the Link Name box, type a name for your link. The link name cannot include a comma (,), and AspenTech recommends that you not include quotation marks (). 4. In the Data Source Name box, you can select an existing ODBC data source or enter a connection string. 5. In the User Name box, type the name of a user account for the database that you want to access. Leave blank if you want to use Windows authentication. 6. In the Password box, type the password for the user account. Leave blank if you're using Windows authentication. Once the link is added, you can create a query by clicking on the link you created and selecting the desired fields of data. Clicking on Paste Query should give you a query something like this: SELECT Name, Value FROM borax.Analogdef_1 Where borax is the name of the remote Setcim machine, and name and value is the data being pulled from the Analogdef_1record in the database. Another example would be: Select t_id from OMAV.OFFSITE.SNAP_DATA Where OMAV.OFFSITE is the name of the remote Oracle database machine, and t_id is the data being pulled from the SNAP_DATA record in the database. Note: If you run these example queries and get the link OMAV not found in SETCIMLINKS or link borax not found in SETCIMLINKS error, then most likely the error message was ultimately caused by the fact that the datasource OMAV or borax was not in the TNSNAMES.ORA file. This is how ORACLE finds the datasources. So it wise to make sure the datasource (ie. OMAV or borax) is configured in the TNSNAMES.ORA file. Keywords: remote query References: None
Problem Statement: You want to retrieve all tags contained in a specific folder in Aspen InfoPlus.21 Administrator with an SQLplus query.
Solution: Use the following query and modify it as needed: SELECT record_name AS Tag Name FROM FolderDef WHERE FolderDef.name LIKE 'your folder name'; Where your folder name is the name of the folder in InfoPlus.21 Administrator that the tags are in. Keywords: Folder Query InfoPlus.21 References: None
Problem Statement: Can you change the port of the SQLpluswebservice?
Solution: You can change the port of the SQLplusWebServce by changing the port number in the line below. DRIVER={AspenTech SQLplus};HOST=hostname;PORT=portxxxxx Located in the Web.Config file located in the C:\inetpub\wwwroot\AspenTech\SQLplusWebService\ You can edit this file with Notepad in Windows. Keywords: SQLplusWebService Port SQLplus References: None
Problem Statement: When a query that has some local variables defined is executed requesting data from a remote database one might receive the following error: SQLplus - Info Remote database error on link xxxxx: [Oracle][ODBC][Ora]ORA-00904: invalid column name at line xx
Solution: This error message usually indicates that Aspen SQLplus sees the local variable as a column in the remote database table. As there will not be any tables with the name of the local variable defined it fails with the error message as shown above. So, If a remote query uses a local variable, the 'LOCAL' keyword prefix must be used. Example: SELECT a FROM r.x WHERE b = local.i For more information on this please refer the section Notes on accessing remote data in SQLplus Help. Keywords: Remote Database error Local References: None
Problem Statement: An SQLplus query would typically be run against a specific InfoPlus.21 database, and either return data from, or write data to, that same InfoPlus.21 database. However, it is possible to run a query against a specific database, but all or part of that query is rerouted to another InfoPlus.21 database. This
Solution: describes how to set that up.Solution Let's imagine that you are running a query against a database running on a system called PROD1, but you want part or all of that query to be rerouted to a database running on a system called AFAR1:- On system PROD1, go to Control Panel => Administrative Tools => Data Sources (ODBC) => SYSTEM DSN => Add. Select the AspenTech SQLplus driver and click Finish. When presented with the Gui, choose some meaningful ODBC Data Source Name that tells you it is related to AFAR1 - e.g. AF1. The Description is up to you. For the Aspen Data Source, click on the down arrow, and select the ADSA entry that points to the AFAR1 system. Test the ODBC connection using the TEST button. Exit the Control Panel and Start => Programs => Aspen Manufacturing Suite => SQLPlus Choose Record => Paste Fields... => Add Link In this Gui, for Link name choose any string of characters you want. You may want to keep it short as this string will be used in your SQLplus query. It can be as short as a single character. Let's imagine we chose a For Data Source Name choose the newly created ODBC Data Source Name (in our example AF1) For Username and Password, it is asking for a domain based account/password that can be used to log into system AFAR1 and see data in the database on AFAR1. From now onwards, if you run a query on PROD1 and want to refer to tables on AFAR1, you just precede the tablename by the Link Name followed by a Period. For example: Select name from a.ip_analogdef This query, although run against the database on PROD1, will return the names of all ip_anaologdef records residing in the Database on AFAR1. Keywords: remote link References: None
Problem Statement: How can I move Aspen Calc calculations into schedule groups using an Aspen SQLplus query?
Solution: In Aspen SQLPlus use the View / Keywords: Aspen Calc Aspen SQLPlus AddScheduledItem DeleteScheduledItem References: s... menu option to add a reference to CalcScheduler: Click the Ok button and copy the following code into the query writer to move all calculations in the folder specified in the variable FolderName into the schedule group named in the variable GroupName. local calccmd, calc, FolderName, GroupName; calccmd = CreateObject('CalcScheduler.CalcCommands'); FolderName = 'Folder1'; --Change folder name as needed GroupName = 'OneMinute'; --Change schedule group name as needed For each Calc in calccmd.GetCalculationList Do If Calc Like '%'||FolderName||'%' Then calccmd.AddScheduledItem(GroupName, Calc); End; End; Setting folder name to blank (FolderName = '';) moves all calculations to the schedule group. Copy the following code into the query writer to delete all calculations in the folder specified in the variable FolderName from the schedule group named in the variable GroupName. local calccmd, calc, FolderName, GroupName; calccmd = CreateObject('CalcScheduler.CalcCommands'); FolderName = 'Folder1'; --Change folder name as needed GroupName = 'OneMinute'; --Change schedule group name as needed For each Calc in calccmd.GetCalculationList Do If Calc Like '%'||FolderName||'%' Then calccmd.DeleteScheduledItem(GroupName, Calc); End; End; Setting folder name to blank (FolderName = '';) deletes all calculations from the schedule group.
Problem Statement: The below error message is encountered in Aspen SQLplus Reporting when running the report interactively.
Solution: By default, the value for the execution timeout for ASP.NET Web Application is 110 seconds in ASP.NET 2.0. This can be viewed in the web.config.comments file in the %systemroot%\Microsoft.NET\Framework\versionNumber\CONFIG. If the ASP.NET Web application is to take longer than 110 seconds to execute, the executionTimeout attribute for the httpRuntime element will need to be set higher. 1. Set the executionTimeout attribute value in the Web.config file in the root of the ASP.NET configuration hierarchy which is in %systemroot%\Microsoft.NET\Framework\versionNumber\CONFIG. 2. Set the executionTimeout attribute value in the Web.config file of the SQLplus Reporting application. Default installation will be C:\Inetpub\wwwroot\AspenTech\SQLplus. Making the change in the Web.config file in the root of the ASP.NET configuration hierarchy will cause the setting to be applied to all ASP.NET applications that run the specific version of .NET Framework. It is recommended to make the change in the Web.config file belonging to the ASP.NET application. In this way, the timeout of the ASP.NET application will override the default value and is only applicable to this particular application. The httpRuntime element accepts a few attributes as shown below or can be seen from the web.config.comments file in the root hierarchy. <httpRuntime executionTimeout = 110 [in Seconds][number] maxRequestLength = 4096 [number] requestLengthDiskThreshold = 80 [number] useFullyQualifiedRedirectUrl = false [true|false] minFreeThreads = 8 [number] minLocalRequestFreeThreads = 4 [number] appRequestQueueLimit = 5000 [number] enableKernelOutputCache = true [true|false] enableVersionHeader = true [true|false] apartmentThreading = false [true|false] requireRootedSaveAsPath = true [true|false] enable = true [true|false] sendCacheControlHeader = true [true|false] shutdownTimeout = 90 [in Seconds][number] delayNotificationTimeout = 5 [in Seconds][number] waitChangeNotification = 0 [number] maxWaitChangeNotification = 0 [number] enableHeaderChecking = true [true|false] /> For example, to increase the executionTimeout to 600 seconds, the following line will need to be added to the Web.config. <httpRuntime executionTimeout=600 maxRequestLength=4096 useFullyQualifiedRedirectUrl=false minFreeThreads=8 minLocalRequestFreeThreads=4 appRequestQueueLimit=100 /> The <configuation> element is the root of the Web.config document. The above line is to be added as a child to the <system.web> element. In this case, it can be added immediately after the <system.web> element. Keywords: SQLplus Reporting Request timed out System.Web.HttpException: Request timed out. References: None
Problem Statement: Is it possible to control the directory where ProcedureDef code is stored?
Solution: Yes - The environment variable COMPRESS_SOURCE points to the folder storing containing source files for ProcedureDef, ViewDef, and CompQueryDef records. By default the code is stored in ...\AspenTech\InfoPlus.21\db21\group200\sql (From V7.2 onwards this folder can reside in different locations. Consult KB article 129813 for more information.) However, you can store the source code in a different directory other than the root directory. To do so, go to Start ==> Settings ==> Control Panel ==> System | Environment or right click on My Computer ==> Properties ==> Advanced tab Click the Environment Variables button. In the system variables list, double click on COMPRESS_SOURCE. In the Variable Value box, type the path of the directory where you want to store the source code for your queries. It is important that these files are backed up on a regular basis, and also copied to new systems during upgrades. NOTE: From V7.1 onward the COMPRESS_SOURCE environment variable is no longer set at installation of the software. If you want to change the path the code will be stored in you will need to create the create the environment variable manually and set the path. Stop InfoPlus.21, restart the InfoPlus.21 task service, and restart InfoPlus.21 to recognize a change. Keywords: compressed compressed_source compress_source ProcedureDef References: None
Problem Statement: Customer creates a text output file from an SQLplus query and then can't find it. Or tries to open a text file and gets a File not found message.
Solution: The key here is to remember that SQLplus runs on the server machine. A customer most often will be working on a client machine. So if they are looking to open or create a file on their C: drive, they may be using code such as: SELECT LINE FROM 'C:\temp\inpfile.txt'; or SET OUTPUT 'C:\temp\report.txt'; However, the C: drive being looked at by SQLplus is the C: drive of the IP.21 Server, not the client. It is possible to retrieve and/or create files from/on the client by using the fully qualified Universal Naming Convention (UNC) path of \\nodename\sharename\dirname\inpfile.txt, where nodename would be the name of the client computer and sharename would be the name of a shared folder on the client computer. So if they are looking to create a file on a client's computer, they may be using code such as: SET OUTPUT '\\Aspen\temp\report.txt'; Note: The sharename is mandatory - you DO need a share on the client that can be accessed by the server and the permissions allowed for this share must be Read and Write depending upon the action being taken. Keywords: set output, text file References: None
Problem Statement: IO_VALUE_RECORD&FLD not recognized by Aspen SQLplus.
Solution: This is because the IO_VALUE_RECORD&FLD field is formatted as a field pointer and the ''&'' is a reserved character. In order to extract information from this field, it needs to be handled differently than other fields in the repeat area of the transfer records. You will need to use double & (i.e. &&) and put the field in double quotes. Sample query: Select IO_VALUE_RECORD&&FLD from IOGETDEF.1; To sort the result, use the ORDER BY syntax. ORDER BY sorts it by the integer value of the record ID. However, to sort by the character value, use the CAST function. ORDER BY CAST(... AS CHAR) For example, if you want to sort your query result for the IO_VALUE_RECORD&FLD field by the character value, just type: Select IO_Tagname, IO_VALUE_RECORD&&FLD from IOGetDef ORDER BY CAST(IO_VALUE_RECORD&&FLD AS CHAR); Keywords: IO_VALUE_RECORD&FLD ORDER BY CAST References: None
Problem Statement: Is it possible to extract field data from a certain occurrence number from tag history?
Solution: Yes it is. The correct syntax to extract the nth occurrence in the history repeat area of a tag is: SELECT ip_trend_value[n], ip_trend_time[n], ip_trend_qstatus[n] FROM IP_AnalogDef WHERE Name='Tag'; Keywords: References: None
Problem Statement: Some third party SQL functions may not be recognized by Aspen SQLPLus. For example if attempting to query an ORACLE data base from Aspen SQLPlus using the to_date command the query will fail with an Unknown Function error.
Solution: The EXECUTE command executes a general statement on a link. The statement does not need to be supported by Aspen SQLplus and can be specific to the particular database type. The EXEC command executes a general statement on a link and returns a result set. Example: EXEC 'SELECT ip_input_value WIDTH 80 FROM d-ip_discrete' ON MyIP21; Keywords: None References: None
Problem Statement: When Report Format under the Report Properties is set to Excel, the email received does not contain the automated report. When the Report Format is set to HTML, there is no such issue.
Solution: This problem is due to Microsoft Excel not being installed on the Aspen SQLplus Reporting server. This can be confirmed by browsing to the folder C:\Documents and Settings\All Users\Application Data\AspenTech\SQLplus\output. In this folder, HTML reports (.htm) can be found but no Excel reports (.xls) will be found. Since Microsoft Excel is not installed on the Aspen SQLplus Reporting server, the Microsoft Excel report is not generated successfully. To resolved this issue, Microsoft Excel needs to be installed on the Aspen SQLplus Reporting server. Keywords: SQLplus Reporting Excel Report Automated Report References: None
Problem Statement: What are the Aspen Cim-IO Store & Forward startup command line arguments and how to use them?
Solution: Aspen Cim-IO Store & Forward provides several command line arguments. Two of these arguments are specified when calling the cimio_sf_start.bat, the others must be hard coded into the bat file. For ease of understanding they are split into 2 headings Named and Unnamed. The command line arguments for each Store & Forward process are: cimio_sf_forward <DLGP service> <Store file path> <Timeout value> <MSGS> cimio_sf_store <DLGP service> <Store file path> <Timeout value> <NOTAGINFO> cimio_sf_scanner <DLGP service> <DEVICE> <Timeout value> <NOTAGINFO> Named: DLGP service This is the TCP/IP service name of the Aspen Cim-IO server's DLGP process. This argument is required for all Store & Forward processes and is the first called argument. Can also be used as Unnamed. Store file path This is the location of the Store file. For this argument, specify the directory path. This argument is optional for the two Store & Forward forward and store processes and is the second argument of the store and forward processes. Can also be used as Unnamed. Unnamed: Timeout value This is the send socket timeout. Specify the timeout value in seconds. This argument is optional for all the Store & Forward processes. If used, it can either be the second or third argument for each of the Store & Forward processes. The default timeout for the Store & Forward processes are: cimio_sf_forward - 5 seconds, cimio_sf_scanner - 3 seconds, cimio_sf_store - 3 seconds. Example setting timeouts to 10 seconds: start /B /MIN cimio_sf_forward %1 %2 10 start /B /MIN cimio_sf_scanner %1 10 start /B /MIN cimio_sf_store %1 %2 10 DEVICE This is used to set a get request's frequency to zero. Because a non-zero frequency must be specifed in a get request when using Store & Forward, this option allows the frequency to be changed to zero before the get request is sent to the Cim-IO server for processing. This argument is optional for the Store & Forward scanner process. To use this feature, specify the word DEVICE as the second argument for the cimio_sf_scanner process: Example: start /B /MIN cimio_sf_scanner CIMIOSIMUL DEVICE MSGS The forward process has an optional argument to enable it to read several messages from a store file instead of reading one message at a time. Originally the forward process would open a store file, read a message, close the store file, and then send the message. With the new option, the forward process can read several messages from a store file and place them in a buffer. When all the messages in the buffer have been sent to the CIM-IO async client, then the forward process will read the next group of messages from the store file. The number of messages read from the store file at one time is configurable. To use this, add the command line argument MSGS followed by a blank space and then a number to the cimio_sf_start file for the forward process. The example shows how to edit the cimio_sf_start.bat file on an NT system to use the messaging option for the forward process. In the example, the forward process has been configured to read 100 messages from the store file at one time. Example: start /B /MIN cimio_sf_forward CIMIOSIMUL MSGS 100 NOTAGINFO Store and Forward has a new option which uses ?dummy? tag names to decrease the size of a CIM-IO message and also decrease the size of a store file. The feature can be enabled in one of two ways. Either by passing the NOTAGINFO argument to the scanner process or to the store process. Do not pass the NOTAGINFO to both processes. The cimio_sf_start file will need to editted to add the NOTAGINFO argument to the appropriate process. Some servers will not work if ?dummy? tag names are sent from the scanner process. In these cases, enable this feature passing the NOTAGINFO argument to the store process. During upgrades, all of the scan and store list files must be removed before starting the Store & Forward processes regardless if the NOTAGINFO is used or not. The examples show how to edit the cimio_sf_start.bat file on an NT system to use the NOTAGINFO option. The first example shows the NOTAGINFO option being passed to the scanner process. The second example the NOTAGINFO option being passed to the store process. If using other Store & Forward options to either the scanner or store process, then pass the NOTAGINO option as the last one. Example #1: start /B /MIN cimio_sf_forward %1 %2 start /B /MIN cimio_sf_scanner %1 NOTAGINFO start /B /MIN cimio_sf_store %1 %2 Example #2: start /B /MIN cimio_sf_forward %1 %2 start /B /MIN cimio_sf_scanner %1 start /B /MIN cimio_sf_store %1 %2 NOTAGINFO Keywords: cimio store and forward notaginfo msgs device timeout References: None
Problem Statement: You can read historical values at specific times using SQLplus using the HISTORY pseudo table, but it returns NULL if there is no data in history newer than the time requested. For example, with data at 12:00 and 13:00, data can be retrieved at 12:30, but no data will be returned at 13:30. Is there any easy method of extrapolating data ?
Solution: In the documentation it mentions that REQUEST is an integer column that is used to specify the type of data returned. REQUEST can take the following values: 1 = TIMES request (evenly spaced data). 3 = FITS request 4 = VALUES request (actual recorded data). The HISTORY table in SQLplus uses the RHIS21DATA call in InfoPlus.21. This originally accepted four values per request. As of v. 3.0 extra values were added to RHIS21DATA and these are usable from SQLplus. However, they are not documented yet. The value of 6 is called H21_GET_TIMES_EXTENDED in the setcim.h include file. An undocumented feature exists. When REQUEST=6, it will extrapolate data beyond the entries in the database This will be documented in the SQLplus Version 4.0 help file. Keywords: HISTORY REQUEST References: None
Problem Statement: It is sometimes necessary to determine via SQLplus which record has a particular record ID, or RECID. RECIDs are used throughout InfoPlus.21 & the associated API calls.
Solution: The easiest way to construct such a query is to draw on the all_records table for the RECID. The all_records table contains a list of all records which exist in the InfoPlus.21 database. Using a query which incorporates this table works because every record in the database has a RECID. Indirection must be used to query the all_records table for a field which does not exist for every record in the database. The following query will return the record name which corresponds to a particular RECID: SELECT * FROM all_records WHERE recid = 1500; The above query returns the following: NAME Io-Abs-Percent Keywords: RECID NAME indirection operator References: None
Problem Statement: If you want to read the lines from a text file that has more than 80 characters on one line, and you use the following Statement Select line from <TEXTFILE> The lines are cut off and only the first 80 characters are shown as output.
Solution: The SELECT statement reads the whole line but visualizes only the first 80 characters. To solve this problem, you will have to include a FOR Statement and change the query into: For (Select line as MyLine from <TEXTFILE>) Do Write MyLine; End; Keywords: textfile select References: None
Problem Statement: Why am I seeing an error message when using SQL+ to REVOKE rights to users or roles in Aspen Framework? The error message states: REVOKE failed: Invalid role name encountered at line 2
Solution: This error is reported because it is only possible to REVOKE security on a record that has it applied. To circumvent this issue either ensure the record/role is valid or GRANT rights first. Keywords: REVOKE Invalid role name References: None
Problem Statement: How can a query check if a value exists in history before inserting a value into history?
Solution: Use the function NOT EXITS to check if a select statement does not return anything as in the following example: if not exists (select ip_trend_time from ATCAI where ip_trend_time = '30-AUG-12 09:00:00') then insert into ATCAI (ip_trend_time, ip_trend_value) values ('30-AUG-12 09:00:00', 23.0); else update ATCAI set ip_trend_value = 23.0 where ip_trend_time = '30-AUG-12 09:00:00'; end Keywords: exists insert References: None
Problem Statement: When using exported models in Aspen Plus or HYSYS, some scripts are invoked automatically. Are there any templates of such scripts available?
Solution: Here is a template Presolve script that users may find useful: IfSolutionMode = then ' Running in ACM - set values for testing script ' Provide values for inlet conditions here for testing the script within ACM. These ' values are assigned automatically when in Aspen Plus End If ' Initialize values if: ' A+ EO mode & previously failed to converge ' or A+ SM mode or HYSYS, and not previously solved ' or running manually in ACM If (SolutionMode = Sequential Modular and SMStatus <> Converged) _ or (SolutionMode = Equation Oriented and EOStatus = Not converged)_ or (SolutionMode = ) Then DisableIncrementalUpdate ' Include initialization code here EnableIncrementalUpdate End If Keywords: References: None
Problem Statement: How to evaluate the inverse of a matrix with ACM?
Solution: ACM supports arrays, but has no predefined operators for classic operations with matrices. The following model shows how the inverse can be evaluated. model inv ns as integerset ([1:2]); // matrix dimension a(ns,ns) as realvariable (FIXED); b(ns,ns) as realvariable; // b = inv(a) for i in ns do for j in ns do if i==j then SIGMA(a(i,ns)*b(ns,j)) = 1; else SIGMA(a(i,ns)*b(ns,j)) = 0; endif endfor endfor end Keywords: References: None
Problem Statement: Fields that are formatted by selector records sometimes need to be moved to variables during processing in an SqlPlus script. When this happens, the value becomes an ordinary integer and stops displaying its corresponding value from the selector record. When it is time to write output from the script, there needs to be a way to format the integer with the selector record. A query against the selector record returns the value of SELECT_DESCRIPTION for each occurrence but nothing to indicate the integer value that maps to the text.
Solution: The easiest way to format an integer value with a selector record is to use CAST...USING. For example: write cast(2 as char using 'eng-units'); And using a variable: local eng int; eng=2; write cast(eng as char using 'eng-units'); Keywords: status level References: None
Problem Statement: While Aspen InfoPlus.21 allows 256-character tag names, Aspen SQLplus, by default, displays only the first 24 characters when selecting record names longer than 24 characters.A How can I display record names longer than 24 characters?
Solution: Use the command A A A A A A A A A A A SET Default_Record = nn; at the beginning of the query where nn is the maximum number of characters needed for your query to display record names.A Since there is not a way to change the default maximum from 24, you must execute this SET command each time you run your query. Keywords: tag name long record name select name References: None
Problem Statement: Each time the SQLplus query writer is opened, a host must be specified. A default data source is not retained.
Solution: Host information is stored in the sqlplus.ini file (located in the C:\WINNT folder). If default host information is not retained, SQLplus may be unable to access this file. The file may have been secured or set to read only. If the sqlplus.ini file is not in the default location, security may be set on the C:\WINNT folder. Keywords: server References: None
Problem Statement: This
Solution: is to assist customers who are experiencing the Connection is busy with results for another hstmt error when querying a Microsoft SQL Server Database using AspenTech SQLPlus. Solution Specific issues may arise when utilizing AspenTech SQLPlus to query a Microsoft SQL Server database. These relate to the method in which SQL Server responds to the SQLPlus queries. Essentially SQLPlus will work through each query statement as it goes through the script and send them to the required database, in this case SQL Server. Unfortunately there is an already known issue with the method in which the ODBC driver and SQL Server database handle the statements, and the inability to respond to the initial query in time before receiving the next query. This issue has already been raised previously underSolution number 121581: KB 121581: How can I work around the error, Connection is busy with results for another hstmt? To workaround this problem it is also possible to change the property of the Multiple Active Result Sets (MARS) value to Yes for the ODBC link to the MSSQL Server. This is available in SQL Server 2005, not 2000 unfortunately. It is also necessary to add a registry key to the registry as follows: \HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\[YOUR_LINK_NAME] Value_name: MARS_Connection Value_data: Yes Please ensure you backup your registry before making any changes and are sure you know how to manipulate the registry prior to performing this task as you may damage your existing system doing so. Keywords: None References: None
Problem Statement: UNIX can express a time format using an integer value (for example, 1153490513). This format is not allowed in InfoPlus.21. Is it possible to convert UNIX integer timestamps into InfoPlus.21 timestamps?
Solution: Save the following function as a ProcedureDef. Function CUNIXDate(temp integer, UTC) local i VarDate; local x double; local t1 timestamp; local t2 char(32); x = temp / 86400.0 + 25569.0; i = trunc(x * 24)/24.0; t1 = cast(i as timestamp)+(x-cast(i as real))*24:00; if UTC then t2 = REPLACE( 'v' WITH 'T' IN cast(t1 as char format 'YYYY-MM-DDvHH:MI:SS.TZ')); else t2 = t1; end; return cast(t2 as timestamp); End; write cast(CUNIXDate(1153490513, TRUE ) as char using 'ts22'); write cast(CUNIXDate(1153490513, FALSE ) as char using 'ts22'); The function, CUNIXDate, can be called in SELECT or INSERT statements in other scripts. The UTC parameter indicates if the integer timestamp is in local time or UTC time. If the second parameter is set to 'TRUE' the result timestamp is converted into local time. Keywords: time time stamp unix convert conversion References: None
Problem Statement: Oracle columns of data type char will only allow strings to be assigned which have the exact length. Aspen SQLplus (SQLplus) trims strings off leading and trailing spaces. Therefore, even if the SQLplus variable is defined to be the same length as the Oracle column, the two may not be equal.
Solution: The reSolution is to change the Oracle column type to be VARCHAR or VARCHAR2, 'or' use the PAD function when making assignments. For example Update oracle.batchlog set batch=PAD(local.batch to 20); Keywords: References: None
Problem Statement: Aspen SQLplus has the ability to use a 'SYSTEM' command. SYSTEM commands a user to pass something that can execute at a DOS/CMD into an SQLplus Query. Such a command might be just as simple as: SYSTEM 'dir' This article discusses the fact that the XCOPY command may have problems when executed from within a SYSTEM command in an Aspen SQLplus query. This problem would be encountered whether the query is executed from an Aspen InfoPlus21 record 'or' from the Aspen SQLplus query writer. The symptom would be that the copies would not be done, yet there were not any error messages.
Solution: The XCOPY routine, when used in a query, needs to be passed as Standard Input. However this input could be null Therefore the following simple example shows the reSolution .. Change system 'xcopy D:\arcs\*.txt %TEMP%' To system 'xcopy D:\arcs\*.txt %TEMP% < nul ' Keywords: None References: None
Problem Statement: When using variable in the WHERE condition of a SELECT query to a remote table, error is encountered. Below is the error message encountered when querying Batch.21 database on Microsoft SQL Server. Below is the error message encountered when querying a database on MySQL database system. As can be seen above, the error message will differ depending on the database system the remote table is on and the ODBC driver used to connect to the database.
Solution: The query to the remote table need to be rewritten such that the variable is concatenated to the SQL query to be executed on the remote table. It will need to be executed using either the EXEC or EXECUTE command. For example, the following SQL query will result in error. DECLARE LOCAL TEMPORARY TABLE MODULE.BatchID(batch_id INT); INSERT INTO MODULE.BatchId SELECT DISTINCT batch_id FROM B21.AspenBatch.dbo.char_batch_data; FOR (SELECT batch_id id FROM MODULE.BatchId WHERE batch_id >= 5064) DO SELECT batch_id, char_id, char_inst, char_time, char_value, subbatch_id FROM B21.AspenBatch.dbo.char_batch_data WHERE batch_id = id; END DISCONNECT B21; However, when it is rewritten to the following, it can be executed without any error. DECLARE LOCAL TEMPORARY TABLE MODULE.BatchID(batch_id INT); LOCAL tmpStr CHAR(150); INSERT INTO MODULE.BatchId SELECT DISTINCT batch_id FROM B21.AspenBatch.dbo.char_batch_data; FOR (SELECT batch_id id FROM MODULE.BatchId WHERE batch_id >= 5064) DO tmpStr = 'SELECT batch_id, char_id, char_inst, ' || 'char_time, char_value, subbatch_id' || 'FROM AspenBatch.dbo.char_batch_data' || 'WHERE batch_id = ' || id; EXEC tmpStr ON B21; END DISCONNECT B21; Another way is to use MACRO. However this will require 2 separate SQL scripts to written with one calling upon the other using START command. Query 1: DECLARE LOCAL TEMPORARY TABLE MODULE.TEMP(tt TIMESTAMP, tv INT); INSERT INTO MODULE.TEMP SELECT TrendTime t, TrendValue v FROM MySQL.ProcessData.Tag1Data WHERE Trendvalue > 8; SELECT * FROM MODULE.TEMP; FOR (SELECT tv n FROM MODULE.TEMP) DO START 'C:\query2.sql', n; END DISCONNECT MySQL; Query 2: SELECT TrendTime t, TrendValue v FROM MySQL.ProcessData.Tag1Data WHERE Trendvalue = &1; DISCONNECT MySQL; Keywords: SQLplus remote table Invalid column name Unknown column References: None
Problem Statement: Aspen SQLplus reporting provides functionality to create reports which can be sent automatically by email to a recipient list. However, if you're not using Aspen SQLplus Reporting, it is possible to include the result of a query as part of an email by creating HTML code as result of the query and include it as part of the message body. This
Solution: provides example code on how to do this as well as a simple query which can be as template for more complex reports. This example uses the code onSolution 132567 to send email. Solution Pure HTML code for emails can be created on SQLplus by simple writing it as part of a variable which will hold the HTML body message for an email, for example: local htmlMessage; htmlMessage = '<html><head></head><body>' || CHR(10); --Message code here, htmlMessage = htmlMessage || '</body></html>'; The body of the message can actually include HTML code like: htmlMessage = htmlMessage || '<H3>Custom SQLplus Report</H3>' || CHR(10); htmlMessage = htmlMessage || '<P> <B>This is custom SQLplus report!</B>' || CHR(10); htmlMessage = htmlMessage || '<P> Created on pure HTML code' || CHR(10); htmlMessage = htmlMessage || '<BR> <B><I>(Adapt this to your need)</I></B>' || CHR(10); htmlMessage = htmlMessage || '<BR>' || CHR(10); It is possible to include the result of SQLquery SELECT statement using code like: For (Select Name, IP_Description from IP_AnalogDef where Name like 'ATCL%') Do htmlTable = htmlTable || '<tr>' || CHR(10); htmlTable = htmlTable || '<td>' || Name || '</td>' || CHR(10); htmlTable = htmlTable || '<td>' || IP_Description || '</td>' || CHR(10); htmlTable = htmlTable || '</tr>' || CHR(10); End Here each of the query row are used as part of a <tr><td>''</td></tr> element of HTML code. A complete simple query to send an email message as HTML can be used like: local msg, FSO, Fldr, File, RecentFile; local SMTPServer, Sender, Recipient, Subject, message, htmlMessage, htmlTable; Keywords: None References: None
Problem Statement: Can you clarify what HYSYS 3.2 users need to install to use exported ACM models?
Solution: To use ACM models with HYSYS 3.2 you need to: install HYSYS 3.2 from HYSYS 3.2 CD install Aspen Plus 12.1 from AES 12.1 CD You can do this in any order. Check also for service packs and cumulative hot fixes if applicable. This will provide the core components required to use ACM models in HYSYS. You do not need the A+/ACM licenses if you have a model export license and only want to use the models in HYSYS. You need A+/Aspen Properties license if you want to create a new physical properties file. To create new models in ACM to be used with HYSYS 3.2, you need to: install HYSYS 3.2 from HYSYS 3.2 CD (so that you can test your model on the same computer) install a supported compiler (Visual C++ 6.0, Visual C++ .NET, Visual C++ .NET 2003 (standard edition is enough)) install Aspen Plus 12.1 or Aspen Properties 12.1 and ACM 12.1 from AES 12.1 CD You can do this in any order. You should also install ACM cumulative hot fix 3 (or above). You need an ACM license to create new models, Aspen Plus or Properties to create new properties files, and a HYSYS license to test your models. Details on ACM model export can be found in ACM on-line help. Keywords: OOMF AMSystem Runtime References: None
Problem Statement: How do I call stored procedures with no parameters from within Aspen SQLplus?
Solution: Although it is possible to define stored procedures which do not have any parameters, they cannot be called from Aspen SQLplus as it cannot distinguish a stored procedure from any other database record. To overcome this, define a stored procedure with a dummy parameter. ProcedureDef PROCEDURE TestProc(Dummy Int) ? ? END Calling Query Select * from TestProc() Keywords: None References: None
Problem Statement: There is a statement in the SQLplus Online Help that says :- Important: It is recommended that you not CAST timestamp values as integer values, or timestamps as integers. AspenTech support has seen several SQL Queries that work for sometimes a long while, and then suddenly have problems due to casting Timestamps as Integers. Usually, but not always, the Query will start having problems at the beginning of a Leap Year. Timestamps are stored in our database (Seticm or IP.21) as an integer value that represents the number of tenths of seconds since the start of the current four-year period. The value increases gradually throughout the four-year period but then drops back down to zero at the start of the next four-year period. REMEMBER - Timestamps are stored in IP.21 as GMT, no matter where you are in the world. Therefore, a timestamp representing 00:00:00 GMT at the beginning of a Leap year will be stored as a 0 (zero). The last timestamp stored before the start of GMT Leap year is 1262303999 So if you do a Time Compare after casting Timestamps as Integer you could get a NEGATIVE result when comparing across a Leap Year Boundary.
Solution: If you want to find the time difference between two timestamp values, you should not use CAST. Instead, you should subtract the timestamp values or use the DELTA_TIME function. Example: local t1 timestamp, t2 timestamp; t1 = '11-DEC-03'; t2 = '11-JAN-04'; write t2-t1; -- Time difference as hours:minutes:seconds.tenths write delta_time(t2, t1); -- Time difference as a number of tenths of seconds Similarly, If you want to add or subtract a time interval to a timestamp, you should not use CAST. Instead, you should simply add an integer or real value to the timestamp. Example: local t1 timestamp; t1 = '31-MAR-04 10:00:00'; write t1+1:00; Keywords: References: None
Problem Statement: How to make ViewDef records to request data from the aggregate and history pseudo tables when using an ODBC connection?
Solution: In the Aspen SQLplus Query Writer write the following query: select * from history Use the Record menu and then select Save As, then save the record as a ViewDef record. Now, you can reference the ViewDef record as if it were a definition record. See the following query below for an example: select ts, value from histview where name = 'atcai' order by ts; Creating ViewDef records is convenient when querying the database, because the ViewDef record will be treated as a definition record, rather than a record defined by a definition record. Note how HISTView is on the same level as IP_AnalogDef. Keywords: pseudo tables history table aggregate table ViewDef record ODBC References: None
Problem Statement: The following query: local msg char (500); msg = ''Alarm for ''; FOR (SELECT Name FROM IP_Analogdef WHERE Name LIKE ''%atc%'') DO msg=msg || name || '',''; END write msg Would produce output that looks like this: Result ==> Alarm forATCDAI,ATCF101,ATCF102,ATCF103,ATCF201,ATCF202,ATCF301,ATCF302,ATCL101,ATCL102 ........ Problem: there is no space between the word for and the first tagname, even though there is a space in the query for line msg = ''Alarm for '';
Solution: SQLplus char variables behave like InfoPlus.21 fields and cannot store trailing spaces. In SQLplus version 4.0 and later, there is an easy way around this. SQLplus version 4.0 introduced variant variables and these can store trailing spaces. So the query could be changed to use a variant variable rather than a char variable. Eg local msg; instead of local msg char(500); Keywords: char spaces References: None
Problem Statement: Sometimes when trying to save a query as a record in InfoPlus.21, the following error message appears: Error creating record: incorrect buffer size at line 1. The error has to do with the number of characters in the name you want to save the query under. The default number of characters in the name field allowed by QueryDef record is 16.
Solution: Change the name of the query you want to save as a record in IP.21 to something equal to or shorter than 16 characters and you'll be able to save it. Keywords: buffer size Error creating record Incorrect buffer size at line 1 References: None
Problem Statement: How to access Aspen InfoPlus.21 field names via ODBC when they are invalid column names for the application (i.e. 'MESSAGE SW.' in analogdef is not valid for Microsoft Access)? Most of the definition records (i.e. ip_analogdef, ip_discretedef) have field names that consist of letters, numbers and underscores.
Solution: Create a view, which renames the fields, then access the view. The view can be created by running a query in Aspen SQLPlus. This will create a record in InfoPlus.21 defined by ViewDef. i.e. The following would create a view called newanalogdef: create view newanalogdef as select name, plant area as plant_area, value, eng units as eng_units, message sw. as Message from analogdef All fields selected in the created view will be available for queries. Then query the view from Access: i.e. select name, plant_area, eng_units, message from newanalogdef Keywords: access field names invalid column names References: None
Problem Statement: Sometimes the TSK_IQ1 or another IQ external task seems to freeze or hang. Any QueryDef record being processed by this external task would stop executing. This knowledge base article explains what could cause this and how to rectify the situation if this occurs.
Solution: Usually, one notices that an external task is hung because queries associated with a specific IQ task fail to execute on their regular intervals. How can I determine which query caused a TSK_IQ process to hang? There exists 3 situations that can cause an IQ task to hang. These situations are: 1. A query within the IQ task attempts to access a remote data source which is unavailable. This is most likely the problem if the IQ task seems to hang randomly for no plausible reason. If one believes this to be the cause of the TSK_IQ# to hang the following can be done to remedy the problem. Make sure all remote data sources are up and running. Check the network connections for disconnection or overloading Determine which data source is unavailable and move the query which accesses this data source to a dedicated IQ task. This will prevent other queries from halting when the IQ task hangs. 2. A query that utilizes a system command can cause the TSK_IQ# to hang. If one suspects that a system command causes the IQ task to hang do the following: Find out which executable is started from the system command. Use the Windows Task Manager to check if this program is running. If it is running kill it. It could be that this executable is hung in an infinite loop or is waiting for a remote connection. The more homegrown an executable is, the more suspicious one should be of it. If one cannot determine why the executable freezes up, move the query that houses the system command to a dedicated IQ task so at least the other queries can remain unaffected. 3. A query that gets caught in an infinite (or excessively long) loop can also cause an IQ task to freeze up. One should suspect this if the IQ task freezes on a predictable basis (ie, around the scheduled time for a specific query). If one suspects an infinite Aspen SQLplus loop causes the IQ task to hang the most prudent action is to examine the code & rewrite it in a more efficient manner. Keywords: TSK_IQ1 Frozen Hangs task IQ External Task References: None
Problem Statement: What are the command line parameters for recload.exe when calling it from SQLplus?
Solution: While there isn't any help (e.g. -?) for recload.exe, it does prompt for the parameters: C:\>C:\Program Files\AspenTech\InfoPlus.21\db21\code\recload.exe InfoPlus.21 ----------- V 4.1.2.1 Copyright 1996-2001 Aspen Technology, Inc. All rights reserved. InfoPlus.21 is subject to the following Restricted Rights Legend: Use, duplication or disclosure by the Government is subject to restrictions as set forth in (i) FAR 52.227-14, Alt. III, (ii) FAR 52.227-19, (iii) DFARS 252.227-7013 (c)(1)(ii), or (iv) the accom- panying license agreement as applicable. For purposes of the FAR, this Software shall be deemed in the unpublished and licensed with disclosure prohibitions. Contractor/Subcontractor: Aspen Technology, Inc.. If the Licensee is acquiring the Software under a United States government contract, the Licensee agrees that it will include all necessary and applicable restricted rights legends on the Software and the documentation to protect Aspen Technology's proprietary rights under the FAR or other similar regulations of other federal agencies. The Licensee agrees to always include such legends whenever the Software is, or is deemed to be, a deliverable under that contract. Load Text Records Program Use first free record IDs? (Y/N) : y Records will be created using the lowest available IDs File name : C:\TEMP\bob.rld Loading Records from File - a1bob5 Text Records Loaded from File (24 lines) Furthermore, if you put the parameters on the command line, it works the same way (except that it doesn't prompt for the answers): C:\Program Files\AspenTech\InfoPlus.21\db21\code>recload y c:\temp\bob.rld InfoPlus.21 ----------- V 4.1.2.1 Copyright 1996-2001 Aspen Technology, Inc. All rights reserved. InfoPlus.21 is subject to the following Restricted Rights Legend: Use, duplication or disclosure by the Government is subject to restrictions as set forth in (i) FAR 52.227-14, Alt. III, (ii) FAR 52.227-19, (iii) DFARS 252.227-7013 (c)(1)(ii), or (iv) the accom- panying license agreement as applicable. For purposes of the FAR, this Software shall be deemed in the unpublished and licensed with disclosure prohibitions. Contractor/Subcontractor: Aspen Technology, Inc.. If the Licensee is acquiring the Software under a United States government contract, the Licensee agrees that it will include all necessary and applicable restricted rights legends on the Software and the documentation to protect Aspen Technology's proprietary rights under the FAR or other similar regulations of other federal agencies. The Licensee agrees to always include such legends whenever the Software is, or is deemed to be, a deliverable under that contract. Load Text Records Program Records will be created using the lowest available IDs Loading Records from File - a1bob6 Text Records Loaded from File (24 lines) To do this from SQLplus, use the following command: SYSTEM ' C:\Program Files\AspenTech\InfoPlus.21\db21\code\recload.exe y c:\temp\bob.rld' Keywords: loadrec load record records sqlplus query syntax References: None
Problem Statement: How to use Aspen SQLplus to control the history archive period?
Solution: For example: Can I have Aspen SQLplus switch the active archive on a particular day of the month? Answer: SQLplus can detect which day the query is executed, it can also execute system commands. The Aspen InfoPlus.21 historian has the utility 'h21shift', which forces an archive to shift. The following example shows how a query scheduled to run every 24 hours will control the archive switching (this assumes that the global time span is set to greater than 31 days). IF CAST(CURRENT_TIMESTAMP AS CHAR FORMAT 'DD') = 1 THEN SYSTEM '%H21%\bin\h21shift -r TSK_DHIS'; END Note: The %H21% environment variable defines the following path: C:\Program Files (x86)\AspenTech\InfoPlus.21\c21\h21 Keywords: backup fileset shift References: None
Problem Statement: When executing an SQL script which makes use of technical tip 120388 (How can I insert data into a history repeat area using the name returned by a select statement?), the following error message is encountered. or
Solution: Below is a sample script that will return the error message shown in the above screenshots. LOCAL tagname CHAR(32); LOCAL trendTime TIMESTAMP; LOCAL trendValue REAL; tagname = 'ATCAI'; trendTime = '16-JUN-10 13:00:00'; trendValue = 1234; INSERT INTO tagname || '.PV' AS IP_AnalogDef(IP_Trend_Time, IP_Trend_Value, IP_Trend_Qstatus) VALUES (trendTime, trendValue, 'GOOD'); The error message is encountered due to the use of the concatenation operator '||' within the INSERT statement. The INSERT statement expects a table name to be passed to it (which in this case is not.) In order to correct the issue, the concatenation must be done before the INSERT statement. By simply changing it as shown below, the SQL script will execute without any issue: tagname = tagname || '.PV'; INSERT INTO tagname AS IP_AnalogDef(IP_Trend_Time, IP_Trend_Value, IP_Trend_Qstatus) VALUES (trendTime, trendValue, 'GOOD'); Keywords: Expecting expression, found || References: None
Problem Statement: How can you test Aspen CIM-IO performance?
Solution: Run the cimio_t_api program and chose option G - Test Performance. This option allows the user to perform one or more test data access cycles (GET or PUT) and displays the values and/or statuses returned. This test also provides statistical information such as the average number of tags read and written per second and the average time of GET and PUT requests. This test supports REAL, DOUBLE, LONG and SHORT data types. After selecting this option, you are prompted for the following information: Number of Test Cycles: the number of GET or PUT requests to issue. Type of Request: whether to issue GET requests, PUT requests, or both. Delay Time: amount of time to wait between requests. This value may be a positive integer for the request to complete within the specified time, or a negative integer to wait the specified time before issuing the next request. If zero is entered, there will be no delay between requests. Random or Incremental Output (output only): indicates whether to output random numbers or incremental values (that is, a series of increasing values). Tolerance: compares the data values to the specified accuracy. Periodic display: indicates whether to display the results after each request completes, or after completing all tests. Display information for all tags: indicates whether to display data as for GET and PUT options. Number of cycles before displaying results: indicates how many cycles should pass before beginning to display intermittent results (if applicable). Example: ( using the cimio simulation server ) Please enter logical device name [iosetcim]: IOSIMUL Please enter unit number [1]: 1 Please enter number of tags [1]: 1 Please enter the number of test cycles [1]: 10 Please enter whether to test GET and/or PUT requests (g/p/gp) [gp]: g Please enter the delay time in seconds for GET and PUT requests [0]: 0 Please enter whether to display tag information periodically (y/n) [y]: y Please enter whether to display information for all tags (y/n) [n]: n Please enter number of cycles before displaying test results [1]: 1 Please enter priority ( 1=HIGHEST 9=LOWEST ) [1]:4 Please enter timeout in seconds( enter 0 or -1 for infinite timeout ) [10]: 10 Access Type: 1)Synchronous 2)Asynchronous Please select access type [CIMIO_AT_SYNC]: 1 Please enter frequency in tenths of a second[100]: 100 Please enter list id [1]: -1 GET Tagname entry options 1. Enter tag information one tag at a time 2. Obtain tag information from text file Please select tagname entry option [1]: 1 Please enter tagname 1: SREAL Data types 1. 32-bit floating point ( real ) 2. 64-bit floating point ( double ) 3. 16-bit signed integer ( short ) 4. 32-bit signed integer ( long ) 5. Character string ( ASCII ) 6. Time entity Please select type for tag 'SREAL': 1 Device data types 1. 32-bit floating point ( real ) 2. 64-bit floating point ( double ) 3. 16-bit signed integer ( short ) 4. 32-bit signed integer ( long ) 5. Character string ( ASCII ) 6. Time entity 7. Enumeration 8. Ordinal 9. Delta time 10. External Identifier 11. Control Block AntiWindup 12. Control Block Status 13. Engineering Units 14. Description Please select device data type for tag 'test01' Press RETURN for default: GET successful Time to do GET request 1 of 1 with 1 tags is 0.230 seconds Performance Results Actual test time in seconds : 0.23 Number of tags read/written : 1 Average reads per second : 4 Average seconds per read : 0.230 Average seconds per GET request : 0.230 Please press RETURN to continue... Keywords: cimio performance cimio performance References: None
Problem Statement: How can one determine the version of Aspen InfoPlus.21 by using an SQLplus query?
Solution: The following SQLplus command will return the version of Aspen InfoPlus.21: Write version(0); Here are some examples of what gets returned, depending on the version: IP.21 2006 IP.21 2006.5 V7.1 Keywords: References: None
Problem Statement: This query returns the date of the first day (Monday) of a given week in a given year using ISO standards. According to ISO, the first calendar week of a year is the one containing the first Thursday of the year. This means that Monday of the first calendar week of 2010 falls on January 4, and that Monday of the 24th calendar week of 2010 falls on June 14.
Solution: The attached query defines two user defined functions first_monday_of_year and first_day_of_week. The function first_monday_of_year illustrates the use of a DO...WHILE loop and the Aspen SQLplus function day_of_week. The function first_day_of_week calls first first_monday_of_year and shows how to use the Aspen SQLplus function cast...as...format. The query prompts for year and week numbers. After calling first_day_of_week, the query calls the Aspen SQLplus function cast...as...format three times to produce output similar to MONDAY of week 1 in 2010 falls on JANUARY 04 Finally, to verify the result returned by first_day_of_week, the query calls ISO_WEEK_NUMBER Keywords: sample query example query do while day_of_week cast cast as format iso_week_number prompt References: None
Problem Statement: When a SELECT query involves the use of the AGGREGATE function, the GROUP BY statement often needs to be added. The result return does not return in the order in which the tag names are specified. In fact, it seems to have perform an ORDER BY in ascending order for the column specified first in the GROUP BY statement. As can be seen from the above screen capture, even though the Aspen SQLplus query has listed the order atcdai, atcai, atcl103, atcl101 and atcl102, however the result return is in ascending order which is atcai, atcdai, atcl101, atcl102 and atcl103.
Solution: This issue can be work around by declaring a TEMPORARY TABLE as can be seen in the screen capture below. Instead of listing out the tag names in the Aspen SQLplus SELECT query, a SELECT query can be used to query from the TEMPORARY table. SELECT a.name, ip_description, max1 FROM MODULE.X AS t LEFT OUTER JOIN (SELECT name, ip_description, MAX(ip_trend_value) AS MAX1 FROM ip_analogdef WHERE name IN (SELECT name FROM MODULE.X) -- Changed to SELECT from TEMPORARY table AND ip_trend_time < CURRENT_TIMESTAMP AND ip_trend_time > (CURRENT_TIMESTAMP - 25920000) GROUP BY name, ip_description) AS a ON t.Name = a.name ORDER BY t.Id; Keywords: AGGREGATE functions GROUP BY References: None
Problem Statement: On the Aspen InfoPlus.21 (IP.21) server, TSK_SQL_SERVER listens on a socket (usually 10014) for any SQLPlus client trying to connect. Once a client connects, TSK_SQL_SERVER spawns a Windows process called SQLplus.exe to service the SQLPlus client. One SQLplus.exe process will be started for each client that connects. Thus, by counting the number of SQLplus.exe processes running in Windows Task Manager, you'll be able to tell how many SQLplus clients are connected to the server. Based on the above, the following question may arise: How to identify the systems/clients who are using the SQLplus interface?
Solution: The following two queries do just that (NOTE: the query assumes your SQLplus service is named like Sqlplus. If your SQLplus service is named differently, you would need to substitute that name into this query): Query 1: select substring(3 of line) as Local Address, substring(4 of line) as Foreign Address from system 'netstat -a | find /i sqlplus' Query 2: For (select substring(3 of line) as Service, substring(4 of line) as IPAddress from system 'netstat -a') do if Service like '%sqlplus%' then write Service||' '||IP Address; end end The output would look like this, with one line item for each user connected. There should always be at least two lines. The first one, with the 0.0.0.0:0, is the Listening service. The 2nd one, with the localhost, is from the computer that just ran this query. All others would be users connected from around your plant. zbigniew:sqlplus 0.0.0.0:0 zbigniew:sqlplus TUMEY.hou.aspentech.com:3544 zbigniew:sqlplus WERT.hou.aspentech.com:2004 zbigniew:sqlplus localhost:1122 Keywords: None References: None
Problem Statement: This
Solution: provides a summary of statements and examples on how to manage permission for a group of records using Aspen SQLplus. For further details about it please consult Adding Record Level Security or Removing Record Level Security topics in Aspen SQLplus Help File. Solution There are three main statements that are needed to manage permission from a SQLplus query: GRANT will set permission over a record, general syntaxes is: GRANT {permission} ON {RecordName} TO {role} REVOKE will remove permission granted over a record, general syntaxes in: REVOKE {permission} ON {RecordName} FROM {role} information_schema.role_table_grants table to consult permission over a record. Permission that can be set are: All, Read, WriteGeneral, WriteRestricted, Delete, ChangeSecurity and Create. Here is a query example on how to use this: --Selecting records to change permissions Select Name from all_records where name like 'atcl10_'; --Grant ALL permission for role Admin to this records GRANT ALL ON (Select Name from all_records where name like 'Record_') TO Admin; --Displaying permission granted Write 'Permission granted:'; SELECT table_name, grantee width 25, privilege_type FROM information_schema.role_table_grants WHERE table_name in (Select Name from all_records where name like 'Record_'); --Removing Write permission REVOKE WriteGeneral, WriteRestricted, WriteSystem ON (Select Name from all_records where name like 'Record_') FROM Admin; --Displaying permission again after revoke action Write 'Permission granted after revoke Writes:'; SELECT table_name, grantee width 25, privilege_type FROM information_schema.role_table_grants WHERE table_name in (Select Name from all_records where name like 'Record_') Note that Admin role name is written using this will work for roles name with space within. Keywords: Security Record permission SQLplus References: None
Problem Statement: How do you modify the database parameters from SQLPlus on a client that does not have the Administrator installed?
Solution: Using the SYSTEM command, run the setdbparam.exe file in the SETCIMCODE directory. There is help available via the command line: C:\Program Files\AspenTech\InfoPlus.21\db21\code>setdbparam ? Usage: setdbparam [-timeoff=<time offset>] setdbparam [-dbsize=<db size>] [-numrecs=<# records>] [-inconly] <time offset> is either in Setcim time offset format or in minutes <db size> is new number of database words <# records> is new number of database records Keywords: dbclock size References: None
Problem Statement: An SQLplus 'System' command executes an Operating System Command such as DIR, or such as execution of an EXE or BAT file - just as if you were executing it at the DOS or Command Prompt. If I am running the SQLplus Query Writer on the same PC as IP.21 is running, and my query contains a System command, then it is obvious that we want that command executed on that same PC, and that is what it will do. Now, suppose I run SQLplus Query Writer on a PC that is Remote to the IP.21, there is a lot of confusion over where that command executes, and what setup is needed for it to run successfully.
Solution: The answers are: 'By default', the 'System' command will execute on, and look for files on, the PC to which you are connected - NOT the remote PC from which you are running Sqlplus Query Writer, When any remote PC is used, the directory MUST HAVE SHARED ACCESS There is a way to over-ride the default Let's try and demonstrate this with 4 different examples :- Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on MYPC, then the following query to execute a .BAT file on MYPC will be successful : System 'Test.Bat'; Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on YOURPC, then the simple query System 'Test.Bat'; will only run if Test.Bat exists on YOURPC, AND, Test.Bat is on YOURPC in a directory that is SHARED Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on YOURPC, If I want to run system commands pointing back to MYPC, I would have to execute something like System '\\MYPC\share\test.bat'; I could also run something like System 'DIR \\MYPC\share'; (where 'share' is a Shared directory on MYPC) Running Query Writer on MYPC, and connect (via Query/Host) to the IP.21 on MYPC, If I want to run system commands pointing forward to YOURPC, I would have to execute something like System '\\YOURPC\share\test.bat'; Or System ' DIR \\YOURPC\share'; (where 'share' is a Shared directory on YOURPC) Keywords: References: None
Problem Statement: Can I stop and start Aspen InfoPlus.21 tasks using Aspen SQLplus queries?
Solution: This knowledge base article describes how to stop and start Aspen InfoPlus.21 tasks using Aspen SQLplus queries. Aspen InfoPlus.21 is shipped with a command line utility (tsk_client.exe) for managing Aspen InfoPlus.21. This utility is located in Program Files\AspenTech\InfoPlus.21\db21\code. Using this utility in conjunction with the SYSTEM command in Aspen SQLplus, it is possible to stop and start Aspen InfoPlus.21 tasks. It is necessary to include the path to the tsk_client executable. Example: SYSTEM 'd:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /stop_task TSK_IQ1'; Wait 50; SYSTEM 'd:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /start_task_by_name TSK_IQ1'; You may use environment variables in lieu of the full path. Example: SYSTEM '%SETCIMCODE%\tsk_client /stop_task TSK_IQ1'; Wait 50; SYSTEM '%SETCIMCODE%\tsk_client /start_task_by_name TSK_IQ1'; Note: For some Aspen InfoPlus.21 tasks that do not have an external task record, such as TSK_APEX_SERVER you will be prompted to provide a yes or no answer. To remedy this you could create a small text file which includes the yes or no response or use the DOS echo command. Example: Create the file named t.txt containing the letter Y and execute the code below. SYSTEM 'C:\program files\aspentech\infoplus.21\db21\code\tsk_client /stop_task TSK_APEX_SERVER < c:\t.txt' Where t.txt just contains Y. Example: Use the DOS echo command: SYSTEM 'echo Y | c:\progra~1\aspentech\infoplus.21\db21\code\tsk_client /stop_task_by_name TSK_APEX_SERVER'; Or SYSTEM 'echo Y |%SETCIMCODE%\tsk_client /stop_task_by_name TSK_APEX_SERVER'; Keywords: stop task start task References: None
Problem Statement: When selecting from a View, the following message is given. In some circumstances, you may be seeing a Microsoft Visual C++ Runtime Library error message instead as shown below.
Solution: This is due to the usage of the ORDER BY clause in the SQL script used to create the View. ORDER BY clause is not allowed in the SQL script in View creation. Keywords: ORDER BY View Microsoft Visual C++ Runtime Library reserved word ORDER is not valid as a table expression Runtime Error! Program: C... This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information References: None
Problem Statement: This Aspen SQLPlus query lists all Aspen InfoPlus.21 records defined by IP_AnalogDef that are not in standard CIM-IO get transfer records.
Solution: select Name from ip_analogdef where Name not in (select cast(io_value_record&&fld as record) as tagname from IoGetDef where tagname is not null union select cast(io_value_record&&fld as record) as tagname1 from IoGetHistDef where tagname1 is not null union select cast(io_value_record&&fld as record) as tagname2 from IoLLTagGetDef where tagname2 is not null union select cast(io_value_record&&fld as record) as tagname3 from IoLLTagUnsDef where tagname3 is not null union select cast(io_value_record&&fld as record) as tagname4 from IoLongTagGetDef where tagname4 is not null union select cast(io_value_record&&fld as record) as tagname5 from IoLongTagUnsDef where tagname5 is not null union select cast(io_value_record&&fld as record) as tagname6 from IoUnsolDef where tagname6 is not null) order by name asc; Keywords: Sample Query References: None
Problem Statement: What are the recommended steps for performing maintenance on Aspen Cim-IO transfer records? Performing record maintenance on Aspen Cim-IO transfer records while the records are activating could result in undesirable results. This is especially true if Aspen Cim-IO Store and Forward (S&F) is enabled. The S&F scanner process maintains a scan list (cimio_scan_list_device) on the Aspen Cim-IO server that handles the scheduling of data collections. Performing record maintenance on Aspen Cim-IO transfer records could cause the scan list to become out of sync with the transfer record.
Solution: Steps to perform maintenance on Aspen Cim-IO transfer records. Set IO_Record_Processing to OFF This suspends scanning for this transfer record by removing it from the scan list on the server. Record maintenance can now safely be completed on transfer record. Set IO_Record_Processing to ON This updates the scan list on the Aspen Cim-IO server and resumes data collection. If data collection does not resume then activate the record (next step) ? Set IO_Activate to YES Depending on the version of Aspen Cim-IO this step may not be required but does not cause any problems if completed. Keywords: io_data_processing References: None
Problem Statement: Real numbers with many significant digits (greater than 7), when displayed in Aspen SQLPlus, are displayed in exponential format, such as 1.23457e+007. Precision is not lost, but this may not be how you want the number to be displayed.
Solution: To display the number in true numeric format, you can use the CAST USING statement to convert the value to CHAR, and display the value with a specific format. For example: local x real; x = 12345678.912; write x; write CAST(x as CHAR using 'f22.11'); Running this gives you: 1.23457e+007 12345678.91200000047 For additional information please take a look atSolution 103161. Keywords: CAST CAST USING scientific notation exponential exponent References: None
Problem Statement: Upgrading to CIM-IO version 4.9.4 on Windows NT
Solution: Shutdown the interface(s) on the CIM-IO Server Stop all of the CIM-IO tasks on the CIM-IO Client Install version 4.9.4 of CIM-IO (The same CD is used to install both the CIM-IO Server and Client). Keywords: References: the CIM-IO User's Manual. Server: Install version 4.9.4 of the CIM-IO server over the existing one. Make sure all the CIM-IO processes are shut down. Note: you can not uninstall CIM-IO software Client: Install version 4.9.4 of the CIM-IO client over the existing one. Make sure all the CIM-IO processes are shut down. Note: you can not uninstall CIM-IO software For the 4.9.4 version of CIM-IO you do not need to load the cimio.rld file. The cimio.rld is a record definition file that is provided as part of the CIM-IO software installation. Re-link the interface(s) (Interface specific, please refer to the interface manual)
Problem Statement: Prior to V6, when using the HISTORY table to request TEXT data from records such as IP_TextDef records, it would result in the message: no rows selected
Solution: The History table can now take a parameter to indicate that the value should be returned as a character value. The value of the parameter is the maximum length (column size) of the value column. E.g. select ts,value from history(80) where name = 'TextRec1' and ts between '30-jun-04 10:00:00' and '30-jun-04 10:32:00' and request=4 Because of the 'Request=4' this will return the 'actual' values within these times But what about Interpolation? You CAN run the query WITHOUT the Request=4 'Without' Request=4, the table returns interpolated data, which for Text values means the nearest recorded value at or BEFORE the interpolated timestamp. Note: If requesting interpolated data it is recommended that you have occurrences in History before and after the requested Start and End Times in the 'between' clause. Otherwise you will get blanks before the Start time and incorrect values after the time of the Last occurrence. Contact technical support if you need better clarification on this last issue. Keywords: interpolate regular space interval last References: None
Problem Statement: Is there a way using SQLplus to identify which record an external task is processing?
Solution: There are 2 functions that can retrieve this type of information. The first one is TASK_CURRENT. TASK_CURRENT(external_task_record) returns the record currently being processed by the specified external task. It returns NULL if the task is not processing a record. For example: local v_curr_rec char(10); v_curr_rec = TASK_CURRENT('TSK_PLAN'); write v_curr_rec; Your output would return the record that TSK_PLAN was currently working on, such as COS1. The second one is TASK_NEXT. TASK_NEXT(external_task_record) returns the next record to be processed by the specified external task. It returns NULL if there is no next record. For example: local v_next_rec char(10); v_next_rec = TASK_NEXT('TSK_PLAN'); write v_next_rec; Your output would return the record that TSK_PLAN was going to work on next, such as COS2. These functions could be very useful in determining which record may be causing a task to go compute bound, etc... Note: This same information can be obtained in Setcim by running the SHPROREC utility, and in InfoPlus.21 using the Administrator tool. In the Admin tool, you would need to select an external task record, for instance TSK_IQ1, right mouse click, choose Properties, and choose the External Task tab. This will show you what record is currently being processed, and what record will be processed next. Keywords: task, processing, current, next References: None
Problem Statement: Can I use a query to update the oldest allowed timestamp for a list of tags contained in an text file?
Solution: The attached query UpdateXOLDESTOKfromFile reads tag names from a text file and changes the oldest allowed timestamp for a history field. The query first prompts for a text file containing one tag name per line. The default name of the file is XOldestOKTags.txt located in the Aspen InfoPlus.21 Group200 folder. Next, the query prompts for the oldest allowed historical timestamp for the tags using the date format native to the InfoPlus.21 database. The default is May 1, 2010. Finally, the query changes the oldest allowed historical timestamp for each tag in the text file. The query assumes the history repeat area contains the field IP_TREND_VALUE. Modify the query if the history repeat area uses a different field to hold the trend value. Keywords: XOLDESTOK, DATE_FORMAT References: None
Problem Statement: This knowledge base article discusses how to print output generated from an SQLplus query to various printers on the network.
Solution: The SYSTEM command in SQLplus is usually used to call custom programs from within an SQLplus script. However, the SYSTEM command can also be used to call Windows DOS functions such as the 'PRINT' function. The PRINT function can thus be used in an SQLplus script to print a file to a printer on the network. This article assumes that your SQLplus script already generates output to a text file called FileName.txt in C:\. The calling convention used within SQLplus is: SYSTEM 'PRINT /D:Device C:\FileName.txt' Where Device denotes the printer to which the SQLplus query needs to print. As the queries are executed by the Aspen Infoplus.21 Taskservice, this service needs to be started with a domain account. Before printing from an SQLplus query, it is recommended to first manually use the PRINT command from a DOS prompt to verify that the printer name and the path + file name are correct. Using the PRINT command from a DOS prompt is also a good way to debug problems encountered when using this command from SQLplus. Keywords: References: None
Problem Statement: Note the results of the following query: local ts1 timestamp, ts2 timestamp; ts1 = '04-MAR-13 10:20:30.12'; ts2 = '04-MAR-13 10:20:30.13'; if ts1 like ts2 then write 'Like'; else write 'Not Like'; end if ts1 = ts2 then write 'Equal'; else write 'Not Equal'; end This query produces: Like Not Equal
Solution: Note that = and LIKE are not equivalent.A A LIKE matches patterns and = tests for equality. Also,LIKE always compares character values and = can compare values of different data types. The default format for timestamp local variables is TS20, so using LIKE to compare timestamp local variables means that fractions of a tenth of a second are ignored.A Meaning that when the LIKE operator sees the two timestamps specified above, it sees: ts1 = '04-MAR-13 10:20:30.1'; ts2 = '04-MAR-13 10:20:30.1'; Whereas the = operator sees the entire value, including the hundredths of seconds (or greater). NOTE :Even if you CAST a timestamp as 'TS25', thereby gaining greater reSolution to the value, the comparison will still default to tenths of seconds, unless you CAST the comparison also, like this: SELECT IP_Trend_Time USING 'TS25' FROM ATCAI WHERE CAST(IP_Trend_Time AS CHAR USING 'TS25') LIKE '06-MAR-13 09:37:52.767000'; The second CAST in the statement immediately above expands the scope of accuracy of LIKE from TS20 (tenths of seconds) to TS25 (microsecond) for the actual selection made, not just the display. Overall Aspen recommends the more reliable path of using the = operator when comparing and making decisions based on timestamps. This way you will avoid potential errors in your queries based on the design of the LIKE operator, which only evaluates to tenths of a second. Keywords: None References: None
Problem Statement: Why does this query not return a character length of 5?
Solution: SQLplus truncates character strings, but not variants. By declaring x as a variant, the character length is the expected result. Keywords: variant character string char_length References: None
Problem Statement: SQLplus can be used to determine both the number of unusable records in the IP.21 database and the names of the records. The query below is an example of how this is done.
Solution: The following query will return the total number of records in the IP.21 database set to unusable followed by a list of the record names. Write DATABASE_SIZE(''unusable_records''); Select Name From ALL_RECORDS where Usable = 0; The DATABASE_SIZE function can be used with different parameters to find other useful information. For example, it can be used to determine the total number of records in the database, the maximum number of records which can be created for the database, and the highest used record ID. For more information on the DATABASE_SIZE function see the SQLPlus Help File by searching on DATABASE_SIZE. Keywords: number of records unusable records References: None
Problem Statement: Sometimes it may only be necessary to see the first so many records of output instead of seeing them all. For example, you only need to see the first 3 records with the highest ip_graph_maximum and the tag name.
Solution: The easiest way to accomplish this is by using the MAX_ROWS SET statement as follows: SET MAX_ROWS 3; SELECT name, ip_graph_maximum FROM ip_analogdef ORDER BY ip_graph_maximum DESC; Your results would only contain 3 rows of data including the name and ip_graph_maximum (largest value first and so on). The ORDER BY, or sort, happens prior to displaying the 3 rows so you''re assured to get the highest 3. Remember that the MAX_ROWS statement ONLY applies to the first select statement following it. If your query has another SELECT statement where you also need to limit the rows of output, this would require another SET MAX_ROWS statement just prior to the statement. Keywords: limit output MAX_ROWS results References: None
Problem Statement: This Knowledge Based article is to provide assistance to customers who are experiencing the following error during the installation of SQLplus from the Manufacturing Suite: There was a problem with configuring Aspen SQLplus Return Code is 2
Solution: If you are receiving this error please verify the following: 1) Installation is being performed with user rights sufficient to access all of the media being utilised if the media is local to the machine 2) If using network shares, ensure the user has sufficient rights to all subfolders within the AspenTech install package on the remote network share. 3) Ensure the required MSI install package(s) are all correctly situated within the install location. Once the user rights have been verified, reinstall and verify the installation performs correctly. Keywords: Return Code 2 SQLplus References: None
Problem Statement: How to update IP.21 tables direclty from RDB remote tables in one statement
Solution: Use the following syntax update IP.21 table A, link name.instance name .table name B set A.field name= B.column name, where B.field name = A.column name For example, say you want to update the ip_value field for an IP_DiscreteDef record from an Oracle table that has two columns: TEST_CODE and PROD_ID update ip_discretedef A, QCS_SP.PUBLIC.CODE_MASTER B set A.ip_value = B.TEST_CODE, where B.ip_description = A.PROD_ID Keywords: Sqlplus Remote table References: None
Problem Statement: The fc (file compare) function works fine when executed from a command window but doesn't produce results when executed in the Aspen SQLPlus Query Writer. The following command works in DOS: fc samplefile1.txt samplefile2.txt In the SQLPlus Query Writer, using the SYSTEM command with fc doesn't produce any results: SYSTEM 'fc samplefile1.txt samplefile2.txt'
Solution: This command doesn't show results because fc needs to redirect the standard input. Two examples are shown using redirection operators. Below is an example that will write the results to the SQLplus query window. Note that the file intput.txt has to exist prior to executing the command. If file intput.txt does not exist (and it can be completely empty), an error will be received: The system cannot find the file specified. This query will write to the query window: SYSTEM 'fc < c:\input.txt c:\samplefile1.txt c:\samplefile2.txt'; The next example sends the output to a file named output.txt. SYSTEM 'fc < c:\input.txt c:\samplefile1.txt c:\samplefile2.txt > C:\output.txt'; Again, the file input.txt must exist prior to executing the command. The file output.txt will automatically be created. Refer to the following Microsoft article for more information about redirection operators. http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true Keywords: References: None
Problem Statement: What is the Aspen SQLplus syntax to retrieve data using a WHERE clause with a date from an Microsoft Access table?
Solution: ThisSolution assumes that the correct configuration has been done for the ODBC Link which is address inSolution 107956. The query statement below will give Production History from a Microsoft Access database where the close date is after July 27, 2007: SELECT Workorder as WO, Pieces in as Amount, Date Created as CloseDate FROM ProdHist.C:\Data\ProductionHistory.Machine History WHERE cast(CloseDate as Timestamp) > 'Jul-27-07' Keywords: ODBC SQLplus Microsoft Access date/time format References: None
Problem Statement: This knowledge base article explains why the following error Fail to open file $COMPRESS_SOURCE/filename.sql may occur when trying to Save or Open a query stored in a CompQueryDef, ViewDef or ProcedureDef record in Aspen SQLPlus.
Solution: There are 3 probable causes of this problem: 1. The COMPRESS_SOURCE environment variable is undefined. 2. The original (uncompressed) Aspen SQLplus query/script could not be found in the path specified in the COMPRESS_SOURCE environment variable. 3. The Source File has the Read Only attribute enabled The first cause is common to customers who are running v2.5.1 and earlier versions of Aspen InfoPlus.21. From v3.x onwards, the COMPRESS_SOURCE environment variable is automatically defined during installation. The second cause is common to users who have just migrated to a new server and forgot to migrate the uncompressed queries. The first thing to do in any case is to check if the COMPRESS_SOURCE environment variable is present. To do this in Windows, go to Control Panel | System | Advanced Tab | Environment Variables Under System Variables, search for COMPRESS_SOURCE. If this variable is not present, you should create a new environment variable with the name COMPRESS_SOURCE, and Variable Value which points to AspenTech\InfoPlus.21\db21\group200\sql Important: The computer must be rebooted after adding a new environment variable. Otherwise, the new environment variable will not properly recognized. Next, check if the uncompressed query is in the path specified in the COMPRESS_SOURCE environment variable. The uncompressed query must be present in this path or you will not be able to open it using the Aspen SQLPlus Query Writer. If it's not there, do a search for it or obtain a backup copy of the uncompressed query. Finally, it is also important to make sure that the source file (Source_File_Name.sql in this example) does not have the Read Only attribute enabled. Keywords: Compressed References: None
Problem Statement: IP_TREND_TIME timestamps show up as ******** in query of IP_TextDef query.
Solution: To resolve the problem, the TS20 record (defined under TimeStampFormDef) should be used for the timestamps. This can be done in two ways. The first method is illustrated in the sample query below. Select IP_TREND_TIME using ''TS20'', IP_TREND_VALUE from Test_Tag; In this example, the timestamp is displayed using the TS20 format. The second way to address the problem is to specify TS20 in the IP_TREND_VALUE field for the IP_TextDef record. The IP_TREND_VALUE field is found in the #_OF_FIELDS_IN_REC repeat area for the definition record. An example of this method can be seen in the attached document. Keywords: text query time stamp References: None
Problem Statement: When executing SQL script in Aspen Query Writer, the following error message appears.
Solution: This is due to the use of local variable declared without specifying data type in arithmetic calculation. When a local variable is declared without specifying data type, it will default to be a variant local variable. Declare the variables in the SQL script specifying a data type for the variables using the syntax shown below: LOCAL variable_name <data_type> Keywords: variant arithmetic failed variant References: None
Problem Statement: The following errors may occur when attempting to create new records in Aspen InfoPlus.21. No free record ID after 2000 for INSERT or CREATE or No available record ID's
Solution: InfoPlus.21 assigns a unique internal numeric number to every record that gets created in the database. This is referred to as the Record ID. InfoPlus.21 must allocate these record IDs, which requires a small amount of memory in an internal table. It takes up 12 bytes per record ID, whether a record has been created which uses that record ID or not. Because of this memory usage, most customers would prefer not to allocate a large number of record IDs, if their database will not grow that large. Sometimes, this will lead to the database not having enough record IDs available for use, as records are added to the database. When a new record gets created using the InfoPlus.21 Administrator tool, it will usually be assigned the first available free ID in the database. However, SQLplus can be used to insert records, and a hard-coded number was picked as the starting point, to check for free IDs. That number was 2000. If there are no free record IDs above the number 2000, you will see the error message mentioned above. To correct this problem, open the InfoPlus.21 Administrator, right-click on the InfoPlus.21 data source, select Properties, and select the tab for Record Utilization. Increase the total number of records. You should set the number large enough that you have enough available record IDs for the number of records you want to create, plus some additional for future growth. It is not necessary to stop and restart InfoPlus.21. The change takes affect immediately, and the new record IDs are available for use. Keywords: insert free References: None
Problem Statement: When starting the Aspen CIM-IO MANAGER service using Store and Forward, the Store, Scanner and Forward processes may not be started. At a command prompt, go to the %CIMIOCODE% directory and attempt to start Store and Forward: C:\AspenTech\InfoPlus.21\db21\code> :\commands\cimio_sf_start Check to see that the following messages are returned (3 times - one for Store, Scan and Forward services) : facility=8 Error=8007 facility=3 Error=3110 facility=3 Error=3021 facility=2 Error=2010 Facility=2 Error=2005 Facility=1 Error=11004Failure to initialize CIMIO, Exiting There may be nothing related to these messages recorded in the CIMIO_MSG.LOG.
Solution: The meanings of the error messages are as follows: facility=8 error=8007 INIT,8007,Error initializing CIMIO facility=3 error=3110 POLL_FIRSTTIME,3110,Error accepting connection facility=3 error=3021 ACCEPT_SOCK_CREATE,3021,Error creating an inbound socket facility=2 error=2010 IN_CREATE,2010,Error creating inbound socket facility=2 error=2005 GETSERV_FAIL,2005,Error looking up service name facility=1 error=11004 Failed to initialize CIM I/O, exiting These error messages are generally related to problems in the services file (WINDOWS\system32\drivers\etc). The problem in the services file may be that there is not a carriage return at the end of the file. Confirm that this additional line exists on the CIM-IO server and client machines. Also confirm that names for the scan, store, and forward service entries are formatted correctly. The service entries should be in the following format. <DLGP Service Name>_SC <DLGP Service Name>_ST <DLGP Service Name>_FW A character limitation also exists for service names. They should not exceed 15 characters in length due to a restriction placed by the Operating System. Keywords: startup store and forward initialize facility services References: None
Problem Statement: When saving a Query as a QueryDef record, the following error is raised: Failed to save to record: Source line too long.
Solution: This error is displayed because a QueryDef record limits each line of the query to 80 characters. If one of the query lines exceeds this limit, the above error results. To work around this, there are two options: Find any lines in the query text that exceed 80 characters. Include a carriage return in these lines so that they fall under the 80 character limit. Save the record as a CompQueryDef record. CompQueryDef records do not contain the 80 character line limit. Instead, the record compresses the query to save space in the database. Keywords: comp query References: None
Problem Statement: Is it possible to call or activate one query record (for example, a QueryDef record or a CompQueryDef record) from another query record?
Solution: Yes, one may call or activate one query record from another by using the following syntax within the query: ACTTSK 'Name of record to be activated'; For example (where the record to be activated is named WeeklyReport): ACTTSK 'WeeklyReport'; Additional information about ACTTSK may be found within the SQLplus help file. Keywords: None References: None
Problem Statement: How to populate a variable when the result of an Oracle function is a Result Set. When the results of an Oracle function returns single variables,
Solution: # 116213 describes how to populate the local variable within Aspen SQLplus using those values from an Oracle database table. If the Oracle function returns a result set then how do you extract the needed data?Solution Place the results of the EXEC STATEMENT into a temporary table and then query the temporary table using standard Aspen SQLplus syntax. Here's an example: DECLARE LOCAL TEMPORARY TABLE MODULE.Temp(Name CHAR(10)); INSERT INTO MODULE.TEMP EXEC 'SELECT Dbindex FROM Dllrecon' on AdvisorDemo; FOR (SELECT * FROM MODULE.TEMP) DO WRITE Name; END Keywords: Result Set Oracle table populate References: None
Problem Statement: How can you populate an Aspen InfoPlus.21 database with the minimum tag requirements using an SQLplus script?
Solution: The standard analog definition record is IP_AnalogDef. If this is the record you will be using, the minimum requirements are to choose a value format, and to turn on the history system. All other fields could be considered optional. They query below will create a series of IP_AnalogDef records, and fill in these required fields. The query could be expanded and enhanced to include any other fields within the records. Example query: local the_count integer; local max_count integer; local the_name char (24); -- -- Set the maximum number of tags -- max_count = ???; for the_count = 1 to max_count do the_name = 'test' || the_count; insert into ip_analogdef (name, ip_value_format, ip_repository, ip_#_of_trend_values, ip_archiving) values (the_name, 'f9.3', 'tsk_dhis', 2, 'on'); end; Keywords: InfoPlus21 database populate SQL create bulk-load References: None
Problem Statement: Is there a way to create separate Desktop Shortcut (icons) for Aspen SQLPlus that will automatically access a specific host? By design, when you open Aspen SQLPlus, it always connects to the last host that was accessed. This value is stored in the registry key. If you have many Aspen ADSA datasources, you might want to be able to create Desktop shortcuts (icons) that would open SQLPlus using a specific host.
Solution: Starting with version 6.0.1, the following Aspen SQLplus command line parameters are available. You can right click on the Desktop shortcut and add the parameter accordingly to the target path: . /ads - Specifies an ADSA data source name to which to connect . /p - Specifies the port name to which to connect . /h - Specifies the host name to which to connect For example, the following command starts SQLplus and connects to ADSA data source, ds1: C:\Program Files\AspenTech\InfoPlus.21\db21\code\SQLplus.exe /ads=ds1 The following example starts SQLplus and connects server srv1 on port 10024: C:\Program Files\AspenTech\InfoPlus.21\db21\code\SQLplus.exe /h=srv1 /p=10024 Keywords: Icon Host References: None
Problem Statement: I used below SQL Syntax to save as excel to html format.however, the html file is not readable. local XLobj, a; local i int, j int; XLobj = CreateObject('Excel.Application'); XLobj.Workbooks.Open('c:\test.xlsx'); XLobj.ActiveWorkbook.SaveAs('C:\test.html'); XLobj.Quit; XLobj = NULL;
Solution: The reason is that you missed a parameter for file format. see below modified Syntax: XLobj.ActiveWorkbook.SaveAs('C:\test.html',44); -- 44 indicates that the file format is html see below XlFileFormat and Constant Value xlAddIn 18 xlCSV 6 xlCSVMac 22 xlCSVMSDOS 24 xlCSVWindows 23 xlCurrentPlatformText -4158 xlDBF2 7 xlDBF3 8 xlDBF4 11 xlDIF 9 xlExcel2 16 xlExcel2FarEast 27 xlExcel3 29 xlExcel4 33 xlExcel4Workbook 35 xlExcel5 39 xlExcel7 39 xlExcel9795 43 xlHtml 44 xlIntlAddIn 26 xlIntlMacro 25 xlSYLK 2 xlTemplate 17 xlTextMac 19 xlTextMSDOS 21 xlTextPrinter 36 xlTextWindows 20 xlUnicodeText 42 xlWebArchive 45 xlWJ2WD1 14 xlWJ3 40 xlWJ3FJ3 41 xlWK1 5 xlWK1ALL 31 xlWK1FMT 30 xlWK3 15 xlWK3FM3 32 xlWK4 38 xlWKS 4 xlWorkbookNormal -4143 xlWorks2FarEast 28 xlWQ1 34 xlXMLData 47 xlXMLSpreadsheet 46 Keywords: saveas htm html not readable format References: None
Problem Statement: Aspen SQLplus clients receive unexpected Access Denied messages perhaps after rebooting the Aspen Local Security or InfoPlus.21 server.
Solution: Try removing and re-adding the SQLplus securable object using the AFW Security Manager. Keywords: None References: None