last_insert_id failing for table name with double quotes

[email protected] (Joseph Boakye) Wed, 10 Nov 2021 14:40:52 +0000
Newsgroups perl.dbd.pg
Message-ID <DM6PR04MB709720D7651ED6D33D24C5FABE939@DM6PR04MB7097.namprd04.prod.outlook.com>
--_000_DM6PR04MB709720D7651ED6D33D24C5FABE939DM6PR04MB7097namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Good day folks.

Error:
INSERT into " public.best!Tab le@Ever2$%^&()_+{}:'""?/.>,<~ 4" (" (id)$mipu=
blic.lk'","""""''""""2--","not$%^&() _+{}:'""?/.>,<~nice","""""""""3'",""""=
"''""""++") VALUES (?, ?, ?, ?, ?)

DBD::Pg::db last_insert_id failed: Could not find the table " public.best!T=
ab le@Ever2$%^&*()_+{}\:'""?/.>,<~ `4" [for Statement "
SELECT i.indisprimary,
COALESCE(
-- this takes the table name as text, not regclass
pg_catalog.pg_get_serial_sequence(
-- and pre-8.3 doesn't have a cast from regclass to text,
-- and pre-9.3 doesn't have format, so do it the long way
quote_ident(n.nspname) || '.' || quote_ident(c.relname),


---- snip



---------------

The issue seems to be that since I have double quotes in the table name, I =
have to "double up" the double quotes for the insert statement but you folk=
s may need to replace all "" in the table name to " before running your que=
ry.
$table_name_for_query =3D $table_name; $table_name_for_query =3D~ s/["]{2}/=
"/g;

Maybe In Pg.pm?:
my $table_for_query =3D $table;
$table_for_query =3D~ s/["]{2}/"/g;
my @Args<https://github.com/Args> =3D ($table_for_query);
------------------

Thank you in advance for your responses.
Joseph

--_000_DM6PR04MB709720D7651ED6D33D24C5FABE939DM6PR04MB7097namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
<p dir=3D"auto">Good day folks.</p>
<p dir=3D"auto">Error:<br>
INSERT into &quot; public.best!Tab le@Ever2$%^&amp;<em>()_+{}:'&quot;&quot;=
?/.&gt;,&lt;<code>~ </code>4&quot; (&quot; (id)<code>$mipublic.lk'&quot;,&q=
uot;&quot;&quot;&quot;&quot;</code>''&quot;&quot;&quot;&quot;2--&quot;,&quo=
t;not$%^&amp;</em>() _+{}:'&quot;&quot;?/.&gt;,&lt;<code>~nice&quot;,&quot;=
&quot;&quot;&quot;&quot;</code>&quot;&quot;&quot;&quot;3'&quot;,&quot;&quot=
;&quot;&quot;&quot;<code>''&quot;&quot;&quot;&quot;++&quot;) VALUES (?, ?, =
?, ?, ?)</code></p>
<p dir=3D"auto"><code>DBD::Pg::db last_insert_id failed: Could not find the=
 table &quot; public.best!Tab le@Ever2$%^&amp;*()_+{}\:'&quot;&quot;?/.&gt;=
,&lt;</code>~ `4&quot; [for Statement &quot;<br>
SELECT i.indisprimary,<br>
COALESCE(<br>
-- this takes the table name as text, not regclass<br>
pg_catalog.pg_get_serial_sequence(<br>
-- and pre-8.3 doesn't have a cast from regclass to text,<br>
-- and pre-9.3 doesn't have format, so do it the long way<br>
quote_ident(n.nspname) || '.' || quote_ident(c.relname),</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto">---- snip<br>
</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto"><br>
</p>
<p dir=3D"auto">---------------<br>
</p>
<p dir=3D"auto">The issue seems to be that since I have double quotes in th=
e table name, I have to &quot;double up&quot; the double quotes for the ins=
ert statement but you folks may need to replace all &quot;&quot; in the tab=
le name to &quot; before running your query.<br>
$table_name_for_query =3D $table_name; $table_name_for_query =3D~ s/[&quot;=
]{2}/&quot;/g;</p>
<br>
</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
Maybe In Pg.pm?:<br>
my $table_for_query =3D $table;<br>
$table_for_query =3D~ s/[&quot;]{2}/&quot;/g;<br>
my <a class=3D"user-mention" data-hovercard-type=3D"user" data-hovercard-ur=
l=3D"/users/Args/hovercard" data-octo-click=3D"hovercard-link-click" data-o=
cto-dimensions=3D"link_type:self" href=3D"https://github.com/Args">
@Args</a> =3D ($table_for_query);<br>
</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
------------------</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
Thank you in advance for your responses.</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
 color: rgb(0, 0, 0);">
Joseph<br>
</div>
</body>
</html>

--_000_DM6PR04MB709720D7651ED6D33D24C5FABE939DM6PR04MB7097namp_--