Oracle

how to make a connection string for oracle that includes hostname, instance name, user id, password using system.data.oracleclient?

僤鯓⒐⒋嵵緔 提交于 2021-02-08 11:23:19
问题 I have made a connection string in oracle like: Data Source=hostname;Initial Catalog=IMPORT_UTILITY;User ID=abc;password=123 I want to make the same for oracle. I am using ODBC . can anyone tell me what will be the connection string for oracle that will be equivalent to above sql connection string using odbc? 回答1: For Oracle 12c R2 and the Instant Client ODBC Driver (version 12.2.0.1.0) the following connection string should work without having to create a DSN and/or a tnsnames.ora file:

Oracle select mutual sub string

喜你入骨 提交于 2021-02-08 11:19:29
问题 I would like to return new table in ORACLE where all rows that have same the values in 'col' columns group together and the 'description' column will contain only the mutual sub strings when the different characters will replaced by '...' how can I do that? May i get your help please? Basic code to start with: SELECT col,description FROM table group by col; Example 1: col description 1 Today is 1 Today is a good day 1 Today is perfect day 2 Hello world 2 Hello results: col description 1 Today

Oracle using dynamic sql when table name is a parameter

做~自己de王妃 提交于 2021-02-08 11:01:33
问题 I have a SQL query (a store procedure ) that i want to convert to PLSQL I already conver most of the store procedure but i cant convert the following part : DECLARE lookupTableRow CURSOR FOR SELECT TableName FROM SYS_LookUpTable OPEN lookupTableRow FETCH NEXT FROM lookupTableRow INTO @tableName WHILE @@FETCH_STATUS=0 BEGIN SET @sql='SELECT * FROM '+@tableName EXECUTE sp_executesql @sql IF @counter=0 BEGIN INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName) END ELSE

Oracle using dynamic sql when table name is a parameter

强颜欢笑 提交于 2021-02-08 11:00:57
问题 I have a SQL query (a store procedure ) that i want to convert to PLSQL I already conver most of the store procedure but i cant convert the following part : DECLARE lookupTableRow CURSOR FOR SELECT TableName FROM SYS_LookUpTable OPEN lookupTableRow FETCH NEXT FROM lookupTableRow INTO @tableName WHILE @@FETCH_STATUS=0 BEGIN SET @sql='SELECT * FROM '+@tableName EXECUTE sp_executesql @sql IF @counter=0 BEGIN INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName) END ELSE

Why PLS-00382: expression is of wrong type?

半世苍凉 提交于 2021-02-08 10:59:55
问题 I have the following custom RECORD TYPE : TYPE TB48_RECTYPE IS RECORD ( codpo varchar2(5 BYTE), codco varchar2(5 BYTE), quadr varchar2(5 BYTE), espec varchar2(5 BYTE), aperf varchar2(5 BYTE), subes varchar2(5 BYTE), datin date); And now a function that returns the exact same type. function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is retorno_REC TB48_RECTYPE; begin select m.CODPO, m.CODCO, m.QUADR, m.ESPEC, m.APERF, m.SUBES, m.DATIN into retorno_REC from TB48_M m where m

Oracle using dynamic sql when table name is a parameter

岁酱吖の 提交于 2021-02-08 10:59:23
问题 I have a SQL query (a store procedure ) that i want to convert to PLSQL I already conver most of the store procedure but i cant convert the following part : DECLARE lookupTableRow CURSOR FOR SELECT TableName FROM SYS_LookUpTable OPEN lookupTableRow FETCH NEXT FROM lookupTableRow INTO @tableName WHILE @@FETCH_STATUS=0 BEGIN SET @sql='SELECT * FROM '+@tableName EXECUTE sp_executesql @sql IF @counter=0 BEGIN INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName) END ELSE

Why PLS-00382: expression is of wrong type?

*爱你&永不变心* 提交于 2021-02-08 10:57:17
问题 I have the following custom RECORD TYPE : TYPE TB48_RECTYPE IS RECORD ( codpo varchar2(5 BYTE), codco varchar2(5 BYTE), quadr varchar2(5 BYTE), espec varchar2(5 BYTE), aperf varchar2(5 BYTE), subes varchar2(5 BYTE), datin date); And now a function that returns the exact same type. function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is retorno_REC TB48_RECTYPE; begin select m.CODPO, m.CODCO, m.QUADR, m.ESPEC, m.APERF, m.SUBES, m.DATIN into retorno_REC from TB48_M m where m

How do I convert an oracle timestamp value from UTC to EST in a select statement?

自古美人都是妖i 提交于 2021-02-08 10:41:21
问题 Hi I have a date field (Open_Time) containing timestamp data. The times in this column are in UTC. I want to select that column and convert it to EST and insert it into another table. I want it to be EST for the time at the original timestamp (take into account daylight savings time based on what day month and year it was). I have been reading about the various timezone functions in oracle but most seem to focus on altering the database's timezone which I don't need to do. The (Open_Time)

sql plus output is not coming in proper CSV format if we use the colsep ,

怎甘沉沦 提交于 2021-02-08 10:25:21
问题 The issue i am facing is that even the data in the CSV file also getting separated if the value consists of , (comma) I am using shell script connect to oracle using the sql plus and spooling the data in the CSV file In the CSV the colsep , (comma) is working fine to separate columns but the data also getting separated. for example if the value of the company name is (Southern textiles,LICO ) In that case even SOuttheren textiles is in one column and LICO is moving to another column and thee

Iterating through PL/SQL result in SHELL

主宰稳场 提交于 2021-02-08 10:21:06
问题 I want to iterate over PL/SQL rows in SHELL script and for each row I want to execute some code using current row. At this point I got: VALUE='sqlplus -s /nolog <<EOF CONNECT ${CONNECT} select smth from table; / EXIT EOF' for i in "${VALUE[@]}" do ##some code using "i" variable done At this point for 5 rows code executes only once. It appears it doesn't iterate at all. Any ideas how can I fix that? 回答1: You can iterate your resultset as follows: SQL> select car_model from available_models 2