Missing function sqlite3_column_index

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Missing function sqlite3_column_index

Sebastian
Hi,
for sqlite3_bind_parameter_name there is an inverse function sqlite3_bind_parameter_index.
But for sqlite3_column_name, I could not find such a function.

Is it missing by intention, in order not to tempt users to call it once per row, which would be inefficient?
(In that case, why not just mention that in the documentation?)


Sebastian
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Missing function sqlite3_column_index

Igor Tandetnik-2
On 9/2/2018 10:13 AM, Sebastian wrote:
> for sqlite3_bind_parameter_name there is an inverse function sqlite3_bind_parameter_index.
> But for sqlite3_column_name, I could not find such a function.

Column names may not be unique, or meaningful. E.g.

select a, a, 1+2 from mytable;

--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Missing function sqlite3_column_index

Hick Gunter
In reply to this post by Sebastian
The name of an output column is not even defined, much less unique, unless the author of the statement has done extra work (using unique column names and/or AS clauses).

Consider

Select a.*,b.*,c.* ...

Where each table has a column named Id. Which index would you like to have returned?

-----Urspr√ľngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Sebastian
Gesendet: Sonntag, 02. September 2018 16:14
An: [hidden email]
Betreff: [EXTERNAL] [sqlite] Missing function sqlite3_column_index

Hi,
for sqlite3_bind_parameter_name there is an inverse function sqlite3_bind_parameter_index.
But for sqlite3_column_name, I could not find such a function.

Is it missing by intention, in order not to tempt users to call it once per row, which would be inefficient?
(In that case, why not just mention that in the documentation?)


Sebastian
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Missing function sqlite3_column_index

Sebastian
In reply to this post by Sebastian
I am aware that this function would only work reliably if you use AS clauses. But that's what I intend to do, so no problem. Sorry for not having mentioned that.

So is this the reason that the function doesn't exist? That it needs AS clauses to be useful?
Or the efficiency pitfall I suspected?
Or both?
Or something else?

No big problem, I can work with sqlite3_column_name. It would just have been more convenient to have the reverse function, too.

Sebastian

On Mon, 3 Sep 2018 07:27:23 +0000
Hick Gunter <[hidden email]> wrote:

> The name of an output column is not even defined, much less unique, unless the author of the statement has done extra work (using unique column names and/or AS clauses).
>
> Consider
>
> Select a.*,b.*,c.* ...
>
> Where each table has a column named Id. Which index would you like to have returned?
>
> -----Urspr√ľngliche Nachricht-----
> Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Sebastian
> Gesendet: Sonntag, 02. September 2018 16:14
> An: [hidden email]
> Betreff: [EXTERNAL] [sqlite] Missing function sqlite3_column_index
>
> Hi,
> for sqlite3_bind_parameter_name there is an inverse function sqlite3_bind_parameter_index.
> But for sqlite3_column_name, I could not find such a function.
>
> Is it missing by intention, in order not to tempt users to call it once per row, which would be inefficient?
> (In that case, why not just mention that in the documentation?)
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Missing function sqlite3_column_index

Simon Slavin-3
On 3 Sep 2018, at 6:15pm, Sebastian <[hidden email]> wrote:

> So is this the reason that the function doesn't exist? That it needs AS clauses to be useful?

More likely, that it is not needed by SQLite itself.  sqlite3_column_name() is used inside SQLite, but there's no need for your proposed function.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users