SQL Query on PostgreSQL:
insert into TOKEPOOLAMT (TOKEPOOLAMT.TOKEPOOLAMTID,TOKEPOOLAMT.TOKERULEID)
values (151, 176);
Giving error:
com.edb.util.PSQLException:
ERROR: column "tokepoolamt" of relation "tokepoolamt" does not exist
But:
insert into TOKEPOOLAMT (TOKEPOOLAMTID,TOKERULEID) values (151, 176);
is working fine.
Can anybody explain why alias name with column in insert statement not working?
There are no aliases involved here. Your error is that column names in the column list of an INSERT command cannot be table-qualified. #pozs already provided the fitting quote from the manual in his comment.
I don't think it's an issue of case. I tried with both the cases.
That's missing the point. In Postgres, identifiers are folded to lower case unless double-quoted. If you double-quoted a name at creation time you preserved a case sensitive spelling and need to double-quote for the rest of the object's life - unless it was a legal, lower-case name to begin with, then quoting won't make a difference. Details:
Are PostgreSQL column names case-sensitive?
Related
Source for the Informatica Cloud is of type DB2 for I cdc. There are few tables that contain # in their column names. If the mapping was run with a column name containing # in the name then the mapping fails.
Example : If there is an Employee table with the column First#Name then used SQL Override
So to eliminate # from the column name tried using SQL Override to alias the column name.
Used a select statement that contains a column list for the same table. Sample SQL statement for the same:
Select First#Name as First_Name
Last#Name as Last_Name
.
.
.
.
.
.
.
Employee;
But still, the column name is being fetched with a # symbol and this is breaking the mapping.
Any solution how the # can be aliased _ in the column name?
You have two options -
You can enclose column names with double uotes "col_name".
Select "First#Name" as First_Name
"Last#Name" as Last_Name
.
Employee;
If this doesnt solve the issue, please do not mention any sql override and connect only required columns. Informatica should automatically built sql and fetch data.
If above two doesnt work, then you need to change some settings in DB2 so as to handle the special char in column name. I have not tested this so i can not gurantee this.
Select First#Name AS First_Name,Last#Name AS Last_Name,Column3,Column4,Column5,Column6,Column7,Column8 FROM Employee;
The SQL query should be in such a way that there are no spaces except when required and the entire query should be present in a single line.
Remove all the spaces (Except the below mentioned ones) and new line characters from the query. That will solve the issue.
Where spaces can be left over:
After the SELECT statement
Before the FROM keyword
After the FROM keyword
Before and after the AS keyword when aliasing the columns that have special characters (Here 2 spaces will be utilized, one before the AS keyword and second after the AS keyword)
I have a postgres table with two columns (an identificator and a date) that are a composite primary key. I would like to hash the concatenation in another column, generating this value everytime a new record is inserted. For that I'm trying to alter my table in order to create a generated column:
ALTER TABLE my_table ADD COLUMN hash_id_date VARCHAR(50)
GENERATED ALWAYS AS (MD5(my_table.original_id||'-'||my_table.time))
STORED;
This raises me the following error:
ERROR: syntax error at or near "("
LINE 4: GENERATED ALWAYS AS (MD5(my_table.original_id,'-',my_table.t...
^
SQL state: 42601
Character: 178
I'm turning into madness to find where is the syntax error... I've read about STABLE and IMMUTABLE functions and generated columns should always have an IMMUTABLE function as expression. As far as I know MD5 is IMMUTABLE but the error message is not even capable to reach that level.
Any help?
Assuming the basic functionality for calculating the MD5 is common you can create a function for the calculation. Use this function wherever it's needed, including updating your current rows and invoke from a trigger on yo your table. If the particular MD5 calculation is not all that common you can just put the calculation in the trigger function and also use it in a independent update for current rows. See here for example with assumption it is common in your app.
This works fine;
<targets>
<target name="database" xsi:type="Database"
dbProvider="Npgsql.NpgsqlConnection, Npgsql"
connectionString="User ID=postgres;Password=xxx;Host=192.xx;Port=5432;Database=xxx;">
<!--Pooling=true;-->
<commandText>
insert into systemlogs(...;
</commandText>
But when changed to table name as
"SystemLogs"
(same done in database as well) it throws exception;
"couldnt find table name "systemlogs"
which make sense there isnt but why nlog dont realize updated table name?
In PostgreSQL all quoted identifiers (e.g. table and column names) are case sensitive:
See: Are PostgreSQL column names case-sensitive?
So NLog can't find them is you use quotes and the wrong casing.
So don't use quotes or use the correct casing
If you specified the table name as "SystemLogs" inside double quotes then you will need to use it that way also:
insert into "SystemLogs" ...
In Postgresql quoted identifiers retain the case they are quoted with and need to be referred to the same way. If you create as unquoted name SystemLogs then it will be folded to lower case. See below for more detail:
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
I'm programatically adding data to a PostgreSQL table using Python and psycopg - this is working fine.
Occasionally though, a text value is too long for the containing column, so I get the message:
ERROR: value too long for type character varying(1000)
where the number is the width of the offending column.
Is there a way to determine which column has caused the error? (Aside from comparing each column's length to see whether it is 1000)
Many thanks to #Tometzky, whose comment pointed me in the right direction.
Rather than trying to determine which column caused the problem after the fact, I modified my Python script to ensure that the value was truncated before inserting into the database.
access the table's schema using select column_name, data_type, character_maximum_length from information_schema.columns where table_name='test'
when building the INSERT statement, use the schema definition to identify character fields and truncate if necessary
I don't think there's an easy way.
I tried to set VERBOSITY in psql, as I assumed this would help, but unfortunately not (on 9.4):
psql
\set VERBOSITY verbose
dbname=> create temporary table test (t varchar(5));
CREATE TABLE
dbname=> insert into test values ('123456');
ERROR: 22001: value too long for type character varying(5)
LOCATION: varchar, varchar.c:623
This might be something that warrants discussion on the mailing list, as you are not the only one with this problem.
I am have big problem with Postgresql.
I'm trying to insert record to postgres.
But i had error:
The relation "member_orderinfo2" does not exist. But this table had exist when i'm insert record.
This is my query to insert
insert into "member_orderinfo2"(order_id,slim_code,order_date,customer_order_number,ship_date,deliver_company,deliver_number,deliver_address,product_code,product_name,amount,unit_price,total_cost,order_customer_name,ship_status) values
( '30059078','4170906','20131118','15754727-03直送','0','メーカー直送','','京都府綾部市味方町1京セラコミュニケーションシステム','0996381','RD151-50SN(ジユウリヨウダ','5','5120.00','25600','梶野様','入荷待' )
What is error ???
It looks like case sensitivity issue.
You used a double quotes for table name - "member_orderinfo2" - it means so table have to be named exactly member_orderinfo2 with only lower chars. Double quotes are used for case sensitive identifiers. Usually better don't use it when it is possible - are necessary when used identifier is keyword - so don't use case sensitive identifiers and don't use keywords as identifiers.