Thread: [Gambas-devel] Cannot populate database Connection.Name from ODBC driver.
Brought to you by:
gambas
|
From: zxMarce <d4t...@gm...> - 2017-08-18 00:26:31
|
Hi there. This is mainly intended to be tackled by Benoît, but anyone with the necessary knowledge (Toby?) please feel free to butt in. The ODBC driver can use Connection Strings since some time now. I also have a patched up module that can run successfully non-data-producing queries (the SQL_NO_DATA return code is no longer treated as an error), thanks to a bug submitted by Piccoro. Problem is in the open_database() function. When using connstrings, the database name is usually part of this string, and no .Name property is expected to be populated from the BASIC program, nor actually used. So, I'm trying to populate the property from the ODBC backend. I can successfully fetch the DB Name from the lower level database driver in use (SQLite3 does not provide a name, tho, be warned). What I cannot do, be it via copying char[] or Gambas String buffer pointers, is to get the .Name property populated back to the running BASIC program. The open_database() call has two parameters: DB_DESC *desc and DB_DATABASE *db. My best guess is that I have to fiddle with desc, but not really sure if that's correct nor exactly how. To further salt the issue, queries exist in big RDBMS that allow to hot-switch databases while connected to a server (example: USE <newDBName> in MSSQL). So, the connection's .Name property should also be "refetched" after a successful query is run. Any suggestions? -- View this message in context: http://gambas.8142.n7.nabble.com/Cannot-populate-database-Connection-Name-from-ODBC-driver-tp60002.html Sent from the gambas-devel mailing list archive at Nabble.com. |
|
From: <ada...@gm...> - 2017-08-18 01:12:05
|
On Thu, 17 Aug 2017 17:26:26 -0700 (MST) zxMarce <d4t...@gm...> wrote: > (SQLite3 does not provide a name, tho, be warned). Isn't a sqlite db without a name an "in memory" database? b -- B Bruen <ada...@gn... (sort of)> |
|
From: Benoît M. <ga...@us...> - 2017-08-18 01:25:29
|
Le 18/08/2017 à 02:26, zxMarce a écrit : > Hi there. This is mainly intended to be tackled by Benoît, but anyone with > the necessary knowledge (Toby?) please feel free to butt in. > > The ODBC driver can use Connection Strings since some time now. I also have > a patched up module that can run successfully non-data-producing queries > (the SQL_NO_DATA return code is no longer treated as an error), thanks to a > bug submitted by Piccoro. > > Problem is in the open_database() function. When using connstrings, the > database name is usually part of this string, and no .Name property is > expected to be populated from the BASIC program, nor actually used. > So, I'm trying to populate the property from the ODBC backend. I can > successfully fetch the DB Name from the lower level database driver in use > (SQLite3 does not provide a name, tho, be warned). > What I cannot do, be it via copying char[] or Gambas String buffer pointers, > is to get the .Name property populated back to the running BASIC program. > > The open_database() call has two parameters: DB_DESC *desc and DB_DATABASE > *db. My best guess is that I have to fiddle with desc, but not really sure > if that's correct nor exactly how. > > To further salt the issue, queries exist in big RDBMS that allow to > hot-switch databases while connected to a server (example: USE <newDBName> > in MSSQL). So, the connection's .Name property should also be "refetched" > after a successful query is run. > > Any suggestions? > > The open_database(DB_DESC *desc, DB_DATABASE *db) driver function takes two arguments: - DB_DESC *desc : a pointer to a structure that contains all connections string properties and an integer option field. - DB_DATABASE *db : a pointer to another structure that should be filled with all necessary information about the connection. By modifying the desc fields, you are modifying the corresponding Connection object properties, as this is where they are stored. But you must use GB.FreeString() and GB.NewString() to replace a string property value. For example: const char *new_value; GB.FreeString(&desc->name); // Free the Gambas string containing the old database name desc->name = GB.NewZeroString(new_value); // Create a new Gambas string from the zero-terminated string new_value, and store it. That's it. -- Benoît Minisini |
|
From: PICCORO M. L. <mck...@gm...> - 2017-08-18 07:37:11
|
hi zxMarce and other, i want to mark a WARNING here.. as i can see too many experience with mososoft SQL and must be some notes about some other scalar HIGH DBMS.. sybase DOES NOT NEED A DB NAME TO HAVE A CONNECTION ! be warning: its not like sqlite that a db "in memory" are present at least, here theres no connection, in same way db2 and oracle... 2017-08-17 21:25 GMT-04:00 Benoît Minisini via Gambas-devel <gam...@li...>: > const char *new_value; > > GB.FreeString(&desc->name); // Free the Gambas string containing the old > database name > > desc->name = GB.NewZeroString(new_value); // Create a new Gambas string from > the zero-terminated string new_value, and store it. its great that can be changed the connection db on the fly for the module.. its mandatory.. ok ODBC need! a connection db name when Established, but its only with UnixODBC.. there's more "special behaviours" * in same "host connection name" there are also "same many db names" that its not the same as "in same host are many db names served" that strange behaviour are applied to oralce and sybase, that runs "a instance" of the software for "one or more than" databases... in the same host.. due that PROPIETARY ODBC SOFTWARE CAN OFFERS A CONNECTION TO GAMBAS WITHOUT A DATABASE VALID STRUCTURE, or a "empty valid connection" in conclusion.. or more rare as succed to me, a connection but the db are not the spected (due UnixODBC freedts can connect to a one db per host at same time, as all here knowed. but it not limited to in real ysbae or oracle) > > That's it. > > -- > Benoît Minisini > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-devel mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gambas-devel |
|
From: ML <d4t...@gm...> - 2017-08-18 11:22:53
|
Benoît, Thanks a ton. It looks way easier than I tried/thought... As usual. Piccoro, First off, I always default my examples to MSSQL because I work with them, for good or bad. That's mainly what I have to try/test things from Gambas. But a single MySQL server -which is mostly free ($$$) IIRC- can also be home to more than one DB/Catalog. Others may or may not follow suit. Never tried Sybase, DB/2, or Oracle because I don't have access to either. I rely on users to report inconsistencies like I had for Firebird regarding RecordCount. Never mind RDBMS that don't have a DB Name. The interface should be as wide/general as possible, and if at least one of them uses or can switch DB/Catalog names, then I think it should be supported. Actually, SQLite3 (the one I do have at home, with your supplied example of "CREATE IF NOT EXIST Tabla1...") fails to retrieve at least the DB filename (test.sq3) as the Database/Catalog name. That particular DB is a file, so I guess the driver should retrieve *something* as DB Name but it does not, confusing everybody into thinking it's an in-memory DB. On the other hand, connstrings handle instances -at least with MSSQL- transparently by specifying the instance in the server name, and this is separate from the DB name. So you can have any mix-n-match of servers, instances, and DBs, given every server/instance has its own connection object. Then you can switch DBs/Catalogs inside each Connection by running MSSQL's USE (or the applicable RDBMS-specific) query command. Regards, zxMarce. On 18/08/17 04:37, PICCORO McKAY Lenz wrote: > hi zxMarce and other, i want to mark a WARNING here.. as i can see too > many experience with mososoft SQL and must be some notes about some > other scalar HIGH DBMS.. > sybase DOES NOT NEED A DB NAME TO HAVE A CONNECTION ! > be warning: its not like sqlite that a db "in memory" are present at > least, here theres no connection, in same way db2 and oracle... > > 2017-08-17 21:25 GMT-04:00 Benoît Minisini via Gambas-devel > <gam...@li...>: >> const char *new_value; >> GB.FreeString(&desc->name); // Free the Gambas string containing the >> old database name >> desc->name = GB.NewZeroString(new_value); // Create a new Gambas >> string from the zero-terminated string new_value, and store it. > its great that can be changed the connection db on the fly for the > module.. its mandatory.. > ok ODBC need! a connection db name when Established, but its only with > UnixODBC.. there's more "special behaviours" in same "host connection > name" there are also "same many db names" that its not the same as "in > same host are many db names served" > that strange behaviour are applied to oralce and sybase, that runs "a > instance" of the software for "one or more than" databases... in the > same host.. > due that PROPIETARY ODBC SOFTWARE CAN OFFERS A CONNECTION TO GAMBAS > WITHOUT A DATABASE VALID STRUCTURE, or a "empty valid connection" in > conclusion.. or more rare as succed to me, a connection but the db are > not the spected (due UnixODBC freedts can connect to a one db per host > at same time, as all here knowed. but it not limited to in real ysbae > or oracle) >> That's it. >> -- >> Benoît Minisini |
|
From: PICCORO M. L. <mck...@gm...> - 2017-08-18 12:39:35
|
2017-08-18 7:22 GMT-04:00 ML <d4t...@gm...>: > of "CREATE IF NOT EXIST Tabla1...") fails to retrieve at least the DB > filename (test.sq3) as the Database/Catalog name. > That particular DB is a file, so I guess the driver should retrieve > *something* as DB Name but it does not, confusing everybody into that's the behaviour that i try to explain... DBMS connection "intance" dont have to handle a db "instance" that's behaviour its copied from M$ in mysql and postgres but DBMS in the connections dont must handle a db "instance" and that's correct... but ODBC M$ especifications said that must.. this king of "rare" conflicts its common in documents where M$ are involved! |
|
From: Benoît M. <ga...@us...> - 2017-08-18 12:51:27
|
Le 18/08/2017 à 14:39, PICCORO McKAY Lenz a écrit : > > that's the behaviour that i try to explain... DBMS connection "intance" > dont have to handle a db "instance" that's behaviour its copied from M$ > in mysql and postgres but DBMS in the connections dont must handle a db > "instance" and that's correct... but ODBC M$ especifications said that > must.. this king of "rare" conflicts its common in documents where M$ > are involved! > I have no idea what you try to tell us, your english is absolutely unreadable. Please try to make some effort! Can't you, at least, install an english spelling checker on your mail client or your browser? It would be a good start. As for the grammar, I don't know if there is a grammatical corrector for english on Linux. Regards, -- Benoît Minisini |
|
From: PICCORO M. L. <mck...@gm...> - 2017-08-18 15:14:22
|
umm okok, write in the browser event in the console: 2017-08-18 7:22 GMT-04:01 ML <d4t...@gm...>: > of "CREATE IF NOT EXIST Tabla1...") fails to retrieve at least the DB > filename (test.sq3) as the Database/Catalog name. > That particular DB is a file, so I guess the driver should retrieve > *something* as DB Name but it does not, confusing everybody into that's the behaviour that i try to explain... a DBMS connection "instance" don't have to handle a db "instance", that's behaviour found on DBMS's such like postgres or mysql inherits from the "M$" era but are not mandatory... but in many propietary DBMS the connections dont "must handle" a db "instance" and that's correct... in some place the ODBC especification said that a db name must be provided, but mayor DBMS dont need a db name provided, that's behaviour are found commonly in Oracle, Firebird, Sybase, SAP and many other, almost all the propietary DBMS do in this way... Lenz McKAY Gerardo (PICCORO) http://qgqlochekone.blogspot.com 2017-08-18 8:51 GMT-04:00 Benoît Minisini <ga...@us...>: > Le 18/08/2017 à 14:39, PICCORO McKAY Lenz a écrit : > >> >> that's the behaviour that i try to explain... DBMS connection "intance" >> dont have to handle a db "instance" that's behaviour its copied from M$ in >> mysql and postgres but DBMS in the connections dont must handle a db >> "instance" and that's correct... but ODBC M$ especifications said that >> must.. this king of "rare" conflicts its common in documents where M$ are >> involved! >> >> > I have no idea what you try to tell us, your english is absolutely > unreadable. > > Please try to make some effort! > > Can't you, at least, install an english spelling checker on your mail > client or your browser? It would be a good start. > > As for the grammar, I don't know if there is a grammatical corrector for > english on Linux. > > Regards, > > -- > Benoît Minisini > |