Oracle

Bind OCI sysdate() to PDO parameter?

社会主义新天地 提交于 2021-01-28 04:42:42
问题 I want to bind sysdate function in my PDO prepared query : $db = new PDO('oci:dbname=database;charset=UTF8', 'user', 'pass'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $query = $db->prepare('SELECT :func FROM DUAL'); $query->execute(array(':func' => 'SYSDATE()')); var_dump($query->fetch()); The result return this : array (size=2) ':FUNC' => string 'SYSDATE()' (length=9) 0 => string 'SYSDATE()' (length=9) I want to get the system date of my oracle database. Is it possible ?

behavior of inner join inside exists sql

主宰稳场 提交于 2021-01-28 04:33:58
问题 let's say that there're 2 tables (in oracle SQL) like this: user(user_id, company_id): 123 | company_id_1 | 123 | company_id_2 | company(id, version_id): company_id_1 | (null) | company_id_2 | version_id1 | the following query returns 2 rows company_id_1 company_id_2 SELECT distinct(company_id) FROM user WHERE user.user_id = 123 AND user.company_id IS NOT NULL AND EXISTS (SELECT 1 FROM company INNER JOIN user ON company.id = user.company_id AND company.version_id IS NOT NULL); I would expect

behavior of inner join inside exists sql

依然范特西╮ 提交于 2021-01-28 04:31:40
问题 let's say that there're 2 tables (in oracle SQL) like this: user(user_id, company_id): 123 | company_id_1 | 123 | company_id_2 | company(id, version_id): company_id_1 | (null) | company_id_2 | version_id1 | the following query returns 2 rows company_id_1 company_id_2 SELECT distinct(company_id) FROM user WHERE user.user_id = 123 AND user.company_id IS NOT NULL AND EXISTS (SELECT 1 FROM company INNER JOIN user ON company.id = user.company_id AND company.version_id IS NOT NULL); I would expect

POSTMAN is returning date fields with changed values

為{幸葍}努か 提交于 2021-01-28 04:21:01
问题 I am consuming a REST service and I am receiving a JSON with date attributes that do not match what is in my database. I have two fields called "initialDate" and "finalDate". In the database they are like this: 07/MAR/19 00:00:00 07/SEP/19 23:59:59 The database timezone: select dbtimezone from dual; +00:00 In my object, inside the Java class, the content of the attributes comes as: public class Klass { @NotNull private Date initialDate; //initialDate.toString() "Thu Mar 07 00:00:00 CLT 2019"

DBMS_PARALLEL_EXECUTE and indirectly given grants on procedure

落爺英雄遲暮 提交于 2021-01-28 04:00:50
问题 I just bumped into some strange behaviour of DBMS_PARALLEL_EXECUTE (at least for me). See my preset (executed as SYS): -- Preset drop user usr1 cascade; create user usr1 identified by usr1; create or replace procedure usr1.do_stuff(p1 in number, p2 in number) is begin dbms_output.put_line('I did stuff!'); end; / drop user usr2 cascade; create user usr2 identified by usr2; grant connect to usr2; grant create job to usr2; drop role stuff_doer cascade; create role stuff_doer; grant execute on

Creating a spatial index on oracle

♀尐吖头ヾ 提交于 2021-01-28 04:00:21
问题 I have a table 'floating_options', and I want to create a spatial index on a column 'area_geo' (which is a sdo_geometry column, with two rows of data that appear as expected when I select * from floating_options). I have used the following code but I am receiving the error below. I would be very grateful for any help! Thanks! CREATE INDEX area_idx ON floating_options(area_geo) INDEXTYPE IS MDSYS.SPATIAL_INDEX; Error report - SQL Error: ORA-29855: error occurred in the execution of

ORACLE 12.2.01 selecting columns from different tables with similar names --> internal column identifier used

眉间皱痕 提交于 2021-01-28 03:50:49
问题 I wrote a SELECT performing a UNION and in each UNION part using some JOINs. The tables, which are joined have partly the same column identifiers. And if a "SELECT *" is performed, ORACLE decides to display the internal column names instead of the "real" column names. To show the effect I created two tables (with partly similar column identifiers, "TID" and "TNAME") and filled them with some data: create table table_one (tid number(10), tname varchar2(10), t2id number(10)); create table table

Connecting Oracle using unixODBC: Can't open lib '/usr/lib/oracle/12.1/client/lib/libsqora.so.12.1'

走远了吗. 提交于 2021-01-28 03:41:30
问题 I am trying to connect to Oracle using unixODBC but it doesn't work. So far I have tried to follow How do I setup Oracle ODBC drivers on RHEL 6/Linux . When I try to connect using isql I get following: user@user:~$ isql -v oracle-jono [01000][unixODBC][Driver Manager]Can't open lib '/usr/lib/oracle/12.1/client/lib/libsqora.so.12.1' : file not found [ISQL]ERROR: Could not SQLConnect I have checked that /usr/lib/oracle/12.1/client/lib/libsqora.so.12.1 exists. When I run ldd command it says that

DBMS_PARALLEL_EXECUTE and indirectly given grants on procedure

孤者浪人 提交于 2021-01-28 03:23:28
问题 I just bumped into some strange behaviour of DBMS_PARALLEL_EXECUTE (at least for me). See my preset (executed as SYS): -- Preset drop user usr1 cascade; create user usr1 identified by usr1; create or replace procedure usr1.do_stuff(p1 in number, p2 in number) is begin dbms_output.put_line('I did stuff!'); end; / drop user usr2 cascade; create user usr2 identified by usr2; grant connect to usr2; grant create job to usr2; drop role stuff_doer cascade; create role stuff_doer; grant execute on

Oracle Function to return similarity between strings

梦想的初衷 提交于 2021-01-28 03:09:23
问题 I have an interesting problem and am wondering if oracle has a built-in function to do this or I need to find a fast way to do it in plsql. Take 2 strings: s1 = 'abc def hijk' s2 = 'abc def iosk' The function needs to return abc def because the strings are exactly the same up to that point. Another example: s1 = 'abc def hijk www' s2 = 'abc def iosk www' The function needs to return abc def . The only way I can think of doing this is loop through string1 and compare each character with substr