db2-400

IBM DB2 for i error messages using short column names in errors

只谈情不闲聊 提交于 2019-12-23 20:19:02
问题 Note this question is specific to "IBM DB2 for i", the IBM i operating system's version of DB2. The below screenshot shows a purposely erroneous INSERT statement that produces an SQL error of SQL0407. My question... Is there a DB2, JDBC, or other setting I can alter so the long column names are used in the error vs. the cryptic short ones? Note I used the long column names in the INSERT statement. 回答1: Carol Ramler, DB2 for i Senior Software Engineer at IBM , responded with this: In this

IBM DB2: Generate list of dates between two dates

只谈情不闲聊 提交于 2019-12-19 03:38:11
问题 I need a query which will output a list of dates between two given dates. For example, if my start date is 23/02/2016 and end date is 02/03/2016, I am expecting the following output: Date ---- 23/02/2016 24/02/2016 25/02/2016 26/02/2016 27/02/2016 28/02/2016 29/02/2016 01/03/2016 02/03/2016 Also, I need the above using SQL only (without the use of 'WITH' statement or tables). Please help. 回答1: I am using ,ostly DB2 for iSeries, so I will give you an SQL only solution that works on it.

Ruby On Rails Returning Array NoMethodError

烈酒焚心 提交于 2019-12-13 05:45:53
问题 We've been continuously working on this issue for a few months and not getting far with it. Since this was first asked, we changed the code (based on what the original developer for the site suggested), but we are still not getting where we need to be. I'm relatively new to Ruby and am currently taking some courses to learn more about it, so please bear with me. We're using Ruby 1.9 and Rails 3.2 We use AS 400/DB2 for our database. We have an online ordering site that you have to have an

Refer to table name dynamically in DB2/400 SQL query..?

孤者浪人 提交于 2019-12-13 04:41:16
问题 I'd like to run a query that gets a combination of live data and metadata for a regularly changing list of table names. This is for research & analysis on a large server with 100+ schemas and thousands of tables/views in each. I need help referring to table names dynamically, which I do understand is NOT possible. However... My googling indicates the solution may be an SQL statement in a text variable, which is then executed by the EXEC statement. But this is DB2/400 v7r3, which is a complex

Db2 convert rows to columns

﹥>﹥吖頭↗ 提交于 2019-12-13 03:24:30
问题 I need the below results .. Table : Order postcode qnty 123 2234 1 Expected result: Order 123 Postcode 2234 Qnty 1 SQL server: Select pvt.element_name ,pvt.element_value(select order.postcode from table name)up unpivot (element_value for element_name in(order,postcode) as Pvt How to achieve this in db2? 回答1: Db2 for IBM i doesn't have a built-in unpviot function.. AFAIK, it's not available on any Db2 platofrm...unless it's been added recently. The straight forward method select 'ORDER' as key

DB2/400 Alternative to Opening a Cursor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 01:08:09
问题 I'm running DB2 for i, V7R2 TR3. I was told opening a cursor provides a lot of overhead and should be avoided whenever possible. From what I've read, using EXECUTE INTO var1 USING var2 is an alternative, but I can't get it working. I am getting a SQL0104 error. This is my Stored Procedure: BEGIN DECLARE STMT1 VARCHAR ( 500 ) ; SET STMT1 = 'SELECT SUBSTR (''' || TRIM(ITEM) || ''' , ( LENGTH ( TRIM ( PREFIX ) ) + 1 ) , ( 20 - LENGTH ( TRIM ( PREFIX ) ) ) ) ' || 'FROM MYLIB.MYTABLE ' || 'WHERE

Using SQL with IBM_DB connector in Python

一个人想着一个人 提交于 2019-12-12 16:34:15
问题 Has anyone used the ibm_db package with IBM's Python for PASE to update Db2 files on IBM i (formerly AS/400)? I want to use Python scripts (from QSH) to update the Db2 database. My purpose is to populate values at runtime and update the fields of Db2 files. It works with static (hardcoded) values, but not dynamic ones. Here is what I am trying, but it is not working: import ibm_db c1 = ibm_db.connect('*LOCAL','userid','password') sql = """INSERT INTO TEMPLIB.TEMPPF (TYPE, DRPARTY, CRPARTY,

DB2 - Argument 02 of function TRANSLATE not valid

走远了吗. 提交于 2019-12-12 03:46:58
问题 I am having some issues converting a string (yyyymmddhhiiss) to a date using TRANSLATE. If I use a string directly then it works perfectly fine, but when i use a field of exactly same datatype, varchar(14), then it throws the error from the title. Here is a basic example of what i am trying to do: WITH test_table AS ( SELECT '20160101123059' AS d FROM SYSIBM.SYSDUMMY1 ) SELECT d , translate('ABCD-EF-GH IJ:KL:MN', d, 'ABCDEFGHIJKLMN') , translate('ABCD-EF-GH IJ:KL:MN', '20160101123059',

Declare temp table inside UserDefined Function in DB2 AS400

天涯浪子 提交于 2019-12-12 03:45:20
问题 How to create user defined function with declare temporary table in AS400? I can't create a temporary table under parent procedure, because i'm using Parallel Jobs. So i need to create temporary table inside function only helps me. Did anybody knows the solution, kindly update here friends. 回答1: example of temporary table : DECLARE GLOBAL TEMPORARY TABLE nametemporarychoice AS ( YOURQUERYHERE ) WITH DATA WITH REPLACE NOT LOGGED; you can use your table like this: select * from qtemp

Use of function TIMESTAMP_FORMAT in QSYS2 not valid. Data mapping error on member

社会主义新天地 提交于 2019-12-11 17:18:47
问题 I am very new in iseries/DB2. We use V7R3. We have table that is generated every day by RPG program as physical file. For accessing the table data from java we use jt400.jar jdbc driver. Most of the table queries work fine but some complex queries that are using "DENSE_RANK() OVER(ORDER BY" and "ROW_NUMBER() OVER(PARTITION BY" time to time hanging and causing CPU 100%. only killing the job on AS400 side is resolving the issue. in the AS400 log I see: Job 969954/QUSER/QZDASOINIT started on 02