Esempio n. 1
0
i4
IIUIdml()
{
	if ( IIUIdbdata()->dmldef == UI_DML_NOLEVEL )
	{
		i4	deflt,	/* default */
   			avail;  /* available DMLs */
		i4	level;

		/* See what languages are authorized */
		FEdml(&deflt, &avail);

		/*
		** Determine the default language.
		**
		**	Always check for SQL first, which will then be the
		**	default even if QUEL is available.  If neither DML
		**	is authorized, check the DBMS as well.  This is to
		**	take care of any potential non-fatal errors with the
		**	authorization string.
		*/

		if ( avail == FEDMLNONE  ||  avail == FEDMLBOTH )
		{ /* check DBMS */
			if ( (level = IIUIdcs_sqlLevel()) != UI_DML_NOLEVEL 
				|| (level = IIUIdcq_quelLevel())
						!= UI_DML_NOLEVEL )
			{
				return (IIUIdbdata()->dmldef = level);
			}
		}

		/*
		** At this point we assume that this is an INGRES DBMS
		** with only one language authorized.
		*/

		if ( ( avail == FEDMLSQL &&
			       (level = IIUIdcs_sqlLevel()) != UI_DML_NOLEVEL )
			|| ( avail == FEDMLQUEL &&
			      (level = IIUIdcq_quelLevel()) != UI_DML_NOLEVEL ))
		{
			return (IIUIdbdata()->dmldef = level);
		}

		/*
		** At this point, only a major error such as a screwed up
		** "iidbcapabilities" catalog could have prevented us from
		** finding a default DML, so just return the most limited DML
		** (gateway SQL.)
		*/

		IIUIdbdata()->dmldef = UI_DML_GTWSQL;
	}
	return IIUIdbdata()->dmldef;
}
Esempio n. 2
0
VOID
r_rep_load ()
{
	char    *outname;
	char    *tempname;


	/* start of routine */

	r_open_db();		/* open database. If not there, abort */

	STtrmwhite(En_report);

	/* start object-oriented facility for retrieving reports */
	IIOOinit((OO_OBJECT **)NULL);

	En_rid = -1;

	/* set up report environment. */
	if (St_style==RS_NULL && (St_ispec || r_env_set()))
	{	/* report found.  Read in report specifications */
		if (!St_silent)
		{
			SIprintf(ERget(F_RW0005_Reading_report_spec));
			SIflush(stdout);
		}

		r_rco_set();	/* read in the RCOMMANDS table into core */
	}
	else
	{	/* no report found.  Use report name */
		if (St_repspec)
		{	/* error because report does not exist */
			r_error(0x3F7, FATAL, En_report, NULL);
		}
		En_rtype = RT_DEFAULT;
		En_ferslv.name = En_report;
		if  ((En_ferslv.name_dest = (char *)FEreqmem((u_i4)Rst4_tag,
		     (u_i4)(FE_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL)
		{
			IIUGbmaBadMemoryAllocation(
					ERx("r_rep_loadld - name_dest"));
		}

		if  ((En_ferslv.owner_dest = (char *)FEreqmem((u_i4)Rst4_tag,
		     (u_i4)(FE_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL)
		{
			IIUGbmaBadMemoryAllocation(
					ERx("r_rep_loadld - owner_dest"));
		}
		/*
		** If the server supports delimited identifiers, then
		** ensure that .DELIMID is enabled since we're doing a report
		** based upon a table, and it may require such services.
		*/
		if  (IIUIdlmcase() != UI_UNDEFCASE)
		{
			St_xns_given = TRUE;
		}
	}

	/*
	** set up (and maybe prompt for) declared variables
	*/
	r_dcl_set(TRUE);

        if ((En_qlang == FEDMLSQL) && (IIUIdbdata()->firstAutoCom == FALSE))
	{
		IIUIautocommit(UI_AC_OFF);
	}

	if( r_sc_qry(Ptr_set_top) == FAIL )
	{
		return;
	}
    
	IIUIdlmcase();          /* Hack for bug 96801 ingcbt198 */

	if(!r_chk_dat())		/* check for a valid data relation */
	{
		return;
	}


	if( !r_sendqry())/* send the query to the backend */
	{
		return;
	}
	

	if (!r_att_dflt())	/* set up ATT structures for each */
	{			/* attribute in the data relation */
		return;
	}


	if (En_rtype == RT_DEFAULT)
	{	/* set up the default report */
		if (!St_silent)
		{
			SIprintf(ERget(F_RW0006_Setting_up_default));
			SIflush(stdout);
		}

		/* Set up first column as a sort column */

		if  (!r_m_dsort())
		{
			r_error(0x416,NONFATAL,NULL);
			return;
		}
	}

	if (!r_srt_set())		/* set up the SORT data structures */
	{	/* bad RSORT */
		r_error(0x0C, FATAL, NULL);
	}
	/* set up the BRK data structures
	** for each sort attribute with a
	** RACTION tuple defined for it
	*/
	if( !r_brk_set())	
	{
		return;
	}


	/* 
	** If there is a .PAGEWIDTH command and no -l flag has been specified 
	** on the commandline, then reset En_lmax. (The -l flag overrides the 
	** .PAGEWIDTH command). (#129, #588)
	*/
        if( STlength(En_pg_width) > 0 && !St_lspec)
	{
		/* If the pagewidth value is preceded by
		* a dollar, evaluate it as a parameter
		*/
		r_g_set(En_pg_width);
		if( r_g_skip() == TK_DOLLAR )
		{
			CMnext(Tokchar);
			outname = r_g_name();
			if( (tempname = r_par_get(outname)) == NULL )
			{
				r_error(0x3F0, FATAL, outname, NULL);
			}
			STcopy(tempname, En_pg_width);
		}
		/* need to convert to a number and set it to En_lmax */
		if (CVan(En_pg_width, &En_lmax) != OK)
		{
			/* Unable to convert so ignore input */
			r_error(0x403, NONFATAL, outname, NULL);
		}
	}
		
	if (En_rtype == RT_DEFAULT)
	{	/* set up default report */
		r_m_rprt();
	}
	else
	{
		Tcmd_tag = FEbegintag();
		r_tcmd_set();		/* set up the tcmd data structures */
		FEendtag();
	}


	r_lnk_agg();		/* set up the CLR and OP structures for
				** fast processing of aggregates.
				*/

	return;
}