netezza

Multiple-step OLE DB operation generated errors

我是研究僧i 提交于 2019-12-10 19:55:40
问题 I am running a simple FillSchema from a Netezza data source dss = new DataSet(); ad = new OleDbDataAdapter(cmd); ad.SelectCommand = new OleDbCommand("SELECT * FROM " + objTable.name); ad.SelectCommand.Connection = cn; ad.FillSchema(dss, SchemaType.Source); I get the following error: System.Data.OleDb.OleDbException: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. at System.Data.OleDb.OleDbServicesWrapper.GetDataSource

Drop if exists in netezza

无人久伴 提交于 2019-12-10 17:23:15
问题 I need a command to delete a table if that exists in NETEZZA , Something like that: drop table if exists xxx; I have searched and tried many but it didn't work. Can you help me here? 回答1: In netezza you can use this syntax: drop table table_name if exists; 回答2: There is nothing built-in, but you can create a stored proc which uses the catalog views to check if the table exists before attempting to drop it: create or replace procedure maybe_drop(varchar(128)) returns boolean language nzplsql

Netezza Sql query

无人久伴 提交于 2019-12-10 14:44:53
问题 I have a list of tables in a Netezza database and I want to get the name of primary key for each of the tables. Can anyone provide me the query. 回答1: You can use this query. SELECT * FROM _v_relation_keydata; 回答2: There is nothing sort of Primary Key thing in Netezza. If you want to look at the NULL or NOT NULL constraints for your required table you can enter the below commands from your nzsql command line \d [YOURTABLENAME] 回答3: SELECT database , schema , constraintname , relation as

In Netezza I'm trying to use a sequence in a case statement but the sequence value doesn't increment

二次信任 提交于 2019-12-10 13:55:29
问题 Here is the sequence creation syntax used: CREATE SEQUENCE BD_ID_SEQ AS INTEGER START WITH 999 INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE; I have a table with the following values records: b_id ------- 2547 NULL 2800 NULL NULL NULL NULL I run the following: select case when b_id is NULL then cast((select next value for bd_id_seq) as character varying(10)) else b_id end b_id from table1; The result comes to: b_id ------- 2547 1000 2800 1000 1000 1000 1000 I was expecting: 2547 1000 2800

SQL fill null values for a field in multiple rows as previous non null value

百般思念 提交于 2019-12-10 10:35:50
问题 I have a table in netezza (based on postgresql) like below. I need to create a new table with the NULL values for name to be replaced with value of name for the previous non-null row. table1 id name time value --------------------- 1 john 11:00 324 2 NULL 12:00 645 3 NULL 13:00 324 4 bane 11:00 132 5 NULL 12:00 30 6 NULL 13:00 NULL 7 NULL 14:00 -1 8 zane 11:00 152 9 NULL 12:00 60 10 NULL 13:00 NULL output table name time value --------------------- john 11:00 324 john 12:00 645 john 13:00 324

Python pyodbc connections to IBM Netezza Erroring

天涯浪子 提交于 2019-12-10 03:01:31
问题 So. This issue is almost exactly the same as the one discussed here -- but the fix (such as it is) discussed in that post doesn't fix things for me. I'm trying to use Python 2.7.5 and pyodbc 3.0.7 to connect from an Ubuntu 12.04 64bit machine to an IBM Netezza Database. I'm using unixODBC to handle specifying a DSN. This DSN works beautifully from the isql CLI -- so I know it's configured correctly, and unixODBC is ticking right along. The code is currently dead simple, and easy to reproduce

Insert if not exists else update it in Netezza

帅比萌擦擦* 提交于 2019-12-08 08:07:44
问题 I am having issue using if not exists statement in Netezza. I am trying to check if record is not there first then insert else update the record. I could not find a better way to do this in Netezza. Here is what I have but does not work: IF NOT EXISTS(SELECT ID FROM OLD_TABLE WHERE ID NOT IN (SELECT ID FROM NEW TABLE ) ) INSERT INTO NEW_TABLE (NAME, LOCATION) ELSE UPDATE NEW_TABLE SET NAME = X.NAME FROM (SELECT NAME, LOCATION FROM OLD_TABLE)AS X WHERE X.NAME = NEW_TABLE.NAME 回答1: Assuming you

SQL to get unique rows in Netezza DB

送分小仙女□ 提交于 2019-12-07 16:29:26
问题 I have a table with rows like: id group_name_code 1 999 2 16 3 789 4 999 5 231 6 999 7 349 8 16 9 819 10 999 11 654 But I want output rows like this: id group_name_code 1 999 2 16 3 789 4 231 5 349 6 819 7 654 Will this query help? select id, distinct(group_name_code) from group_table; 回答1: You seem to want: Distinct values for group_name_code and a sequential id ordered by minimum id per set of group_name_code . Netezza has the DISTINCT key word, but not DISTINCT ON () (Postgres feature):

Export data to CSV using nzsql

戏子无情 提交于 2019-12-07 16:11:58
问题 I would like to export data as CSV from netezza. The data consists of millions of lines of records. The data should be within inverted commas and should have ^ as delimiter. Eg: "a"^"b"^"c" 回答1: Whenever you want to export data from Netezza, you will want to use its external tables functionality. If you are exporting to a filesystem mounted locally to the Netezza host, you could use this: CREATE external TABLE '/tmp/test_export.txt' USING (delimiter '^') AS SELECT * FROM test_export; If you

Update using left join in netezza

≯℡__Kan透↙ 提交于 2019-12-07 09:01:13
问题 I need to perform a left join of two tables in netezza during an update. How can i achieve this ? Left join with three tables are working but not with two tables. UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 LEFT JOIN table_3 t3 ON t2.c1=t3.c1 this works but UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 this says like trying to update multiple columns. Thanks, Manirathinam. 回答1: When performing an UPDATE TABLE with a