db2-400

db2_fetch_assoc() fails midway through iterating over result set

梦想的初衷 提交于 2019-12-11 03:22:21
问题 I'm running on IBM i (an AS/400) V7R2, PHP v5.6.5, Zend Server v8.0.2. I have a query which takes less than a second to execute from iNavigator. When I run the same query from a PHP script and then loop through it using: $numRows = 0; while ($row = db2_fetch_assoc($stmt)) { //Do stuff $numRows++; } echo $numRows++; $numRows ends up only being a fraction of the expected result set and I get this error in the Zend logs: PHP Warning: db2_fetch_assoc(): Fetch Failure in /path/to/script.php on

Return records with only most recent TIME value?

孤街醉人 提交于 2019-12-11 01:12:32
问题 I have a table I need to do some data conversion on. It is a simple tracking table as outlined below: SSN 9,0 KEY (ex. 123456789) NON-NULL DATE 8,0 KEY (ex. 20131202) NON-NULL TIME 6,0 KEY (ex. 133000) NON-NULL PRINT_NEW Z (ex.2013-12-02-11.23.47.965000) (CURRENT_TIMESTAMP used) NON-NULL PRINT_OLD Z (ex. 2013-12-02-11.23.47.965000) (CURRENT_TIMESTAMP used) NULLABLE Previously I was inserting the current system time into the [TIME] field, however, what I should have been doing is inserting the

Error SQL0104 when creating a function in System i V7R1

為{幸葍}努か 提交于 2019-12-08 20:08:59
I'm creating a SQL function on System i V7R1: CREATE FUNCTION MYSCHEMA.GROUPDIBAS(v_code VARCHAR(50)) RETURNS VARCHAR(2048) LANGUAGE SQL BEGIN DECLARE str VARCHAR(2048); SET str = ''; FOR row AS ( SELECT FIELD2 FROM MYSCHEMA.DIBAS WHERE FIELD1 = v_code ) DO SET str = 'Bubi'; --I removed many statements to make clear the problem doesn't come from them END FOR; RETURN str; END ; I execute it with "Run SQL script" tool, which is part of the iSeries Navigator V7R1. It works on another V7R1 server (using iSeries Navigator V5R4), but not in that one where I'm working now. It fails with this message:

From Hex Value to EBCDIC in DB2 for iSeries

纵然是瞬间 提交于 2019-12-08 13:22:30
问题 I have HEX data like this (F9F9F9F9) returned from a query. When I checked from IBM link : https://www.ibm.com/support/knowledgecenter/en/SS2MB5_14.1.0/com.ibm.xlf141.bg.doc/language_ref/asciit.html F9 = 9 and F9 = 9 Here I should get result as 9999 I jhave around 1000 hex records like this in a table. How can I convert this hex values to it corrsponding EBCDIC ? I tried like : select cast(col char(2) as codebase(37)) from table How ever, its not working. THis link is also not working: I'm

Move data from iSeries to DB2 Express?

不羁岁月 提交于 2019-12-08 10:47:40
问题 We need to migrate a database from DB2 for i (iSeries AS/400) to DB2 Express. We do not have access to the iSeries, which is managed by a different company, so a direct ODBC/JDBC connection isn't an option. We need them to export their schemas and data into a format that we can import here. So far, they've sent us a set of field definition files (*.FDF), but I haven't been able to figure out how to do much with them (learning DB2 on the fly here). I've familiarized myself with db2move ,

Error SQL0104 when creating a function in System i V7R1

大憨熊 提交于 2019-12-08 08:01:45
问题 I'm creating a SQL function on System i V7R1: CREATE FUNCTION MYSCHEMA.GROUPDIBAS(v_code VARCHAR(50)) RETURNS VARCHAR(2048) LANGUAGE SQL BEGIN DECLARE str VARCHAR(2048); SET str = ''; FOR row AS ( SELECT FIELD2 FROM MYSCHEMA.DIBAS WHERE FIELD1 = v_code ) DO SET str = 'Bubi'; --I removed many statements to make clear the problem doesn't come from them END FOR; RETURN str; END ; I execute it with "Run SQL script" tool, which is part of the iSeries Navigator V7R1. It works on another V7R1 server

How can I calculate the difference in days between two days stored as YYYYMMDD in a query?

≡放荡痞女 提交于 2019-12-08 06:54:25
问题 I am writing a query where I need to calculate the number of days since a date that is stored in the database in the format "YYYYMMDD". Since this is not a Date datatype, I can't use native Date functions. What is the best way (performance-wise, readability-wise, etc.) to perform such a calculation in a SQL query. 回答1: Best? Convert that old table to use real date columns. Next best? Write a database function to convert YYMMDD to a real date. Alan Campin's iDate can help. You'd end up with

How do I access AS/400 using SQLAlchemy?

此生再无相见时 提交于 2019-12-06 13:15:23
问题 Short version: Please tell me how to connect to AS/400s via SQLAlchemy. Long version My ultimate goal is to join data from SQL Server and AS/400 to be displayed in a Flask Python application. My approach has been to get the data from each database into Pandas dataframes, which can then be joined and output as JSON. If anyone has a better approach, feel free to leave a comment. The problem with the way I'm trying to do this is that Pandas.read_sql_query() relies on SQLAlchemy, and getting

DB2 storing results from final table clause

假装没事ソ 提交于 2019-12-04 20:24:17
The FINAL TABLE clause is great for getting values back from DML in DB2, for example: SELECT id FROM FINAL TABLE ( INSERT INTO mySchema.myTable (val) VALUES ('data') ) However, there doesn't seem to be a way to store the results of this query into another table, persisting the contents somewhere. For example, both of the following fail with the error "Data change table reference not allowed where specified." (I am running DB2 for i v7.1): CREATE TABLE mySchema.otherTable AS ( SELECT id FROM FINAL TABLE ( INSERT INTO mySchema.myTable (val) VALUES ('data') ) ) WITH DATA After creating mySchema

How do I access AS/400 using SQLAlchemy?

二次信任 提交于 2019-12-04 17:33:42
Short version: Please tell me how to connect to AS/400s via SQLAlchemy. Long version My ultimate goal is to join data from SQL Server and AS/400 to be displayed in a Flask Python application. My approach has been to get the data from each database into Pandas dataframes, which can then be joined and output as JSON. If anyone has a better approach, feel free to leave a comment. The problem with the way I'm trying to do this is that Pandas.read_sql_query() relies on SQLAlchemy, and getting SQLAlchemy to work with AS/400 is proving quite difficult. The AS/400 is version 7.2, though another I will