<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FEDSQL Syntax Problem -- How to Specify the Schema? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/FEDSQL-Syntax-Problem-How-to-Specify-the-Schema/m-p/678267#M204691</link>
    <description>&lt;P&gt;Ah, well, I figured it out.&amp;nbsp; I was on the right track with thinking it was a Libname parameter that would do the job,&amp;nbsp;&lt;STRONG&gt;but&amp;nbsp;&lt;/STRONG&gt;in fact one cannot use a Libname but rather must replace the Libname with a CONN parameter on the Proc FEDSQL statement itself.&amp;nbsp; In fact, one must clear the Libname if one exists or FEDSQL will issue a duplicate definition error.&amp;nbsp; As I suspected, I did have to supply the schema twice, and, while that may sound redundant, it made FEDSQL happy, and my query is now running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		LIBNAME	&lt;EM&gt;OPSI_RSC&lt;/EM&gt;	CLEAR;

		PROC	FEDSQL	CONN="DRIVER=FEDSQL;CONOPTS=((DRIVER=ODBC;
							CONOPTS=(DSN=&amp;amp;DSN;AUTHMECH=3;HOST=&amp;amp;Host;PORT=&amp;amp;Port;
							PROPERTIES={&amp;amp;Queue};PWD=&amp;amp;lPwd_PASSWORD;&lt;STRONG&gt;SCHEMA=&amp;amp;Schema&lt;/STRONG&gt;;
							UID=&amp;amp;SysuserID);CATALOG=&lt;EM&gt;OPSI_RSC&lt;/EM&gt;;&lt;STRONG&gt;SCHEMA=&amp;amp;Schema&lt;/STRONG&gt;))"
							;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that first I clear the corresponding Libname and then replace the Libname with the same information in a CONN statement.&amp;nbsp; The Catalog= parameter in the CONN statement is the equivalent of a Libname.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The schema is listed twice, once in the "inner" CONOPTS and once in the "outer" CONOPTS.&amp;nbsp; The schema must be listed twice when using Authmech 3 type authentication.&amp;nbsp; This is a bit of an oddity in how SAS works, but this work around isn't too bad to code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note:&amp;nbsp; If you need to refer to the Libname again after the Proc FEDSQL step, you must code a second Libname statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 20:43:53 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-08-20T20:43:53Z</dc:date>
    <item>
      <title>FEDSQL Syntax Problem -- How to Specify the Schema?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FEDSQL-Syntax-Problem-How-to-Specify-the-Schema/m-p/677946#M204580</link>
      <description>&lt;P&gt;I'm trying to read a Hive table using FEDSQL.&amp;nbsp; Eventually, I want to join the Hive table to an SQL Server table, but first I need to get the basic Hive query working.&amp;nbsp; I have the Hive query working in regular Proc SQL, but FedSQL complains that I'm not providing the Schema.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the error message from the log:&lt;/P&gt;
&lt;PRE&gt;NOTE: Executing Proc FedSQL
NOTE: FEDSQL: Using libname WORK (engine V9).
NOTE: FEDSQL: Using libname FIN3823 (engine ODBC).
NOTE: FEDSQL: Using libname OPSI_RSC (engine ODBC).
NOTE: FEDSQL: Using libname SASUSER (engine V9).
NOTE: Connection string:
NOTE: DRIVER=FEDSQL;CONOPTS= ( (DRIVER=BASE;CATALOG=WORK;SCHEMA= 
      (NAME=WORK;PRIMARYPATH={X:\saswork\jbarbou3\_TD69644_APSWP2335_\Prc2})); 
      (DRIVER=ODBC;DB=DBSEP3823_FINANCE;UID=_prompt_;PWD=*;CATALOG= (FIN3823=Finance)); (DRIVER=ODBC;CONOPTS= 
      (DSN=OPSI_HIVE_RSC1;AUTHMECH=3;HOST=apvrp69817;PORT=10846;PROPERTIES={mapred.job.queue.name=root.opsictm_q1.dev_sq1};PW
      D=*;&lt;STRONG&gt;SCHEMA=Informatics_Prd&lt;/STRONG&gt;;UID=jbarbou3);CATALOG=OPSI_RSC); (DRIVER=BASE;CATALOG=SASUSER;SCHEMA= 
      (NAME=SASUSER;PRIMARYPATH={X:\sasuser\jbarbou3})))
ERROR: Invalid connection string attribute : SCHEMA is required for this datasource
ERROR: PROC FEDSQL initialization failed.&lt;/PRE&gt;
&lt;P&gt;However, my&amp;nbsp;Libname very much specifies the schema; you can see the schema in the FEDSQL messages in the log excerpt, above.&amp;nbsp; I'm even specifying the schema twice which is a workaround I've used in the past but isn't working here.&amp;nbsp; Here's the Libname:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;**------------------------------------------------------------------------------**;
**	Allocate Hive Database.														**;
**------------------------------------------------------------------------------**;
LIBNAME 	&amp;amp;Lib	ODBC	
	Schema		=	"&amp;amp;Schema"
	NoPrompt	=	"uid=jbarbou3; pwd=&amp;amp;lPwd_PASSWORD;
					host=&amp;amp;host;	dsn=&amp;amp;DSN; 
					schema=&amp;amp;Schema;
					port=&amp;amp;port; authmech=3;
					PROPERTIES=""&amp;amp;Queue"";
					"
					;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The Libname works fine with Proc SQL but works not at all with Proc FedSQL.&amp;nbsp; It's failing during initialization, so it's not the query itself that is causing the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions as to how to re-code the Libname?&amp;nbsp; Any ideas regarding some kind of workaround?&amp;nbsp; Maybe there's an option for FedSQL that I just don't know about?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 05:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FEDSQL-Syntax-Problem-How-to-Specify-the-Schema/m-p/677946#M204580</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-08-20T05:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: FEDSQL Syntax Problem -- How to Specify the Schema?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FEDSQL-Syntax-Problem-How-to-Specify-the-Schema/m-p/678267#M204691</link>
      <description>&lt;P&gt;Ah, well, I figured it out.&amp;nbsp; I was on the right track with thinking it was a Libname parameter that would do the job,&amp;nbsp;&lt;STRONG&gt;but&amp;nbsp;&lt;/STRONG&gt;in fact one cannot use a Libname but rather must replace the Libname with a CONN parameter on the Proc FEDSQL statement itself.&amp;nbsp; In fact, one must clear the Libname if one exists or FEDSQL will issue a duplicate definition error.&amp;nbsp; As I suspected, I did have to supply the schema twice, and, while that may sound redundant, it made FEDSQL happy, and my query is now running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		LIBNAME	&lt;EM&gt;OPSI_RSC&lt;/EM&gt;	CLEAR;

		PROC	FEDSQL	CONN="DRIVER=FEDSQL;CONOPTS=((DRIVER=ODBC;
							CONOPTS=(DSN=&amp;amp;DSN;AUTHMECH=3;HOST=&amp;amp;Host;PORT=&amp;amp;Port;
							PROPERTIES={&amp;amp;Queue};PWD=&amp;amp;lPwd_PASSWORD;&lt;STRONG&gt;SCHEMA=&amp;amp;Schema&lt;/STRONG&gt;;
							UID=&amp;amp;SysuserID);CATALOG=&lt;EM&gt;OPSI_RSC&lt;/EM&gt;;&lt;STRONG&gt;SCHEMA=&amp;amp;Schema&lt;/STRONG&gt;))"
							;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that first I clear the corresponding Libname and then replace the Libname with the same information in a CONN statement.&amp;nbsp; The Catalog= parameter in the CONN statement is the equivalent of a Libname.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The schema is listed twice, once in the "inner" CONOPTS and once in the "outer" CONOPTS.&amp;nbsp; The schema must be listed twice when using Authmech 3 type authentication.&amp;nbsp; This is a bit of an oddity in how SAS works, but this work around isn't too bad to code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note:&amp;nbsp; If you need to refer to the Libname again after the Proc FEDSQL step, you must code a second Libname statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 20:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FEDSQL-Syntax-Problem-How-to-Specify-the-Schema/m-p/678267#M204691</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-08-20T20:43:53Z</dc:date>
    </item>
  </channel>
</rss>

